metamaps--metamaps/app/policies/topic_policy.rb

41 lines
651 B
Ruby
Raw Normal View History

2016-02-13 09:28:16 +00:00
class TopicPolicy < ApplicationPolicy
class Scope < Scope
def resolve
scope.where('permission IN ("public", "commons") OR user_id = ?', 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)
true
end
def destroy?
record.user == user || user.admin
end
def autocomplete_topic?
user.present?
end
def network?
show?
end
def relative_numbers?
show?
end
def relatives?
show?
end
end