23 lines
493 B
Ruby
23 lines
493 B
Ruby
class SynapsePolicy < ApplicationPolicy
|
|
class Scope < Scope
|
|
def resolve
|
|
scope.where('permission IN (?) OR user_id = ?', ["public", "commons"], user.id)
|
|
end
|
|
end
|
|
|
|
def create?
|
|
user.present?
|
|
end
|
|
|
|
def show?
|
|
record.permission == 'commons' || record.permission == 'public' || record.user == user
|
|
end
|
|
|
|
def update?
|
|
user.present? && (record.permission == 'commons' || record.user == user)
|
|
end
|
|
|
|
def destroy?
|
|
record.user == user || admin_override
|
|
end
|
|
end
|