app/commands/decidim/consultations/admin/update_consultation.rb in decidim-consultations-0.24.3 vs app/commands/decidim/consultations/admin/update_consultation.rb in decidim-consultations-0.25.0.rc1

- old
+ new

@@ -4,18 +4,17 @@ module Consultations module Admin # A command with all the business logic when updating an existing participatory # consultation in the system. class UpdateConsultation < Rectify::Command + include ::Decidim::AttachmentAttributesMethods + # Public: Initializes the command. # # consultation - the Consultation to update # form - A form object with the params. def initialize(consultation, form) - form.banner_image = consultation.banner_image if form.banner_image.blank? - form.introductory_image = consultation.introductory_image if form.introductory_image.blank? - @consultation = consultation @form = form end # Executes the command. Broadcasts these events: @@ -55,19 +54,12 @@ slug: form.slug, highlighted_scope: form.highlighted_scope, introductory_video_url: form.introductory_video_url, start_voting_date: form.start_voting_date, end_voting_date: form.end_voting_date - }.merge(uploader_attributes) - end - - def uploader_attributes - { - banner_image: form.banner_image, - remove_banner_image: form.remove_banner_image, - introductory_image: form.introductory_image, - remove_introductory_image: form.remove_introductory_image - }.delete_if { |_k, val| val.is_a?(Decidim::ApplicationUploader) } + }.merge( + attachment_attributes(:introductory_image, :banner_image) + ) end end end end end