decidim-proposals 0.23.0 → 0.24.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +4 -1
- data/app/assets/stylesheets/decidim/proposals/_proposals.css.scss +1 -0
- data/app/assets/stylesheets/decidim/proposals/proposals/_preview.css.scss +3 -0
- data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +3 -3
- data/app/cells/decidim/proposals/collaborative_drafts/reported_content/show.erb +3 -0
- data/app/cells/decidim/proposals/collaborative_drafts/reported_content_cell.rb +15 -0
- data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/elements.erb +5 -0
- data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/heading.erb +1 -0
- data/app/cells/decidim/proposals/content_blocks/highlighted_proposals_cell.rb +19 -0
- data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +1 -1
- data/app/cells/decidim/proposals/proposal_m_cell.rb +23 -2
- data/app/cells/decidim/proposals/reported_content/show.erb +4 -0
- data/app/cells/decidim/proposals/reported_content_cell.rb +13 -0
- data/app/commands/decidim/proposals/admin/update_proposal.rb +2 -0
- data/app/commands/decidim/proposals/hashtags_methods.rb +1 -1
- data/app/controllers/decidim/proposals/admin/proposals_controller.rb +7 -5
- data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +1 -30
- data/app/controllers/decidim/proposals/proposals_controller.rb +5 -6
- data/app/events/decidim/proposals/publish_proposal_event.rb +1 -1
- data/app/forms/decidim/proposals/access_to_collaborative_draft_form.rb +1 -3
- data/app/forms/decidim/proposals/admin/proposal_base_form.rb +3 -2
- data/app/forms/decidim/proposals/admin/proposal_form.rb +13 -0
- data/app/forms/decidim/proposals/proposal_form.rb +15 -5
- data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +1 -9
- data/app/helpers/decidim/proposals/admin/filterable_helper.rb +1 -1
- data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +1 -1
- data/app/helpers/decidim/proposals/admin/proposals_helper.rb +8 -8
- data/app/helpers/decidim/proposals/application_helper.rb +5 -2
- data/app/helpers/decidim/proposals/map_helper.rb +25 -4
- data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +14 -44
- data/app/helpers/decidim/proposals/proposals_helper.rb +3 -6
- data/app/models/decidim/proposals/collaborative_draft.rb +10 -0
- data/app/models/decidim/proposals/proposal.rb +21 -11
- data/app/permissions/decidim/proposals/admin/permissions.rb +2 -2
- data/app/permissions/decidim/proposals/permissions.rb +3 -2
- data/app/presenters/decidim/proposals/admin_log/proposal_presenter.rb +2 -2
- data/app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb +2 -2
- data/app/presenters/decidim/proposals/proposal_presenter.rb +35 -16
- data/app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb +4 -4
- data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +6 -6
- data/app/services/decidim/proposals/diff_renderer.rb +7 -11
- data/app/services/decidim/proposals/proposal_builder.rb +1 -0
- data/app/validators/proposal_length_validator.rb +4 -2
- data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +8 -1
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +8 -2
- data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +5 -1
- data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +1 -1
- data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +2 -7
- data/app/views/decidim/proposals/collaborative_drafts/_wizard_header.html.erb +14 -0
- data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +7 -7
- data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +5 -13
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +7 -11
- data/app/views/decidim/proposals/proposals/_dynamic_map_instructions.html.erb +3 -0
- data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_filters.html.erb +34 -32
- data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +21 -11
- data/app/views/decidim/proposals/proposals/edit.html.erb +7 -7
- data/app/views/decidim/proposals/proposals/preview.html.erb +50 -2
- data/app/views/decidim/proposals/proposals/show.html.erb +8 -12
- data/config/locales/ar.yml +2 -22
- data/config/locales/ca.yml +9 -30
- data/config/locales/cs.yml +47 -52
- data/config/locales/de.yml +126 -104
- data/config/locales/el.yml +2 -29
- data/config/locales/en.yml +24 -29
- data/config/locales/es-MX.yml +3 -29
- data/config/locales/es-PY.yml +3 -29
- data/config/locales/es.yml +3 -29
- data/config/locales/eu.yml +4 -22
- data/config/locales/fi-plain.yml +19 -28
- data/config/locales/fi.yml +26 -35
- data/config/locales/fr-CA.yml +20 -29
- data/config/locales/fr.yml +20 -29
- data/config/locales/gl.yml +4 -22
- data/config/locales/hu.yml +2 -22
- data/config/locales/id-ID.yml +2 -22
- data/config/locales/is-IS.yml +0 -5
- data/config/locales/it.yml +4 -29
- data/config/locales/ja.yml +2 -29
- data/config/locales/lv.yml +2 -21
- data/config/locales/nl.yml +28 -43
- data/config/locales/no.yml +4 -24
- data/config/locales/pl.yml +17 -30
- data/config/locales/pt-BR.yml +2 -21
- data/config/locales/pt.yml +2 -29
- data/config/locales/ro-RO.yml +5 -28
- data/config/locales/ru.yml +0 -5
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +5 -22
- data/config/locales/sv.yml +12 -34
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/tr-TR.yml +383 -231
- data/config/locales/uk.yml +0 -5
- data/config/locales/zh-CN.yml +2 -29
- data/db/migrate/20200708091228_move_proposals_fields_to_i18n.rb +8 -2
- data/db/migrate/20210127115628_fix_answered_proposals_after_copy.rb +14 -0
- data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_filter.rb +0 -0
- data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_sort.rb +3 -5
- data/lib/decidim/api/proposal_type.rb +56 -0
- data/lib/decidim/api/proposals_type.rb +43 -0
- data/lib/decidim/content_renderers/proposal_renderer.rb +1 -1
- data/lib/decidim/proposals.rb +2 -0
- data/lib/decidim/proposals/api.rb +10 -0
- data/lib/decidim/proposals/component.rb +30 -19
- data/lib/decidim/proposals/engine.rb +6 -27
- data/lib/decidim/proposals/proposal_creator.rb +98 -0
- data/lib/decidim/proposals/test/factories.rb +22 -8
- data/lib/decidim/proposals/version.rb +1 -1
- metadata +55 -40
- data/app/commands/decidim/proposals/create_proposal_export.rb +0 -37
- data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +0 -0
- data/app/queries/decidim/proposals/similar_collaborative_drafts.rb +0 -52
- data/app/types/decidim/proposals/proposal_type.rb +0 -70
- data/app/types/decidim/proposals/proposals_type.rb +0 -41
- data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +0 -13
- data/app/views/decidim/proposals/collaborative_drafts/compare.html.erb +0 -21
- data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +0 -24
- data/app/views/decidim/proposals/proposals/_proposal_preview.html.erb +0 -1
@@ -5,6 +5,7 @@ module Decidim
|
|
5
5
|
# A form object to be used when public users want to create a proposal.
|
6
6
|
class ProposalForm < Decidim::Proposals::ProposalWizardCreateStepForm
|
7
7
|
include Decidim::TranslatableAttributes
|
8
|
+
include Decidim::AttachmentAttributes
|
8
9
|
|
9
10
|
mimic :proposal
|
10
11
|
|
@@ -16,10 +17,9 @@ module Decidim
|
|
16
17
|
attribute :has_address, Boolean
|
17
18
|
attribute :attachment, AttachmentForm
|
18
19
|
attribute :suggested_hashtags, Array[String]
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
attribute :add_documents, Array
|
20
|
+
|
21
|
+
attachments_attribute :photos
|
22
|
+
attachments_attribute :documents
|
23
23
|
|
24
24
|
validates :address, geocoding: true, if: ->(form) { form.has_address? && !form.geocoded? }
|
25
25
|
validates :address, presence: true, if: ->(form) { form.has_address? }
|
@@ -39,6 +39,8 @@ module Decidim
|
|
39
39
|
# The scope attribute is with different key (decidim_scope_id), so it
|
40
40
|
# has to be manually mapped.
|
41
41
|
self.scope_id = model.scope.id if model.scope
|
42
|
+
|
43
|
+
self.has_address = true if model.address.present?
|
42
44
|
end
|
43
45
|
|
44
46
|
# Finds the Category from the category_id.
|
@@ -66,8 +68,16 @@ module Decidim
|
|
66
68
|
Decidim::Map.available?(:geocoding) && current_component.settings.geocoding_enabled?
|
67
69
|
end
|
68
70
|
|
71
|
+
def address
|
72
|
+
return unless has_address
|
73
|
+
|
74
|
+
super
|
75
|
+
end
|
76
|
+
|
69
77
|
def has_address?
|
70
|
-
|
78
|
+
return unless has_address
|
79
|
+
|
80
|
+
geocoding_enabled? && address.present?
|
71
81
|
end
|
72
82
|
|
73
83
|
def geocoded?
|
@@ -7,7 +7,7 @@ module Decidim
|
|
7
7
|
mimic :proposal
|
8
8
|
|
9
9
|
attribute :title, String
|
10
|
-
attribute :body,
|
10
|
+
attribute :body, Decidim::Attributes::CleanString
|
11
11
|
attribute :body_template, String
|
12
12
|
attribute :user_group_id, Integer
|
13
13
|
|
@@ -18,7 +18,6 @@ module Decidim
|
|
18
18
|
maximum: ->(record) { record.component.settings.proposal_length }
|
19
19
|
}
|
20
20
|
|
21
|
-
validate :proposal_length
|
22
21
|
validate :body_is_not_bare_template
|
23
22
|
|
24
23
|
alias component current_component
|
@@ -32,13 +31,6 @@ module Decidim
|
|
32
31
|
|
33
32
|
private
|
34
33
|
|
35
|
-
def proposal_length
|
36
|
-
return unless body.presence
|
37
|
-
|
38
|
-
length = current_component.settings.proposal_length
|
39
|
-
errors.add(:body, :too_long, count: length) if body.length > length
|
40
|
-
end
|
41
|
-
|
42
34
|
def body_is_not_bare_template
|
43
35
|
return if body_template.blank?
|
44
36
|
|
@@ -7,7 +7,7 @@ module Decidim
|
|
7
7
|
def extra_dropdown_submenu_options_items(filter, i18n_scope)
|
8
8
|
options = case filter
|
9
9
|
when :state_eq
|
10
|
-
|
10
|
+
tag.li(filter_link_value(:state_null, true, i18n_scope))
|
11
11
|
end
|
12
12
|
[options].compact
|
13
13
|
end
|
@@ -20,7 +20,7 @@ module Decidim
|
|
20
20
|
# ranking_for(proposal, endorsements_count: :desc)
|
21
21
|
def ranking_for(proposal, order = {})
|
22
22
|
siblings = Decidim::Proposals::Proposal.where(component: proposal.component)
|
23
|
-
ranked = siblings.order([order, id: :asc])
|
23
|
+
ranked = siblings.order([order, { id: :asc }])
|
24
24
|
ranked_ids = ranked.pluck(:id)
|
25
25
|
|
26
26
|
{ ranking: ranked_ids.index(proposal.id) + 1, total: ranked_ids.count }
|
@@ -32,9 +32,9 @@ module Decidim
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def proposal_complete_state(proposal)
|
35
|
-
|
36
|
-
|
37
|
-
state.html_safe
|
35
|
+
return humanize_proposal_state(proposal.internal_state).html_safe if proposal.answered? && !proposal.published_state?
|
36
|
+
|
37
|
+
humanize_proposal_state(proposal.state).html_safe
|
38
38
|
end
|
39
39
|
|
40
40
|
def proposals_admin_filter_tree
|
@@ -73,7 +73,7 @@ module Decidim
|
|
73
73
|
def proposals_admin_filter_applied_filters
|
74
74
|
html = []
|
75
75
|
if params[:q][:is_emendation_true].present?
|
76
|
-
html <<
|
76
|
+
html << tag.span(class: "label secondary") do
|
77
77
|
tag = "#{t("filters.type", scope: "decidim.proposals.proposals")}: "
|
78
78
|
tag += if params[:q][:is_emendation_true].to_s == "1"
|
79
79
|
t("amendments", scope: "decidim.proposals.application_helper.filter_type_values")
|
@@ -86,7 +86,7 @@ module Decidim
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
if params[:q][:state_null]
|
89
|
-
html <<
|
89
|
+
html << tag.span(class: "label secondary") do
|
90
90
|
tag = "#{t("models.proposal.fields.state", scope: "decidim.proposals")}: "
|
91
91
|
tag += humanize_proposal_state "not_answered"
|
92
92
|
tag += icon_link_to("circle-x", url_for(q: ransak_params_for_query_without(:state_null), per_page: per_page), t("decidim.admin.actions.cancel"),
|
@@ -95,7 +95,7 @@ module Decidim
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
if params[:q][:state_eq]
|
98
|
-
html <<
|
98
|
+
html << tag.span(class: "label secondary") do
|
99
99
|
tag = "#{t("models.proposal.fields.state", scope: "decidim.proposals")}: "
|
100
100
|
tag += humanize_proposal_state params[:q][:state_eq]
|
101
101
|
tag += icon_link_to("circle-x", url_for(q: ransak_params_for_query_without(:state_eq), per_page: per_page), t("decidim.admin.actions.cancel"),
|
@@ -104,7 +104,7 @@ module Decidim
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
if params[:q][:category_id_eq]
|
107
|
-
html <<
|
107
|
+
html << tag.span(class: "label secondary") do
|
108
108
|
tag = "#{t("models.proposal.fields.category", scope: "decidim.proposals")}: "
|
109
109
|
tag += translated_attribute categories.find(params[:q][:category_id_eq]).name
|
110
110
|
tag += icon_link_to("circle-x", url_for(q: ransak_params_for_query_without(:category_id_eq), per_page: per_page), t("decidim.admin.actions.cancel"),
|
@@ -113,7 +113,7 @@ module Decidim
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
if params[:q][:scope_id_eq]
|
116
|
-
html <<
|
116
|
+
html << tag.span(class: "label secondary") do
|
117
117
|
tag = "#{t("models.proposal.fields.scope", scope: "decidim.proposals")}: "
|
118
118
|
tag += translated_attribute Decidim::Scope.where(decidim_organization_id: current_component.organization.id).find(params[:q][:scope_id_eq]).name
|
119
119
|
tag += icon_link_to("circle-x", url_for(q: ransak_params_for_query_without(:scope_id_eq), per_page: per_page), t("decidim.admin.actions.cancel"),
|
@@ -30,10 +30,13 @@ module Decidim
|
|
30
30
|
|
31
31
|
# Public: The css class applied based on the proposal state.
|
32
32
|
#
|
33
|
-
#
|
33
|
+
# proposal - The proposal to evaluate.
|
34
34
|
#
|
35
35
|
# Returns a String.
|
36
|
-
def proposal_state_css_class(
|
36
|
+
def proposal_state_css_class(proposal)
|
37
|
+
state = proposal.state
|
38
|
+
state = proposal.internal_state if proposal.answered? && !proposal.published_state?
|
39
|
+
|
37
40
|
case state
|
38
41
|
when "accepted"
|
39
42
|
"text-success"
|
@@ -10,12 +10,33 @@ module Decidim
|
|
10
10
|
# geocoded_proposals - A collection of geocoded proposals
|
11
11
|
def proposals_data_for_map(geocoded_proposals)
|
12
12
|
geocoded_proposals.map do |proposal|
|
13
|
-
|
14
|
-
body: truncate(present(proposal).body, length: 100),
|
15
|
-
icon: icon("proposals", width: 40, height: 70, remove_icon_class: true),
|
16
|
-
link: proposal_path(proposal))
|
13
|
+
proposal_data_for_map(proposal)
|
17
14
|
end
|
18
15
|
end
|
16
|
+
|
17
|
+
def proposal_data_for_map(proposal)
|
18
|
+
proposal.slice(:latitude, :longitude, :address).merge(title: proposal.title,
|
19
|
+
body: truncate(translated_attribute(proposal.body), length: 100),
|
20
|
+
icon: icon("proposals", width: 40, height: 70, remove_icon_class: true),
|
21
|
+
link: proposal_path(proposal))
|
22
|
+
end
|
23
|
+
|
24
|
+
def proposal_preview_data_for_map(proposal)
|
25
|
+
[
|
26
|
+
proposal.slice(
|
27
|
+
:latitude,
|
28
|
+
:longitude,
|
29
|
+
:address
|
30
|
+
).merge(
|
31
|
+
icon: icon("proposals", width: 40, height: 70, remove_icon_class: true),
|
32
|
+
draggable: true
|
33
|
+
)
|
34
|
+
]
|
35
|
+
end
|
36
|
+
|
37
|
+
def has_position?(proposal)
|
38
|
+
proposal.latitude.present? && proposal.longitude.present?
|
39
|
+
end
|
19
40
|
end
|
20
41
|
end
|
21
42
|
end
|
@@ -32,7 +32,7 @@ module Decidim
|
|
32
32
|
#
|
33
33
|
# step - A symbol of the target step
|
34
34
|
def proposal_wizard_step_name(step)
|
35
|
-
t("decidim.proposals
|
35
|
+
t("decidim.proposals.proposals.wizard_steps.#{step}")
|
36
36
|
end
|
37
37
|
|
38
38
|
# Returns the page title of the given step, translated
|
@@ -48,7 +48,7 @@ module Decidim
|
|
48
48
|
action_name
|
49
49
|
end
|
50
50
|
|
51
|
-
t("decidim.proposals.#{
|
51
|
+
t("decidim.proposals.proposals.#{step_title}.title")
|
52
52
|
end
|
53
53
|
|
54
54
|
# Returns the list item of the given step, in html
|
@@ -56,8 +56,6 @@ module Decidim
|
|
56
56
|
# step - A symbol of the target step
|
57
57
|
# current_step - A symbol of the current step
|
58
58
|
def proposal_wizard_stepper_step(step, current_step)
|
59
|
-
return if step == :step_4 && type_of == :collaborative_drafts
|
60
|
-
|
61
59
|
attributes = { class: proposal_wizard_step_classes(step, current_step).to_s }
|
62
60
|
step_title = proposal_wizard_step_name(step)
|
63
61
|
if step.to_s.split("_").last.to_i == proposal_wizard_step_number(current_step)
|
@@ -99,7 +97,7 @@ module Decidim
|
|
99
97
|
end
|
100
98
|
|
101
99
|
def proposal_wizard_steps_title
|
102
|
-
t("title", scope: "decidim.proposals
|
100
|
+
t("title", scope: "decidim.proposals.proposals.wizard_steps")
|
103
101
|
end
|
104
102
|
|
105
103
|
# Returns a boolean if the step has a help text defined
|
@@ -128,58 +126,30 @@ module Decidim
|
|
128
126
|
private
|
129
127
|
|
130
128
|
def total_steps
|
131
|
-
|
132
|
-
when :collaborative_drafts
|
133
|
-
3
|
134
|
-
when :proposals
|
135
|
-
4
|
136
|
-
else
|
137
|
-
4
|
138
|
-
end
|
129
|
+
4
|
139
130
|
end
|
140
131
|
|
141
132
|
def wizard_aside_info_text
|
142
|
-
|
143
|
-
when :collaborative_drafts
|
144
|
-
t("info", scope: "decidim.proposals.collaborative_drafts.wizard_aside").html_safe
|
145
|
-
else
|
146
|
-
t("info", scope: "decidim.proposals.proposals.wizard_aside").html_safe
|
147
|
-
end
|
133
|
+
t("info", scope: "decidim.proposals.proposals.wizard_aside").html_safe
|
148
134
|
end
|
149
135
|
|
150
136
|
# Renders the back link except for step_2: compare
|
151
137
|
def proposal_wizard_aside_link_to_back(step)
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
url
|
138
|
+
case step
|
139
|
+
when :step_1
|
140
|
+
proposals_path
|
141
|
+
when :step_3
|
142
|
+
compare_proposal_path
|
143
|
+
when :step_4
|
144
|
+
edit_draft_proposal_path
|
145
|
+
end
|
161
146
|
end
|
162
147
|
|
163
148
|
def wizard_aside_back_text(from = nil)
|
164
149
|
key = "back"
|
165
150
|
key = "back_from_#{from}" if from
|
166
151
|
|
167
|
-
|
168
|
-
when :collaborative_drafts
|
169
|
-
t(key, scope: "decidim.proposals.collaborative_drafts.wizard_aside").html_safe
|
170
|
-
else
|
171
|
-
t(key, scope: "decidim.proposals.proposals.wizard_aside").html_safe
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
def type_of
|
176
|
-
if ["Decidim::Proposals::CollaborativeDraftForm"].include? @form.class.name
|
177
|
-
:collaborative_drafts
|
178
|
-
elsif @collaborative_draft.present?
|
179
|
-
:collaborative_drafts
|
180
|
-
else
|
181
|
-
:proposals
|
182
|
-
end
|
152
|
+
t(key, scope: "decidim.proposals.proposals.wizard_aside").html_safe
|
183
153
|
end
|
184
154
|
end
|
185
155
|
end
|
@@ -4,13 +4,10 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
# Simple helpers to handle markup variations for proposals
|
6
6
|
module ProposalsHelper
|
7
|
-
def
|
7
|
+
def proposal_reason_callout_announcement
|
8
8
|
{
|
9
|
-
|
10
|
-
|
11
|
-
body: decidim_sanitize(translated_attribute(@proposal.answer))
|
12
|
-
},
|
13
|
-
callout_class: proposal_reason_callout_class
|
9
|
+
title: proposal_reason_callout_title,
|
10
|
+
body: decidim_sanitize(translated_attribute(@proposal.answer))
|
14
11
|
}
|
15
12
|
end
|
16
13
|
|
@@ -58,6 +58,16 @@ module Decidim
|
|
58
58
|
def reported_content_url
|
59
59
|
ResourceLocatorPresenter.new(self).url
|
60
60
|
end
|
61
|
+
|
62
|
+
# Public: Overrides the `reported_attributes` Reportable concern method.
|
63
|
+
def reported_attributes
|
64
|
+
[:body]
|
65
|
+
end
|
66
|
+
|
67
|
+
# Public: Overrides the `reported_searchable_content_extras` Reportable concern method.
|
68
|
+
def reported_searchable_content_extras
|
69
|
+
[authors.map(&:name).join("\n")]
|
70
|
+
end
|
61
71
|
end
|
62
72
|
end
|
63
73
|
end
|
@@ -69,12 +69,13 @@ module Decidim
|
|
69
69
|
scope :drafts, -> { where(published_at: nil) }
|
70
70
|
scope :except_drafts, -> { where.not(published_at: nil) }
|
71
71
|
scope :published, -> { where.not(published_at: nil) }
|
72
|
+
scope :order_by_most_recent, -> { order(created_at: :desc) }
|
72
73
|
scope :sort_by_valuation_assignments_count_asc, lambda {
|
73
|
-
order(sort_by_valuation_assignments_count_nulls_last_query
|
74
|
+
order("#{sort_by_valuation_assignments_count_nulls_last_query}ASC NULLS FIRST")
|
74
75
|
}
|
75
76
|
|
76
77
|
scope :sort_by_valuation_assignments_count_desc, lambda {
|
77
|
-
order(sort_by_valuation_assignments_count_nulls_last_query
|
78
|
+
order("#{sort_by_valuation_assignments_count_nulls_last_query}DESC NULLS LAST")
|
78
79
|
}
|
79
80
|
|
80
81
|
def self.with_valuation_assigned_to(user, space)
|
@@ -106,7 +107,7 @@ module Decidim
|
|
106
107
|
return unless author.is_a?(Decidim::User)
|
107
108
|
|
108
109
|
joins(:coauthorships)
|
109
|
-
.where(
|
110
|
+
.where(decidim_coauthorships: { coauthorable_type: name })
|
110
111
|
.where("decidim_coauthorships.decidim_author_id = ? AND decidim_coauthorships.decidim_author_type = ? ", author.id, author.class.base_class.name)
|
111
112
|
end
|
112
113
|
|
@@ -130,7 +131,9 @@ module Decidim
|
|
130
131
|
.where(decidim_author_type: "Decidim::UserBaseEntity")
|
131
132
|
.pluck(:decidim_author_id).to_a.compact.uniq
|
132
133
|
|
133
|
-
|
134
|
+
commentators_ids = Decidim::Comments::Comment.user_commentators_ids_in(proposals)
|
135
|
+
|
136
|
+
(endorsements_participants_ids + participants_has_voted_ids + coauthors_recipients_ids + commentators_ids).flatten.compact.uniq
|
134
137
|
end
|
135
138
|
|
136
139
|
# Public: Updates the vote count of this proposal.
|
@@ -225,6 +228,16 @@ module Decidim
|
|
225
228
|
ResourceLocatorPresenter.new(self).url
|
226
229
|
end
|
227
230
|
|
231
|
+
# Public: Overrides the `reported_attributes` Reportable concern method.
|
232
|
+
def reported_attributes
|
233
|
+
[:title, :body]
|
234
|
+
end
|
235
|
+
|
236
|
+
# Public: Overrides the `reported_searchable_content_extras` Reportable concern method.
|
237
|
+
def reported_searchable_content_extras
|
238
|
+
[authors.map(&:name).join("\n")]
|
239
|
+
end
|
240
|
+
|
228
241
|
# Public: Whether the proposal is official or not.
|
229
242
|
def official?
|
230
243
|
authors.first.is_a?(Decidim::Organization)
|
@@ -284,7 +297,7 @@ module Decidim
|
|
284
297
|
|
285
298
|
# Defines the base query so that ransack can actually sort by this value
|
286
299
|
def self.sort_by_valuation_assignments_count_nulls_last_query
|
287
|
-
<<-SQL
|
300
|
+
<<-SQL.squish
|
288
301
|
(
|
289
302
|
SELECT COUNT(decidim_proposals_valuation_assignments.id)
|
290
303
|
FROM decidim_proposals_valuation_assignments
|
@@ -296,7 +309,7 @@ module Decidim
|
|
296
309
|
|
297
310
|
# method to filter by assigned valuator role ID
|
298
311
|
def self.valuator_role_ids_has(value)
|
299
|
-
query = <<-SQL
|
312
|
+
query = <<-SQL.squish
|
300
313
|
:value = any(
|
301
314
|
(SELECT decidim_proposals_valuation_assignments.valuator_role_id
|
302
315
|
FROM decidim_proposals_valuation_assignments
|
@@ -324,10 +337,6 @@ module Decidim
|
|
324
337
|
")
|
325
338
|
end
|
326
339
|
|
327
|
-
ransacker :state do
|
328
|
-
Arel.sql("CASE WHEN state = 'withdrawn' THEN 'withdrawn' WHEN state_published_at IS NULL THEN NULL ELSE state END")
|
329
|
-
end
|
330
|
-
|
331
340
|
ransacker :title do
|
332
341
|
Arel.sql(%{("decidim_proposals_proposals"."title")::text})
|
333
342
|
end
|
@@ -337,7 +346,7 @@ module Decidim
|
|
337
346
|
end
|
338
347
|
|
339
348
|
ransacker :is_emendation do |_parent|
|
340
|
-
query = <<-SQL
|
349
|
+
query = <<-SQL.squish
|
341
350
|
(
|
342
351
|
SELECT EXISTS (
|
343
352
|
SELECT 1 FROM decidim_amendments
|
@@ -365,6 +374,7 @@ module Decidim
|
|
365
374
|
# Checks whether the proposal is inside the time window to be editable or not once published.
|
366
375
|
def within_edit_time_limit?
|
367
376
|
return true if draft?
|
377
|
+
return true if component.settings.proposal_edit_time == "infinite"
|
368
378
|
|
369
379
|
limit = updated_at + component.settings.proposal_edit_before_minutes.minutes
|
370
380
|
Time.current < limit
|