@record/@user in topic/synapse policy
This commit is contained in:
parent
1e01ff8bc9
commit
3ed6ffbdba
2 changed files with 11 additions and 11 deletions
|
@ -1,25 +1,25 @@
|
||||||
class SynapsePolicy < ApplicationPolicy
|
class SynapsePolicy < ApplicationPolicy
|
||||||
class Scope < Scope
|
class Scope < Scope
|
||||||
def resolve
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
def create?
|
def create?
|
||||||
user.present?
|
@user.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def show?
|
def show?
|
||||||
#record.permission == 'commons' || record.permission == 'public' || record.user == user
|
# @record.permission == 'commons' || @record.permission == 'public' || @record.user == @user
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def update?
|
def update?
|
||||||
#user.present? && (record.permission == 'commons' || record.user == user)
|
# @user.present? && (@record.permission == 'commons' || @record.user == @user)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy?
|
def destroy?
|
||||||
record.user == user || user.admin
|
@record.user == @user || @user.admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
class TopicPolicy < ApplicationPolicy
|
class TopicPolicy < ApplicationPolicy
|
||||||
class Scope < Scope
|
class Scope < Scope
|
||||||
def resolve
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
def create?
|
def create?
|
||||||
user.present?
|
@user.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def show?
|
def show?
|
||||||
record.permission == 'commons' || record.permission == 'public' || record.user == user
|
@record.permission == 'commons' || @record.permission == 'public' || @record.user == @user
|
||||||
end
|
end
|
||||||
|
|
||||||
def update?
|
def update?
|
||||||
# user.present? && (record.permission == 'commons' || record.user == user)
|
# @user.present? && (@record.permission == 'commons' || @record.user == @user)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy?
|
def destroy?
|
||||||
record.user == user || user.admin
|
@record.user == @user || @user.admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def autocomplete_topic?
|
def autocomplete_topic?
|
||||||
user.present?
|
@user.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def network?
|
def network?
|
||||||
|
|
Loading…
Reference in a new issue