Sha256: aa7dc67beda0719b0d48c5f11cd965adce8e3f386de10b3647ece95a71198e83
Contents?: true
Size: 1.52 KB
Versions: 15
Compression:
Stored size: 1.52 KB
Contents
# frozen_string_literal: true module Decidim module Initiatives # A command with all the business logic that sends an # existing initiative to technical validation. class SendInitiativeToTechnicalValidation < Decidim::Command # Public: Initializes the command. # # initiative - Decidim::Initiative # current_user - the user performing the action def initialize(initiative, current_user) @initiative = initiative @current_user = current_user end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the form was not valid and we could not proceed. # # Returns nothing. def call @initiative = Decidim.traceability.perform_action!( :send_to_technical_validation, initiative, current_user ) do initiative.validating! initiative end notify_admins broadcast(:ok, initiative) end private attr_reader :initiative, :current_user def notify_admins affected_users = Decidim::User.org_admins_except_me(current_user).all data = { event: "decidim.events.initiatives.initiative_sent_to_technical_validation", event_class: Decidim::Initiatives::InitiativeSentToTechnicalValidationEvent, resource: initiative, affected_users:, force_send: true } Decidim::EventsManager.publish(**data) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems