Class: Decidim::Proposals::ProposalForm
- Defined in:
- decidim-proposals/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
- #organization_scopes ⇒ Object
- #process_scope ⇒ Object
-
#scope ⇒ Object
Finds the Scope from the scope_id.
Methods inherited from Form
Instance Method Details
#category ⇒ Object
Finds the Category from the category_id.
Returns a Decidim::Category
49 50 51 |
# File 'decidim-proposals/app/forms/decidim/proposals/proposal_form.rb', line 49 def category @category ||= categories.where(id: category_id).first end |
#has_address? ⇒ Boolean
60 61 62 |
# File 'decidim-proposals/app/forms/decidim/proposals/proposal_form.rb', line 60 def has_address? current_feature.settings.geocoding_enabled? && has_address end |
#map_model(model) ⇒ Object
30 31 32 33 34 |
# File 'decidim-proposals/app/forms/decidim/proposals/proposal_form.rb', line 30 def map_model(model) return unless model.categorization self.category_id = model.categorization.decidim_category_id end |
#organization_scopes ⇒ Object
36 37 38 |
# File 'decidim-proposals/app/forms/decidim/proposals/proposal_form.rb', line 36 def organization_scopes current_organization.scopes end |
#process_scope ⇒ Object
40 41 42 |
# File 'decidim-proposals/app/forms/decidim/proposals/proposal_form.rb', line 40 def process_scope current_feature.participatory_space.scope end |
#scope ⇒ Object
Finds the Scope from the scope_id.
Returns a Decidim::Scope
56 57 58 |
# File 'decidim-proposals/app/forms/decidim/proposals/proposal_form.rb', line 56 def scope @scope ||= organization_scopes.where(id: scope_id).first || process_scope end |