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