Sha256: b9a8d2aff45aeb0f1ac30abc4a2f50bd0f10de3a8f6716d52a9e47533fc256fc

Contents?: true

Size: 1.35 KB

Versions: 22

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    module Admin
      # A class used to find the admins for an conference.
      class AdminUsers < Rectify::Query
        # Syntactic sugar to initialize the class and return the queried objects.
        #
        # conference - an conference that needs to find its conference admins
        def self.for(conference)
          new(conference).query
        end

        # Initializes the class.
        #
        # conference - an conference that needs to find its conference admins
        def initialize(conference)
          @conference = conference
        end

        # Finds organization admins and the users with role admin for the given conference.
        #
        # Returns an ActiveRecord::Relation.
        def query
          Decidim::User.where(id: organization_admins).or(conference_user_admins)
        end

        private

        attr_reader :conference

        def organization_admins
          conference.organization.admins
        end

        def conference_user_admins
          conference_user_admin_ids = Decidim::ConferenceUserRole
                                      .where(conference: conference, role: :admin)
                                      .pluck(:decidim_user_id)
          Decidim::User.where(id: conference_user_admin_ids)
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
decidim-conferences-0.24.3 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.23.6 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.24.2 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.23.5 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.24.1 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.24.0 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.24.0.rc2 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.23.4 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.24.0.rc1 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.23.3 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.23.2 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.23.1 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.23.1.rc1 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.23.0 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.22.0 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.21.0 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.20.1 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.20.0 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.19.1 app/queries/decidim/conferences/admin/admin_users.rb
decidim-conferences-0.18.1 app/queries/decidim/conferences/admin/admin_users.rb