Class: Decidim::Votings::Admin::PollingStationForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Votings::Admin::PollingStationForm
- Includes:
- TranslatableAttributes
- Defined in:
- app/forms/decidim/votings/admin/polling_station_form.rb
Overview
This class holds a Form to create/update votings from Decidim’s admin panel.
Instance Method Summary collapse
- #geocoded? ⇒ Boolean
- #geocoding_enabled? ⇒ Boolean
- #has_address? ⇒ Boolean
- #map_model(model) ⇒ Object
- #polling_station_managers ⇒ Object
- #polling_station_president ⇒ Object
- #voting ⇒ Object (also: #component)
Instance Method Details
#geocoded? ⇒ Boolean
23 24 25 |
# File 'app/forms/decidim/votings/admin/polling_station_form.rb', line 23 def geocoded? latitude.present? && longitude.present? end |
#geocoding_enabled? ⇒ Boolean
15 16 17 |
# File 'app/forms/decidim/votings/admin/polling_station_form.rb', line 15 def geocoding_enabled? Decidim::Map.available?(:geocoding) end |
#has_address? ⇒ Boolean
19 20 21 |
# File 'app/forms/decidim/votings/admin/polling_station_form.rb', line 19 def has_address? geocoding_enabled? && address.present? end |
#map_model(model) ⇒ Object
10 11 12 13 |
# File 'app/forms/decidim/votings/admin/polling_station_form.rb', line 10 def map_model(model) self.polling_station_president_id = model.polling_station_president&.id self.polling_station_manager_ids = model.polling_station_managers.pluck(:id) end |
#polling_station_managers ⇒ Object
31 32 33 |
# File 'app/forms/decidim/votings/admin/polling_station_form.rb', line 31 def polling_station_managers @polling_station_managers ||= PollingOfficer.where(id: polling_station_manager_ids) end |
#polling_station_president ⇒ Object
27 28 29 |
# File 'app/forms/decidim/votings/admin/polling_station_form.rb', line 27 def polling_station_president @polling_station_president ||= PollingOfficer.find_by(id: polling_station_president_id) end |
#voting ⇒ Object Also known as: component
35 36 37 |
# File 'app/forms/decidim/votings/admin/polling_station_form.rb', line 35 def voting @voting ||= context[:voting] end |