app/forms/decidim/consultations/admin/consultation_form.rb in decidim-consultations-0.22.0 vs app/forms/decidim/consultations/admin/consultation_form.rb in decidim-consultations-0.23.0

- old
+ new

@@ -4,10 +4,11 @@ module Consultations module Admin # A form object used to create consultations from the admin dashboard. class ConsultationForm < Form include TranslatableAttributes + include Decidim::HasUploadValidations mimic :consultation translatable_attribute :title, String translatable_attribute :subtitle, String @@ -27,15 +28,13 @@ validates :decidim_highlighted_scope_id, presence: true validates :start_voting_date, presence: true, date: { before_or_equal_to: :end_voting_date } validates :end_voting_date, presence: true, date: { after_or_equal_to: :start_voting_date } validate :slug_uniqueness - validates :banner_image, - file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } }, - file_content_type: { allow: ["image/jpeg", "image/png"] } - validates :introductory_image, - file_size: { less_than_or_equal_to: ->(_record) { Decidim.maximum_attachment_size } }, - file_content_type: { allow: ["image/jpeg", "image/png"] } + validates :banner_image, passthru: { to: Decidim::Consultation } + validates :introductory_image, passthru: { to: Decidim::Consultation } + + alias organization current_organization def highlighted_scope @highlighted_scope ||= current_organization.scopes.find_by(id: decidim_highlighted_scope_id) end