Class: Decidim::Proposals::ProposalForm

Inherits:
Form
  • Object
show all
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

Instance Method Details

#categoryObject

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

Returns:

  • (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

#scopeObject

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_idObject

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