app/forms/decidim/elections/admin/setup_form.rb in decidim-elections-0.26.10 vs app/forms/decidim/elections/admin/setup_form.rb in decidim-elections-0.27.0.rc1

- old
+ new

@@ -11,16 +11,10 @@ validate do validations.each do |message, t_args, valid| errors.add(message, I18n.t("steps.create_election.errors.#{message}", **t_args, scope: "decidim.elections.admin")) unless valid end - - if needs_census? - census_validations.each do |message, t_args, valid| - errors.add(message, I18n.t("steps.create_election.errors.#{message}", **t_args, scope: "decidim.elections.admin")) unless valid - end - end end def current_step; end def pending_action; end @@ -39,35 +33,18 @@ [:minimum_questions, {}, election.questions.any?], [:minimum_answers, {}, election.minimum_answers?], [:max_selections, {}, election.valid_questions?], [:published, {}, election.published_at.present?], [:component_published, {}, election.component.published?], - [:time_before, { hours: I18n.t("datetime.distance_in_words.x_hours", count: Decidim::Elections.setup_minimum_hours_before_start) }, - election.minimum_hours_before_start?], + [:time_before, { hours: Decidim::Elections.setup_minimum_hours_before_start }, election.minimum_hours_before_start?], [:trustees_number, { number: bulletin_board.number_of_trustees }, participatory_space_trustees_with_public_key.size >= bulletin_board.number_of_trustees] ].freeze end - def census_validations - return [] unless needs_census? - - @census_validations ||= [ - [:census_uploaded, {}, census.present? && census.data.exists?], - [:census_codes_generated, {}, census_codes_generated?], - [:census_frozen, {}, census&.freeze?] - ].freeze - end - def messages - @messages ||= validations.map do |message, t_args, _valid| + @messages ||= validations.to_h do |message, t_args, _valid| [message, I18n.t("steps.create_election.requirements.#{message}", **t_args, scope: "decidim.elections.admin")] - end.to_h - end - - def census_messages - @census_messages ||= census_validations.to_h do |message, t_args, _valid| - [message, I18n.t("steps.create_election.requirements.#{message}", **t_args, scope: "decidim.elections.admin")] end end def participatory_space_trustees @participatory_space_trustees ||= Decidim::Elections::Trustees::ByParticipatorySpace.new(election.component.participatory_space).to_a @@ -79,37 +56,17 @@ def bulletin_board @bulletin_board ||= context[:bulletin_board] || Decidim::Elections.bulletin_board end - def needs_census? - vote_flow.is_a?(Decidim::Votings::CensusVoteFlow) - end - - def vote_flow - @vote_flow ||= election.participatory_space.try(:vote_flow_for, election) - end - - def census_codes_generated? - return unless needs_census? - - census&.codes_generated? || census&.exporting_codes? || census&.freeze? - end - - def census - return unless needs_census? - - @census ||= election.component.participatory_space.dataset - end - def main_button? true end private def choose_random_trustees - return @trustee_ids if @trustee_ids.any? || defined?(@trustees) + return @trustee_ids if @trustee_ids&.any? || defined?(@trustees) @trustees = if participatory_space_trustees_with_public_key.count >= bulletin_board.number_of_trustees participatory_space_trustees_with_public_key.sample(bulletin_board.number_of_trustees) else []