Sha256: cb49b438a5d5d780d2501f13aac96864f56e37ce1043de74ce021132503a76dd

Contents?: true

Size: 947 Bytes

Versions: 1

Compression:

Stored size: 947 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ReportingProposals
    class UpdateReportingProposal < Decidim::Proposals::UpdateProposal
      include ::Decidim::Proposals::GalleryMethods

      def call
        return broadcast(:invalid) if invalid?

        if process_attachments?
          build_attachments
          return broadcast(:invalid) if attachments_invalid?
        end

        if process_gallery?
          build_gallery
          return broadcast(:invalid) if gallery_invalid?
        end

        with_events(with_transaction: true) do
          if @proposal.draft?
            update_draft
          else
            update_proposal
          end

          document_cleanup!(include_all_attachments: true)

          create_attachments(first_weight: first_attachment_weight) if process_attachments?
          create_gallery if process_gallery?
        end

        broadcast(:ok, proposal)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-reporting_proposals-0.6.0 app/commands/decidim/reporting_proposals/update_reporting_proposal.rb