Sha256: fb328ed743b30b6332ce3458ac1418df1fc6bfe2993747f440865f42f02c9d0f
Contents?: true
Size: 1.11 KB
Versions: 3
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.blocked? 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
3 entries across 3 versions & 1 rubygems