Class: Decidim::ParticipatoryProcesses::Admin::ParticipatoryProcessForm

Inherits:
Form
  • Object
show all
Includes:
HasUploadValidations, TranslatableAttributes
Defined in:
app/forms/decidim/participatory_processes/admin/participatory_process_form.rb

Overview

A form object used to create participatory processes from the admin dashboard.

Instance Method Summary collapse

Instance Method Details

#areaObject



78
79
80
# File 'app/forms/decidim/participatory_processes/admin/participatory_process_form.rb', line 78

def area
  @area ||= current_organization.areas.find_by(id: area_id)
end

#map_model(model) ⇒ Object



62
63
64
65
66
67
68
# File 'app/forms/decidim/participatory_processes/admin/participatory_process_form.rb', line 62

def map_model(model)
  self.scope_id = model.decidim_scope_id
  self.participatory_process_group_id = model.decidim_participatory_process_group_id
  self.participatory_process_type_id = model.decidim_participatory_process_type_id
  self.related_process_ids = model.linked_participatory_space_resources(:participatory_process, "related_processes").pluck(:id)
  @processes = Decidim::ParticipatoryProcess.where(organization: model.organization).where.not(id: model.id)
end

#participatory_process_groupObject



82
83
84
# File 'app/forms/decidim/participatory_processes/admin/participatory_process_form.rb', line 82

def participatory_process_group
  Decidim::ParticipatoryProcessGroup.find_by(id: participatory_process_group_id)
end

#participatory_process_typeObject



86
87
88
# File 'app/forms/decidim/participatory_processes/admin/participatory_process_form.rb', line 86

def participatory_process_type
  Decidim::ParticipatoryProcessType.find_by(id: participatory_process_type_id)
end

#participatory_process_types_for_selectObject



94
95
96
97
98
# File 'app/forms/decidim/participatory_processes/admin/participatory_process_form.rb', line 94

def participatory_process_types_for_select
  @participatory_process_types_for_select ||= participatory_process_types.map do |type|
    [translated_attribute(type.title), type.id]
  end
end

#processesObject



90
91
92
# File 'app/forms/decidim/participatory_processes/admin/participatory_process_form.rb', line 90

def processes
  @processes ||= Decidim::ParticipatoryProcess.where(organization: current_organization)
end

#scopeObject



70
71
72
# File 'app/forms/decidim/participatory_processes/admin/participatory_process_form.rb', line 70

def scope
  @scope ||= current_organization.scopes.find_by(id: scope_id)
end

#scope_type_max_depthObject



74
75
76
# File 'app/forms/decidim/participatory_processes/admin/participatory_process_form.rb', line 74

def scope_type_max_depth
  @scope_type_max_depth ||= current_organization.scope_types.find_by(id: scope_type_max_depth_id)
end