Class: Decidim::Budgets::Admin::ProjectForm

Inherits:
Form
  • Object
show all
Includes:
TranslatableAttributes, TranslationsHelper
Defined in:
app/forms/decidim/budgets/admin/project_form.rb

Overview

This class holds a Form to create/update projects from Decidim’s admin panel.

Instance Method Summary collapse

Instance Method Details

#categoryObject



46
47
48
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 46

def category
  @category ||= context.current_feature.categories.where(id: decidim_category_id).first
end

#map_model(model) ⇒ Object



26
27
28
29
30
31
32
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 26

def map_model(model)
  self.proposal_ids = model.linked_resources(:proposals, "included_proposals").pluck(:id)

  return unless model.categorization

  self.decidim_category_id = model.categorization.decidim_category_id
end

#process_scopeObject



34
35
36
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 34

def process_scope
  current_feature.participatory_space.scope
end

#proposalsObject



38
39
40
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 38

def proposals
  @proposals ||= Decidim.find_resource_manifest(:proposals).try(:resource_scope, context.current_feature)&.order(title: :asc)&.pluck(:title, :id)
end

#scopeObject



42
43
44
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 42

def scope
  @scope ||= current_organization.scopes.where(id: decidim_scope_id).first || process_scope
end