Class: Decidim::Proposals::Admin::ProposalForm

Inherits:
Form
  • Object
show all
Defined in:
app/forms/decidim/proposals/admin/proposal_form.rb

Overview

A form object to be used when admin 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



41
42
43
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 41

def category
  @category ||= categories.find_by(id: category_id)
end

#map_model(model) ⇒ Object



30
31
32
33
34
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 30

def map_model(model)
  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



48
49
50
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 48

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



55
56
57
# File 'app/forms/decidim/proposals/admin/proposal_form.rb', line 55

def scope_id
  @scope_id || scope&.id
end