Commit 6114c40f authored by Bob Van Landuyt's avatar Bob Van Landuyt

Move `ProjectPolicy`-class methods into module

That way the ProjectPolicy class can be extended with this module
before we prepend the EE::ProjectPolicy. This makes the classmethods
available for rules defined in the EE::ProjectPolicy.
parent bdd7600d
class ProjectPolicy < BasePolicy class ProjectPolicy < BasePolicy
extend ClassMethods
READONLY_FEATURES_WHEN_ARCHIVED = %i[ READONLY_FEATURES_WHEN_ARCHIVED = %i[
issue issue
list list
...@@ -20,22 +22,6 @@ class ProjectPolicy < BasePolicy ...@@ -20,22 +22,6 @@ class ProjectPolicy < BasePolicy
cluster cluster
].freeze ].freeze
def self.create_read_update_admin_destroy(name)
[
:"read_#{name}",
*create_update_admin_destroy(name)
]
end
def self.create_update_admin_destroy(name)
[
:"create_#{name}",
:"update_#{name}",
:"admin_#{name}",
:"destroy_#{name}"
]
end
desc "User is a project owner" desc "User is a project owner"
condition :owner do condition :owner do
(project.owner.present? && project.owner == @user) || (project.owner.present? && project.owner == @user) ||
......
class ProjectPolicy
module ClassMethods
def create_read_update_admin_destroy(name)
[
:"read_#{name}",
*create_update_admin_destroy(name)
]
end
def create_update_admin_destroy(name)
[
:"create_#{name}",
:"update_#{name}",
:"admin_#{name}",
:"destroy_#{name}"
]
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment