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
65
66
67
68
69
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 65
def author
return current_organization unless created_in_meeting?
meeting_as_author
end
|
84
85
86
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 84
def component_automatic_hashtags
@component_automatic_hashtags ||= ordered_hashtag_list(current_component.current_settings.automatic_hashtags)
end
|
88
89
90
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 88
def component_suggested_hashtags
@component_suggested_hashtags ||= ordered_hashtag_list(current_component.current_settings.suggested_hashtags)
end
|
71
72
73
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 71
def
@extra_hashtags ||= (component_automatic_hashtags + suggested_hashtags).uniq
end
|
#geocoded? ⇒ Boolean
50
51
52
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 50
def geocoded?
latitude.present? && longitude.present?
end
|
#geocoding_enabled? ⇒ Boolean
42
43
44
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 42
def geocoding_enabled?
Decidim::Map.available?(:geocoding) && current_component.settings.geocoding_enabled?
end
|
#has_address? ⇒ Boolean
46
47
48
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 46
def has_address?
geocoding_enabled? && address.present?
end
|
#map_model(model) ⇒ Object
31
32
33
34
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 31
def map_model(model)
body = translated_attribute(model.body)
@suggested_hashtags = Decidim::ContentRenderers::HashtagRenderer.new(body)..map(&:name).map(&:downcase)
end
|
#meeting_as_author ⇒ Object
Return the meeting as author
61
62
63
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 61
def meeting_as_author
@meeting_as_author ||= meetings.find_by(id: meeting_id)
end
|
#meetings ⇒ Object
Finds the Meetings of the current participatory space
55
56
57
58
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 55
def meetings
@meetings ||= Decidim.find_resource_manifest(:meetings).try(:resource_scope, current_component)
&.published&.order(title: :asc)
end
|
#participatory_space_manifest ⇒ Object
38
39
40
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 38
def participatory_space_manifest
@participatory_space_manifest ||= current_component.participatory_space.manifest.name
end
|
#suggested_hashtag_checked?(hashtag) ⇒ Boolean
80
81
82
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 80
def suggested_hashtag_checked?(hashtag)
suggested_hashtags.member?(hashtag)
end
|
75
76
77
78
|
# File 'app/forms/decidim/proposals/admin/proposal_base_form.rb', line 75
def suggested_hashtags
downcased_suggested_hashtags = super.to_set(&:downcase)
component_suggested_hashtags.select { |hashtag| downcased_suggested_hashtags.member?(hashtag.downcase) }
end
|