2016-02-13 09:28:16 +00:00
|
|
|
class TopicPolicy < ApplicationPolicy
|
|
|
|
class Scope < Scope
|
|
|
|
def resolve
|
2016-02-28 05:29:33 +00:00
|
|
|
scope.where('permission IN ("public", "commons") OR user_id = ?', @user.id)
|
2016-02-13 09:28:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def create?
|
2016-02-28 05:29:33 +00:00
|
|
|
@user.present?
|
2016-02-13 09:28:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show?
|
2016-02-28 05:29:33 +00:00
|
|
|
@record.permission == 'commons' || @record.permission == 'public' || @record.user == @user
|
2016-02-13 09:28:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update?
|
2016-02-28 05:29:33 +00:00
|
|
|
# @user.present? && (@record.permission == 'commons' || @record.user == @user)
|
2016-02-13 09:28:16 +00:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
2016-02-28 05:29:33 +00:00
|
|
|
@record.user == @user || @user.admin
|
2016-02-13 09:28:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def autocomplete_topic?
|
2016-02-28 05:29:33 +00:00
|
|
|
@user.present?
|
2016-02-13 09:28:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def network?
|
|
|
|
show?
|
|
|
|
end
|
|
|
|
|
|
|
|
def relative_numbers?
|
|
|
|
show?
|
|
|
|
end
|
|
|
|
|
|
|
|
def relatives?
|
|
|
|
show?
|
|
|
|
end
|
|
|
|
end
|