Sha256: 492894c759cd4cd2fc4130c8f9a09f39cef198160861330fc1d6d8f1f1c7b431
Contents?: true
Size: 1.11 KB
Versions: 30
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 < Rectify::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
30 entries across 30 versions & 1 rubygems