Sha256: 52dd1eec90bf3c2a70557913fbb321b1f753f52002895c65711e6a07a536d749
Contents?: true
Size: 1.4 KB
Versions: 25
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true module Decidim module Elections module Admin # This class holds a form to start and end the voting period. class VotePeriodForm < ActionForm validate do validations.each do |message, t_args, valid| errors.add(message, I18n.t("steps.#{current_step}.errors.#{message}", **t_args, scope: "decidim.elections.admin")) unless valid end end def validations @validations ||= if current_step == "key_ceremony_ended" [ [:time_before, { start_time: I18n.l(election.start_time, format: :long), hours: Decidim::Elections.start_vote_maximum_hours_before_start }, election.maximum_hours_before_start?] ].freeze else [ [:time_after, { end_time: I18n.l(election.end_time, format: :long) }, election.finished?] ].freeze end end def messages @messages ||= validations.map do |message, t_args, _valid| [message, I18n.t("steps.#{current_step}.requirements.#{message}", **t_args, scope: "decidim.elections.admin")] end.to_h end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems