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

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

Overview

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

Constant Summary

Constants included from AttributeObject::TypeMap

AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal

Instance Attribute Summary

Attributes inherited from AttributeObject::Form

#context

Instance Method Summary collapse

Methods included from HasUploadValidations

#attached_uploader, #maximum_avatar_size, #maximum_upload_size

Methods included from TranslatableAttributes

#default_locale?

Methods inherited from AttributeObject::Form

ensure_hash, from_model, from_params, hash_from, infer_model_name, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context

Methods included from AttributeObject::Model

#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h

Instance Method Details

#areaObject


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

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

#map_model(model) ⇒ Object


67
68
69
70
71
72
73
# File 'decidim-participatory_processes/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb', line 67

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


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

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

#participatory_process_typeObject


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

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

#participatory_process_types_for_selectObject


99
100
101
102
103
# File 'decidim-participatory_processes/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb', line 99

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


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

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

#scopeObject


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

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

#scope_type_max_depthObject


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

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