Sha256: 02f4e84084e56563f2eb68efb70cb467e1ca50bfcf761453eefc8eab7b370a22
Contents?: true
Size: 1022 Bytes
Versions: 31
Compression:
Stored size: 1022 Bytes
Contents
# frozen_string_literal: true module Decidim module Elections module Admin # This command is executed when the user destroys a Question # from the admin panel. class DestroyQuestion < Rectify::Command def initialize(question, current_user) @question = question @current_user = current_user end # Destroys the question if valid. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:invalid) if invalid? destroy_question! broadcast(:ok, question) end private attr_reader :question, :current_user def invalid? question.election.started? end def destroy_question! Decidim.traceability.perform_action!( :delete, question, current_user, visibility: "all" ) do question.destroy! end end end end end end
Version data entries
31 entries across 31 versions & 1 rubygems