Sha256: f4a18a2caac6994a15ee9e800470c839bd88c6902c6be3e81b91fea750abeaab

Contents?: true

Size: 1.3 KB

Versions: 19

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

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

        # Syntactic sugar to initialize the class and return the queried objects.
        #
        # organization - an organization that needs to find its voting admins
        def self.for_organization(organization)
          new(nil, organization).query
        end

        # Initializes the class.
        #
        # voting - a voting that needs to find its voting admins
        # organization - an organization that needs to find its voting admins
        def initialize(voting, organization = nil)
          @voting = voting
          @organization = voting&.organization || organization
        end

        # Finds organization admins and the users with role admin for the given voting.
        #
        # Returns an ActiveRecord::Relation.
        def query
          organization.admins
        end

        private

        attr_reader :voting, :organization
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.9 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.28.3 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.8 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.28.2 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.7 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.28.1 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.6 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.28.0 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.5 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.28.0.rc5 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.28.0.rc4 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.4 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.3 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.2 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.1 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.0 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.0.rc2 app/queries/decidim/votings/admin/admin_users.rb
decidim-elections-0.27.0.rc1 app/queries/decidim/votings/admin/admin_users.rb