@record/@user in topic/synapse policy

This commit is contained in:
Devin Howard 2016-02-28 13:29:33 +08:00
parent 1e01ff8bc9
commit 3ed6ffbdba
2 changed files with 11 additions and 11 deletions

View file

@ -1,25 +1,25 @@
class SynapsePolicy < ApplicationPolicy
class Scope < Scope
def resolve
scope.where('permission IN ("public", "commons") OR user_id = ?', user.id)
scope.where('permission IN ("public", "commons") OR user_id = ?', @user.id)
end
end
def create?
user.present?
@user.present?
end
def show?
#record.permission == 'commons' || record.permission == 'public' || record.user == user
# @record.permission == 'commons' || @record.permission == 'public' || @record.user == @user
true
end
def update?
#user.present? && (record.permission == 'commons' || record.user == user)
# @user.present? && (@record.permission == 'commons' || @record.user == @user)
true
end
def destroy?
record.user == user || user.admin
@record.user == @user || @user.admin
end
end

View file

@ -1,29 +1,29 @@
class TopicPolicy < ApplicationPolicy
class Scope < Scope
def resolve
scope.where('permission IN ("public", "commons") OR user_id = ?', user.id)
scope.where('permission IN ("public", "commons") OR user_id = ?', @user.id)
end
end
def create?
user.present?
@user.present?
end
def show?
record.permission == 'commons' || record.permission == 'public' || record.user == user
@record.permission == 'commons' || @record.permission == 'public' || @record.user == @user
end
def update?
# user.present? && (record.permission == 'commons' || record.user == user)
# @user.present? && (@record.permission == 'commons' || @record.user == @user)
true
end
def destroy?
record.user == user || user.admin
@record.user == @user || @user.admin
end
def autocomplete_topic?
user.present?
@user.present?
end
def network?