Sha256: 6fe383d5d65542dfcb11dbc8e9f3e479bbeac922364c83592b94d0c0fe50b7ba
Contents?: true
Size: 1.3 KB
Versions: 22
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module Decidim module Assemblies module Admin # A class used to find the admins for an assembly. class AdminUsers < Rectify::Query # Syntactic sugar to initialize the class and return the queried objects. # # assembly - an assembly that needs to find its assembly admins def self.for(assembly) new(assembly).query end # Initializes the class. # # assembly - an assembly that needs to find its assembly admins def initialize(assembly) @assembly = assembly end # Finds organization admins and the users with role admin for the given assembly. # # Returns an ActiveRecord::Relation. def query Decidim::User.where(id: organization_admins).or(assembly_user_admins) end private attr_reader :assembly def organization_admins assembly.organization.admins end def assembly_user_admins assembly_user_admin_ids = Decidim::AssemblyUserRole .where(assembly: assembly, role: :admin) .pluck(:decidim_user_id) Decidim::User.where(id: assembly_user_admin_ids) end end end end end
Version data entries
22 entries across 22 versions & 1 rubygems