Sha256: 1b07f0b1b10c0996139015eb4fc4d164ff39b4d14f53cfff2782a0594b936cec
Contents?: true
Size: 1 KB
Versions: 12
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module Decidim module Debates module Admin # This class holds a Form to close debates from Decidim's admin views. class CloseDebateForm < Decidim::Form include TranslatableAttributes mimic :debate translatable_attribute :conclusions, Decidim::Attributes::CleanString do |translated_attribute, locale| validates translated_attribute, presence: true, if: ->(record) { record.default_locale?(locale) } validates translated_attribute, length: { minimum: 10, maximum: 10_000 }, if: ->(record) { record.default_locale?(locale) } end validates :debate, presence: true validate :user_can_close_debate def closed_at debate&.closed_at || Time.current end def debate @debate ||= Debate.find_by(id: id) end private def user_can_close_debate errors.add(:debate, :invalid) unless debate.official? end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems