Class: Decidim::ParticipatoryProcesses::Admin::Moderators

Inherits:
Query
  • Object
show all
Defined in:
decidim-participatory_processes/app/queries/decidim/participatory_processes/admin/moderators.rb

Overview

A class used to find the users that can moderate the participatory process.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Query

#cached_query, #each, #eager?, #exists?, merge, #none?, #relation?, #|

Constructor Details

#initialize(process, organization = nil) ⇒ Moderators

Initializes the class.

process - a process that needs to find its process admins organization - an organization that needs to find its process admins


27
28
29
30
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/admin/moderators.rb', line 27

def initialize(process, organization = nil)
  @process = process
  @organization = process&.organization || organization
end

Class Method Details

.for(process) ⇒ Object

Syntactic sugar to initialize the class and return the queried objects.

process - a process that needs to find its moderators


12
13
14
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/admin/moderators.rb', line 12

def self.for(process)
  new(process).query
end

.for_organization(organization) ⇒ Object

Syntactic sugar to initialize the class and return the queried objects.

organization - an organization that needs to find its moderators


19
20
21
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/admin/moderators.rb', line 19

def self.for_organization(organization)
  new(nil, organization).query
end

Instance Method Details

#queryObject

Finds organization admins and the users with role admin for the given process.

Returns an ActiveRecord::Relation.


36
37
38
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/admin/moderators.rb', line 36

def query
  organization.admins.or(processes_user_admins)
end