Class: Decidim::Elections::Admin::ElectionForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Elections::Admin::ElectionForm
- 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
- #election ⇒ Object
- #map_model(election) ⇒ Object
- #per_question_not_started? ⇒ Boolean
- #results_availability_labels ⇒ Object
- #scheduled_election? ⇒ Boolean
Instance Method Details
#election ⇒ Object
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
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_labels ⇒ Object
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
52 53 54 |
# File 'app/forms/decidim/elections/admin/election_form.rb', line 52 def scheduled_election? election&.scheduled? end |