Class: Decidim::Proposals::ProposalForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Proposals::ProposalForm
- Defined in:
- app/forms/decidim/proposals/proposal_form.rb
Overview
A form object to be used when public users want to create a proposal.
Instance Method Summary collapse
-
#category ⇒ Object
Finds the Category from the category_id.
- #has_address? ⇒ Boolean
- #map_model(model) ⇒ Object
-
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
-
#scope_id ⇒ Object
Scope identifier.
Instance Method Details
#category ⇒ Object
Finds the Category from the category_id.
Returns a Decidim::Category
44 45 46 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 44 def category @category ||= categories.find_by(id: category_id) end |
#has_address? ⇒ Boolean
62 63 64 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 62 def has_address? current_component.settings.geocoding_enabled? && has_address end |
#map_model(model) ⇒ Object
33 34 35 36 37 38 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 33 def map_model(model) self.user_group_id = model.decidim_user_group_id return unless model.categorization self.category_id = model.categorization.decidim_category_id end |
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
Returns a Decidim::Scope
51 52 53 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 51 def scope @scope ||= @scope_id ? current_participatory_space.scopes.find_by(id: @scope_id) : current_participatory_space.scope end |
#scope_id ⇒ Object
Scope identifier
Returns the scope identifier related to the proposal
58 59 60 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 58 def scope_id @scope_id || scope&.id end |