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
50 51 52 |
# File 'app/forms/decidim/elections/admin/election_form.rb', line 50 def election @election ||= context[:election] end |
#map_model(election) ⇒ Object
34 35 36 37 38 |
# File 'app/forms/decidim/elections/admin/election_form.rb', line 34 def map_model(election) self.manual_start = election.start_at.blank? self. = election..ids self. = election..map { |att| { id: att.id, title: att.title } } end |
#per_question_not_started? ⇒ Boolean
46 47 48 |
# File 'app/forms/decidim/elections/admin/election_form.rb', line 46 def per_question_not_started? results_availability == "per_question" && start_at.blank? end |
#results_availability_labels ⇒ Object
40 41 42 43 44 |
# File 'app/forms/decidim/elections/admin/election_form.rb', line 40 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
54 55 56 |
# File 'app/forms/decidim/elections/admin/election_form.rb', line 54 def scheduled_election? election&.scheduled? end |