Sha256: 19f3db9256bf3b2f31a62fd60a3eaaed66f9d9bc2cd7d2d4f521ac3dd4a3f3c7
Contents?: true
Size: 1.1 KB
Versions: 31
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module Decidim module Elections module Admin # This command is executed when the user destroys an Answer # from the admin panel. class DestroyAnswer < Rectify::Command include ::Decidim::AttachmentMethods include ::Decidim::GalleryMethods def initialize(answer, current_user) @answer = answer @current_user = current_user @attached_to = answer end # Destroys the answer if valid. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:invalid) if invalid? destroy_answer broadcast(:ok, answer) end private attr_reader :answer, :current_user def invalid? answer.question.election.started? end def destroy_answer Decidim.traceability.perform_action!( :delete, answer, current_user, visibility: "all" ) do answer.destroy! end end end end end end
Version data entries
31 entries across 31 versions & 1 rubygems