Sha256: 347129de731e4352a99ffecf941624636d8603388c1225c5398b3562d3694534
Contents?: true
Size: 1.11 KB
Versions: 6
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module Decidim module Elections module Admin # This command is executed when the user destroys an Election # from the admin panel. class DestroyElection < Decidim::Command include ::Decidim::AttachmentMethods include ::Decidim::GalleryMethods def initialize(election, current_user) @election = election @current_user = current_user @attached_to = election end # Destroys the election if valid. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:invalid) if invalid? destroy_election! broadcast(:ok, election) end private attr_reader :election, :current_user def invalid? election.started? end def destroy_election! Decidim.traceability.perform_action!( :delete, election, current_user, visibility: "all" ) do election.destroy! end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems