Class: Decidim::Assemblies::Admin::AssemblyForm
Overview
A form object used to create assemblies from the admin dashboard.
Constant Summary
collapse
- CREATED_BY =
%w(city_council public others).freeze
Decidim::AttributeObject::TypeMap::Boolean, Decidim::AttributeObject::TypeMap::Decimal
Instance Attribute Summary
#context
Instance Method Summary
collapse
#attached_uploader, #maximum_avatar_size, #maximum_upload_size
#default_locale?
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
#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h
Instance Method Details
#area ⇒ Object
103
104
105
|
# File 'decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb', line 103
def area
@area ||= current_organization.areas.find_by(id: area_id)
end
|
#assembly_type ⇒ Object
131
132
133
|
# File 'decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb', line 131
def assembly_type
AssembliesType.find_by(id: decidim_assemblies_type_id)
end
|
#assembly_types_for_select ⇒ Object
107
108
109
110
|
# File 'decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb', line 107
def assembly_types_for_select
@assembly_types_for_select ||= organization_assembly_types
&.map { |type| [translated_attribute(type.title), type.id] }
end
|
#created_by_for_select ⇒ Object
112
113
114
115
116
117
118
119
|
# File 'decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb', line 112
def created_by_for_select
CREATED_BY.map do |creator|
[
I18n.t("created_by.#{creator}", scope: "decidim.assemblies"),
creator
]
end
end
|
#ensure_parent_cannot_be_child ⇒ Object
88
89
90
91
92
93
|
# File 'decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb', line 88
def ensure_parent_cannot_be_child
return if id.blank?
available_assemblies = Decidim::Assemblies::ParentAssembliesForSelect.for(current_organization, Assembly.find(id))
errors.add(:parent, :invalid) unless available_assemblies.include? parent
end
|
#map_model(model) ⇒ Object
95
96
97
|
# File 'decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb', line 95
def map_model(model)
self.scope_id = model.decidim_scope_id
end
|
#parent ⇒ Object
121
122
123
|
# File 'decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb', line 121
def parent
@parent ||= organization_assemblies.find_by(id: parent_id)
end
|
#processes_for_select ⇒ Object
125
126
127
128
129
|
# File 'decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb', line 125
def processes_for_select
@processes_for_select ||= organization_participatory_processes
&.map { |pp| [translated_attribute(pp.title), pp.id] }
&.sort_by { |arr| arr[0] }
end
|
#scope ⇒ Object
99
100
101
|
# File 'decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_form.rb', line 99
def scope
@scope ||= current_organization.scopes.find_by(id: scope_id)
end
|