Sha256: 11d8b3704eb433bd31b82f6564f0aaa18b7f20f43486fede89958c1c20d5b791
Contents?: true
Size: 1.38 KB
Versions: 29
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true module Decidim module Elections module Admin # This command gets called when a election is published from the admin panel. class PublishElection < Rectify::Command # Public: Initializes the command. # # election - The election to publish. # current_user - the user performing the action def initialize(election, current_user) @election = election @current_user = current_user end # Public: Publishes the Election. # # Broadcasts :ok if published, :invalid otherwise. def call publish_election publish_event broadcast(:ok, election) end private attr_reader :election, :current_user def publish_election Decidim.traceability.perform_action!( :publish, election, current_user, visibility: "all" ) do election.publish! election end end def publish_event Decidim::EventsManager.publish( event: "decidim.events.elections.election_published", event_class: ::Decidim::Elections::ElectionPublishedEvent, resource: election, followers: election.participatory_space.followers ) end end end end end
Version data entries
29 entries across 29 versions & 1 rubygems