Sha256: 9ac83d9de1899403423b12452629da16b7a64038546c6d288583e72cb9308cf0

Contents?: true

Size: 945 Bytes

Versions: 19

Compression:

Stored size: 945 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module UserGroups
    # Use this class to find the the admins of the given user group with the
    # "admin" role. It returns memberships.
    class AdminMemberships < Decidim::Query
      # Syntactic sugar to initialize the class and return the queried objects.
      #
      # user_group - a UserGroup that needs to find its admin users
      def self.for(user_group)
        new(user_group).query
      end

      # Initializes the class.
      #
      # user_group - a UserGroup that needs to find its admin users
      def initialize(user_group)
        @user_group = user_group
      end

      # Finds the admin users of the user group.
      #
      # Returns an ActiveRecord::Relation.
      def query
        user_group
          .non_deleted_memberships
          .includes(:user)
          .where(role: :admin)
      end

      private

      attr_reader :user_group
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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