Sha256: dd92088c376b7f7357fd7267b3ff5c2c271a9600221ccf5512ee6d1616c6bea6
Contents?: true
Size: 1 KB
Versions: 12
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module Decidim module Proposals module Admin # A command with all the business logic related with an admin discarding participatory text proposals. class DiscardParticipatoryText < Decidim::Command # Public: Initializes the command. # # form - A PreviewParticipatoryTextForm form object with the params. def initialize(component) @component = component end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the form wasn't valid and we couldn't proceed. # # Returns nothing. def call transaction do discard_drafts end broadcast(:ok) end private attr_reader :form def discard_drafts proposals = Decidim::Proposals::Proposal.drafts.where(component: @component) proposals.destroy_all end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems