Sha256: 6bcc9bab32bade2d51b21620f0b16e491b7be17ee727f34b01c94a71f1bb100d

Contents?: true

Size: 1008 Bytes

Versions: 11

Compression:

Stored size: 1008 Bytes

Contents

# frozen_string_literal: true
module Decidim
  module Admin
    # A class used to find the roles of the users that can manage a given
    # participatory process in a process admin role (that is, processs that are
    # not organization admins).
    class ProcessAdminRolesForProcess < 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 the UserRoles of the users that can manage the given process.
      #
      # Returns an ActiveRecord::Relation.
      def query
        ParticipatoryProcessUserRole
          .where(participatory_process: process, role: :admin)
      end

      private

      attr_reader :process
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
decidim-admin-0.0.6 app/queries/decidim/admin/process_admin_roles_for_process.rb
decidim-0.0.6 decidim-admin/app/queries/decidim/admin/process_admin_roles_for_process.rb
decidim-admin-0.0.5 app/queries/decidim/admin/process_admin_roles_for_process.rb
decidim-0.0.5 decidim-admin/app/queries/decidim/admin/process_admin_roles_for_process.rb
decidim-0.0.4 decidim-admin/app/queries/decidim/admin/process_admin_roles_for_process.rb
decidim-admin-0.0.3 app/queries/decidim/admin/process_admin_roles_for_process.rb
decidim-0.0.3 decidim-admin/app/queries/decidim/admin/process_admin_roles_for_process.rb
decidim-admin-0.0.2 app/queries/decidim/admin/process_admin_roles_for_process.rb
decidim-0.0.2 decidim-admin/app/queries/decidim/admin/process_admin_roles_for_process.rb
decidim-admin-0.0.1 app/queries/decidim/admin/process_admin_roles_for_process.rb
decidim-0.0.1 decidim-admin/app/queries/decidim/admin/process_admin_roles_for_process.rb