1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-13 23:48:55 +01:00
fab-manager/app/policies/event_policy.rb

28 lines
616 B
Ruby
Raw Normal View History

2015-05-05 03:10:25 +02:00
class EventPolicy < ApplicationPolicy
class Scope < Scope
def resolve
if user.nil? or (user and !user.admin?)
scope.includes(:event_image, :event_files, :availability, :category)
2015-05-05 03:10:25 +02:00
.where('availabilities.start_at >= ?', Time.now)
.order('availabilities.start_at ASC')
.references(:availabilities)
else
scope.includes(:event_image, :event_files, :availability, :category)
2015-05-05 03:10:25 +02:00
.references(:availabilities)
end
end
end
def create?
user.admin?
2015-05-05 03:10:25 +02:00
end
def update?
create?
end
def destroy?
create?
end
end