Sha256: dac1eeee50c1837cbf1a51cc5ebb1ccb3714e68670aa0f53709bb86dbcd62e1e
Contents?: true
Size: 1.21 KB
Versions: 6
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module Decidim module ReportingProposals module Admin # A command with all the business logic when a user updates a proposal. class UpdateProposal < Decidim::Proposals::Admin::UpdateProposal # Public: Initializes the command. # # form - A form object with the params. # proposal - the proposal to update. def initialize(form, proposal) @form = form @proposal = proposal @attached_to = proposal end # Executes the command. Broadcasts these events: # # - :ok when everything is valid, together with the proposal. # - :invalid if the form wasn't valid and we couldn't proceed. # # Returns nothing. def call return broadcast(:invalid) if form.invalid? if process_gallery? build_gallery return broadcast(:invalid) if gallery_invalid? end transaction do create_gallery if process_gallery? photo_cleanup! end broadcast(:ok, proposal) end private attr_reader :form, :proposal, :gallery end end end end
Version data entries
6 entries across 6 versions & 1 rubygems