app/forms/decidim/accountability/admin/result_form.rb in decidim-accountability-0.1.2 vs app/forms/decidim/accountability/admin/result_form.rb in decidim-accountability-0.7.0
- old
+ new
@@ -15,11 +15,10 @@
attribute :decidim_category_id, Integer
attribute :proposal_ids, Array[Integer]
attribute :start_date, Date
attribute :end_date, Date
attribute :progress, Float
- attribute :external_id, String
attribute :decidim_accountability_status_id, Integer
attribute :parent_id, Integer
validates :title, translatable_presence: true
validates :description, translatable_presence: true
@@ -28,12 +27,10 @@
validates :category, presence: true, if: ->(form) { form.decidim_category_id.present? }
validates :parent, presence: true, if: ->(form) { form.parent_id.present? }
validates :status, presence: true, if: ->(form) { form.decidim_accountability_status_id.present? }
- validate :external_id_uniqueness
-
def map_model(model)
self.proposal_ids = model.linked_resources(:proposals, "included_proposals").pluck(:id)
self.decidim_category_id = model.category.try(:id)
end
@@ -57,17 +54,9 @@
@parent ||= Decidim::Accountability::Result.where(feature: current_feature, id: parent_id).first
end
def status
@status ||= Decidim::Accountability::Status.where(feature: current_feature, id: decidim_accountability_status_id).first
- end
-
- private
-
- def external_id_uniqueness
- return if external_id.blank?
- existing_with_external_id = Decidim::Accountability::Result.find_by(feature: current_feature, external_id: external_id)
- errors.add(:external_id, :taken) if existing_with_external_id && existing_with_external_id.id != id
end
end
end
end
end