Events: initial implementation
This commit is contained in:
25
app/policies/event_policy.rb
Normal file
25
app/policies/event_policy.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
class EventPolicy < ApplicationPolicy
|
||||
def owner_or_admin
|
||||
if record == :event
|
||||
true
|
||||
else
|
||||
record.user.id == user.id || user.admin?
|
||||
end
|
||||
end
|
||||
|
||||
def index?
|
||||
owner_or_admin
|
||||
end
|
||||
|
||||
def new?
|
||||
owner_or_admin
|
||||
end
|
||||
|
||||
def create?
|
||||
owner_or_admin
|
||||
end
|
||||
|
||||
def show?
|
||||
owner_or_admin
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user