Sha256: e14c53f3ae8b06faf998d937c1dc48bdb539a8e35851bd1b1fce2f4df8f154bb
Contents?: true
Size: 1.45 KB
Versions: 40
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true module Decidim module Assemblies module Admin # A command with all the business logic when creating a new participatory # process admin in the system. class CreateAssemblyAdmin < NotifyRoleAssignedToAssembly include ::Decidim::Admin::CreateParticipatorySpaceAdminUserActions # Public: Initializes the command. # # form - A form object with the params. # assembly - The Assembly that will hold the # user role def initialize(form, current_user, assembly) @form = form @current_user = current_user @participatory_space = assembly end private attr_reader :form, :participatory_space, :current_user, :user def existing_role Decidim::AssemblyUserRole.exists?( role: form.role.to_sym, user: user, assembly: @participatory_process ) end def create_role Decidim.traceability.perform_action!( :create, Decidim::AssemblyUserRole, current_user, resource: { title: user.name } ) do Decidim::AssemblyUserRole.find_or_create_by!( role: form.role.to_sym, user: user, assembly: participatory_space ) end send_notification user end end end end end
Version data entries
40 entries across 40 versions & 1 rubygems