Sha256: 42d84499923bb5dea5363c603299b228ab284cb8f8a5ef9cec11d607078cd870
Contents?: true
Size: 1.16 KB
Versions: 10
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Decidim module Admin # A class used to find the admins for a participatory process including # organization admins. class ProcessAdmins < Rectify::Query # Syntactic sugar to initialize the class and return the queried objects. # # process - a process that needs to find its process admins def self.for(process) new(process).query end # Initializes the class. # # process - a process that needs to find its process admins def initialize(process) @process = process end # Finds organization admins and the users with role admin for the given process. # # Returns an ActiveRecord::Relation. def query Decidim::User.where(id: organization_admins).or(Decidim::User.where(id: process_admins)) end private attr_reader :process def organization_admins process.organization.admins end def process_admins Decidim::Admin::ParticipatoryProcessUserRole .where(participatory_process: process, role: :admin) .pluck(:decidim_user_id) end end end end
Version data entries
10 entries across 10 versions & 2 rubygems