app/commands/decidim/consultations/admin/update_question.rb in decidim-consultations-0.23.6 vs app/commands/decidim/consultations/admin/update_question.rb in decidim-consultations-0.24.0.rc1
- old
+ new
@@ -9,10 +9,13 @@
# 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:
@@ -53,20 +56,25 @@
what_is_decided: form.what_is_decided,
promoter_group: form.promoter_group,
participatory_scope: form.participatory_scope,
question_context: form.question_context,
hashtag: form.hashtag,
- hero_image: form.hero_image,
- remove_hero_image: form.remove_hero_image,
- banner_image: form.banner_image,
- remove_banner_image: form.remove_banner_image,
origin_scope: form.origin_scope,
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) }
end
end
end
end
end