Class: Decidim::ReportingProposals::UpdateReportingProposal

Inherits:
Proposals::UpdateProposal
  • Object
show all
Includes:
Proposals::GalleryMethods
Defined in:
app/commands/decidim/reporting_proposals/update_reporting_proposal.rb

Instance Method Summary collapse

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/commands/decidim/reporting_proposals/update_reporting_proposal.rb', line 8

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