app/commands/decidim/consultations/admin/update_question.rb in decidim-consultations-0.24.3 vs app/commands/decidim/consultations/admin/update_question.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 # question in the system. class UpdateQuestion < Rectify::Command + include ::Decidim::AttachmentAttributesMethods + # Public: Initializes the command. # # question - the Question to update # form - A form object with the params. def initialize(question, form) - form.hero_image = question.hero_image if form.hero_image.blank? - form.banner_image = question.banner_image if form.banner_image.blank? - @question = question @form = form end # Executes the command. Broadcasts these events: @@ -62,19 +61,12 @@ origin_title: form.origin_title, origin_url: form.origin_url, external_voting: form.external_voting, i_frame_url: form.i_frame_url, order: form.order - }.merge(uploader_attributes) - end - - def uploader_attributes - { - hero_image: form.hero_image, - remove_hero_image: form.remove_hero_image, - banner_image: form.banner_image, - remove_banner_image: form.remove_banner_image - }.delete_if { |_k, val| val.is_a?(Decidim::ApplicationUploader) } + }.merge( + attachment_attributes(:hero_image, :banner_image) + ) end end end end end