Class: Decidim::Elections::Admin::ElectionForm

Inherits:
Form
  • Object
show all
Includes:
AttachmentAttributes, HasUploadValidations, TranslatableAttributes
Defined in:
app/forms/decidim/elections/admin/election_form.rb

Overview

Form to create or update an election.

Instance Method Summary collapse

Instance Method Details

#electionObject



48
49
50
# File 'app/forms/decidim/elections/admin/election_form.rb', line 48

def election
  @election ||= context[:election]
end

#map_model(election) ⇒ Object



34
35
36
# File 'app/forms/decidim/elections/admin/election_form.rb', line 34

def map_model(election)
  self.manual_start = election.start_at.blank?
end

#per_question_not_started?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'app/forms/decidim/elections/admin/election_form.rb', line 44

def per_question_not_started?
  results_availability == "per_question" && start_at.blank?
end

#results_availability_labelsObject



38
39
40
41
42
# File 'app/forms/decidim/elections/admin/election_form.rb', line 38

def results_availability_labels
  Decidim::Elections::Election::RESULTS_AVAILABILITY_OPTIONS.map do |type|
    [type, I18n.t("decidim.elections.admin.elections.form.results_availability.#{type}")]
  end
end

#scheduled_election?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'app/forms/decidim/elections/admin/election_form.rb', line 52

def scheduled_election?
  election&.scheduled?
end