Sha256: 73ffc3cff69e99eb6811a86ddd2e49930becd76cf27b4708ca92d83d53174f82
Contents?: true
Size: 957 Bytes
Versions: 8
Compression:
Stored size: 957 Bytes
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, String 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 attribute :debate, Debate validates :debate, presence: true validate :user_can_close_debate def closed_at debate&.closed_at || Time.current end private def user_can_close_debate errors.add(:debate, :invalid) unless debate.official? end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems