Class: Decidim::Votings::Admin::PollingStationForm
Overview
This class holds a Form to create/update votings from Decidim’s admin panel.
Constant Summary
AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal
Instance Attribute Summary
#context
Instance Method Summary
collapse
#default_locale?
ensure_hash, from_model, from_params, hash_from, infer_model_name, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context
#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h
Instance Method Details
23
24
25
|
# File 'decidim-elections/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 'decidim-elections/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 'decidim-elections/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 'decidim-elections/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 'decidim-elections/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 'decidim-elections/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 'decidim-elections/app/forms/decidim/votings/admin/polling_station_form.rb', line 35
def voting
@voting ||= context[:voting]
end
|