Sha256: c71e721274718e5ba2782655a56c38e9a8f82b86fae2d6263170c4d98ff6a588
Contents?: true
Size: 1022 Bytes
Versions: 14
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 < Decidim::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.blocked? 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
14 entries across 14 versions & 1 rubygems