Class: Decidim::ParticipatoryProcesses::VisibleParticipatoryProcessGroups
- Inherits:
-
Query
- Object
- Query
- Decidim::ParticipatoryProcesses::VisibleParticipatoryProcessGroups
- Defined in:
- decidim-participatory_processes/app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb
Overview
This query class filters participatory processes given a current_user.
Instance Method Summary collapse
- #groups ⇒ Object
-
#initialize(current_user) ⇒ VisibleParticipatoryProcessGroups
constructor
A new instance of VisibleParticipatoryProcessGroups.
- #query ⇒ Object
Methods inherited from Query
#cached_query, #each, #eager?, #exists?, merge, #none?, #relation?, #|
Constructor Details
#initialize(current_user) ⇒ VisibleParticipatoryProcessGroups
Returns a new instance of VisibleParticipatoryProcessGroups.
7 8 9 |
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb', line 7 def initialize(current_user) @current_user = current_user end |
Instance Method Details
#groups ⇒ Object
25 26 27 |
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb', line 25 def groups @groups ||= Decidim::ParticipatoryProcessGroup.all end |
#query ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb', line 11 def query processes = Decidim::ParticipatoryProcess.all if @current_user return groups if @current_user.admin? processes = processes.visible_for(@current_user.id) else processes = processes.public_spaces end groups.where(id: processes.pluck(:decidim_participatory_process_group_id)) end |