Class: Decidim::Admin::ManageableParticipatoryProcessesForUser
- Inherits:
-
Rectify::Query
- Object
- Rectify::Query
- Decidim::Admin::ManageableParticipatoryProcessesForUser
- Defined in:
- decidim-admin/app/queries/decidim/admin/manageable_participatory_processes_for_user.rb
Overview
A class used to find the ParticipatoryProcesses that the given user can manage.
Class Method Summary collapse
-
.for(user) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
Instance Method Summary collapse
-
#initialize(user) ⇒ ManageableParticipatoryProcessesForUser
constructor
Initializes the class.
-
#query ⇒ Object
Finds the ParticipatoryProcesses that the given user can manage.
Constructor Details
#initialize(user) ⇒ ManageableParticipatoryProcessesForUser
Initializes the class.
user - a User that needs to find which processes can manage
18 19 20 |
# File 'decidim-admin/app/queries/decidim/admin/manageable_participatory_processes_for_user.rb', line 18 def initialize(user) @user = user end |
Class Method Details
.for(user) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
user - a User that needs to find which processes can manage
11 12 13 |
# File 'decidim-admin/app/queries/decidim/admin/manageable_participatory_processes_for_user.rb', line 11 def self.for(user) new(user).query end |
Instance Method Details
#query ⇒ Object
Finds the ParticipatoryProcesses that the given user can manage.
Returns an ActiveRecord::Relation.
25 26 27 28 29 |
# File 'decidim-admin/app/queries/decidim/admin/manageable_participatory_processes_for_user.rb', line 25 def query return user.organization.participatory_processes if user.role?(:admin) || user.role?(:collaborator) ParticipatoryProcess.where(id: process_ids) end |