key, ability fixes

This commit is contained in:
Andreas Stephanides
2015-06-10 17:11:21 +02:00
parent c57095bbca
commit f62ed335ec
2 changed files with 9 additions and 4 deletions

View File

@@ -169,10 +169,14 @@ end
can [:showics], Calendar
# can [:show], Calentry
if (!k.nil? && k.typ==1 && (k.user.has_role?("fetuser")||k.user.has_role?("fetadmin")))
can [:show,:index], Calendar
if k.parent.nil?
can [:show,:index], Calendar
else
can [:show], Calendar, id: k.parent_id
end
end
if( user.has_role?("fetuser") || user.has_role?("fetadmin")||)
if( user.has_role?("fetuser") || user.has_role?("fetadmin"))
can [:show,:index], Calendar
can [:edit, :update,:new,:create,:verwalten], Calendar
can [:edit, :update,:new,:create,:verwalten,:delete], Calentry

View File

@@ -1,5 +1,5 @@
class Key < ActiveRecord::Base
attr_accessible :expire, :is_valid, :typ,
attr_accessible :expire, :is_valid, :typ
belongs_to :parent, :polymorphic => true
belongs_to :user
before_create :create_unique_identifier
@@ -16,6 +16,7 @@ class Key < ActiveRecord::Base
kk.user=user
kk.typ = typ
kk.is_valid = true
kk.save
end
else
kk=Key.where(user_id: user.id, typ: typ, is_valid: true, parent_type: parent.class.to_s, parent_id: parent.id).first
@@ -26,7 +27,7 @@ class Key < ActiveRecord::Base
kk.typ = typ
kk.is_valid = true
kk.parent=parent
kk.save
end
end
kk