Sha256: 75dee5c0ca12a1d05b9f66b87563f95b02ca8197fe35b9cf4c48159aaf7bf642

Contents?: true

Size: 1.63 KB

Versions: 40

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    module Admin
      # A command with all the business logic when creating a new participatory
      # process admin in the system.
      class CreateParticipatoryProcessAdmin < NotifyRoleAssignedToParticipatoryProcess
        include ::Decidim::Admin::CreateParticipatorySpaceAdminUserActions

        # Public: Initializes the command.
        #
        # form - A form object with the params.
        # current_user - the user performing this action
        # participatory_process - The ParticipatoryProcess that will hold the
        #   user role
        def initialize(form, current_user, participatory_process)
          @form = form
          @current_user = current_user
          @participatory_space = participatory_process
        end

        private

        attr_reader :form, :participatory_space, :current_user, :user

        def create_role
          extra_info = {
            resource: {
              title: user.name
            }
          }
          role_params = {
            role: form.role.to_sym,
            user: user,
            participatory_process: participatory_space
          }

          Decidim.traceability.create!(
            Decidim::ParticipatoryProcessUserRole,
            current_user,
            role_params,
            extra_info
          )
          send_notification user
        end

        def existing_role
          Decidim::ParticipatoryProcessUserRole.exists?(
            role: form.role.to_sym,
            user: user,
            participatory_process: participatory_space
          )
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.27.9 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.27.8 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.27.7 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.27.6 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.26.10 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.26.9 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.27.5 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.26.8 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.27.4 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.27.3 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.26.7 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.26.5 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.27.2 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.27.1 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.26.4 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.27.0 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.26.3 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.27.0.rc2 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.27.0.rc1 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
decidim-participatory_processes-0.26.2 app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb