Class: Decidim::Proposals::Admin::ProposalBaseForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Proposals::Admin::ProposalBaseForm
show all
- Includes:
- ApplicationHelper, AttachmentAttributes, HasTaxonomyFormAttributes, TranslatableAttributes
- Defined in:
- app/forms/decidim/proposals/admin/proposal_base_form.rb
Overview
A form object to be used when admin users want to create a proposal.
Instance Method Summary
collapse
Instance Method Details
#author ⇒ Object
64
65
66
67
68
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 64
def author
return current_organization unless created_in_meeting?
meeting_as_author
end
|
#geocoded? ⇒ Boolean
49
50
51
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 49
def geocoded?
latitude.present? && longitude.present?
end
|
#geocoding_enabled? ⇒ Boolean
41
42
43
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 41
def geocoding_enabled?
Decidim::Map.available?(:geocoding) && current_component.settings.geocoding_enabled?
end
|
#has_address? ⇒ Boolean
45
46
47
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 45
def has_address?
geocoding_enabled? && address.present?
end
|
#map_model(model) ⇒ Object
30
31
32
33
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 30
def map_model(model)
body = translated_attribute(model.body)
Decidim::ContentRenderers::BlobRenderer.new(body)
end
|
#meeting_as_author ⇒ Object
Return the meeting as author
60
61
62
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 60
def meeting_as_author
@meeting_as_author ||= meetings.find_by(id: meeting_id)
end
|
#meetings ⇒ Object
Finds the Meetings of the current participatory space
54
55
56
57
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 54
def meetings
@meetings ||= Decidim.find_resource_manifest(:meetings).try(:resource_scope, current_component)
&.published&.order(title: :asc)
end
|
#participatory_space_manifest ⇒ Object
37
38
39
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 37
def participatory_space_manifest
@participatory_space_manifest ||= current_component.participatory_space.manifest.name
end
|