decidim-proposals 0.23.5 → 0.24.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +4 -1
  3. data/app/assets/javascripts/decidim/proposals/admin/proposals_form.js.es6 +4 -1
  4. data/app/assets/stylesheets/decidim/proposals/_proposals.css.scss +1 -0
  5. data/app/assets/stylesheets/decidim/proposals/proposals/_preview.css.scss +3 -0
  6. data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +3 -3
  7. data/app/cells/decidim/proposals/collaborative_drafts/reported_content/show.erb +3 -0
  8. data/app/cells/decidim/proposals/collaborative_drafts/reported_content_cell.rb +15 -0
  9. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/elements.erb +5 -0
  10. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/heading.erb +1 -0
  11. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals_cell.rb +19 -0
  12. data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +1 -1
  13. data/app/cells/decidim/proposals/proposal_m_cell.rb +23 -2
  14. data/app/cells/decidim/proposals/proposals_picker_cell.rb +1 -1
  15. data/app/cells/decidim/proposals/reported_content/show.erb +4 -0
  16. data/app/cells/decidim/proposals/reported_content_cell.rb +13 -0
  17. data/app/commands/decidim/proposals/hashtags_methods.rb +1 -1
  18. data/app/commands/decidim/proposals/update_proposal.rb +0 -2
  19. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +6 -4
  20. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +1 -30
  21. data/app/controllers/decidim/proposals/proposals_controller.rb +5 -6
  22. data/app/events/decidim/proposals/publish_proposal_event.rb +1 -1
  23. data/app/forms/decidim/proposals/access_to_collaborative_draft_form.rb +1 -3
  24. data/app/forms/decidim/proposals/admin/proposal_base_form.rb +3 -2
  25. data/app/forms/decidim/proposals/proposal_form.rb +15 -5
  26. data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +1 -1
  27. data/app/helpers/decidim/proposals/admin/filterable_helper.rb +1 -1
  28. data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +1 -1
  29. data/app/helpers/decidim/proposals/admin/proposals_helper.rb +8 -8
  30. data/app/helpers/decidim/proposals/application_helper.rb +5 -2
  31. data/app/helpers/decidim/proposals/map_helper.rb +31 -8
  32. data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +14 -44
  33. data/app/helpers/decidim/proposals/proposals_helper.rb +3 -6
  34. data/app/models/decidim/proposals/collaborative_draft.rb +10 -0
  35. data/app/models/decidim/proposals/proposal.rb +18 -10
  36. data/app/permissions/decidim/proposals/admin/permissions.rb +2 -2
  37. data/app/permissions/decidim/proposals/permissions.rb +3 -2
  38. data/app/presenters/decidim/proposals/proposal_presenter.rb +4 -4
  39. data/app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb +4 -4
  40. data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +6 -6
  41. data/app/services/decidim/proposals/collaborative_draft_search.rb +1 -1
  42. data/app/services/decidim/proposals/diff_renderer.rb +7 -11
  43. data/app/services/decidim/proposals/proposal_builder.rb +1 -0
  44. data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +8 -1
  45. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +5 -1
  46. data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +1 -1
  47. data/app/views/decidim/proposals/collaborative_drafts/_filters_small_view.html.erb +1 -1
  48. data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +2 -7
  49. data/app/views/decidim/proposals/collaborative_drafts/_wizard_header.html.erb +14 -0
  50. data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +1 -3
  51. data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +5 -13
  52. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -7
  53. data/app/views/decidim/proposals/proposals/_dynamic_map_instructions.html.erb +3 -0
  54. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +6 -6
  55. data/app/views/decidim/proposals/proposals/_filters.html.erb +34 -32
  56. data/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +1 -1
  57. data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +21 -11
  58. data/app/views/decidim/proposals/proposals/edit.html.erb +1 -3
  59. data/app/views/decidim/proposals/proposals/preview.html.erb +50 -2
  60. data/app/views/decidim/proposals/proposals/show.html.erb +2 -8
  61. data/config/locales/ar.yml +2 -23
  62. data/config/locales/bg.yml +0 -4
  63. data/config/locales/ca.yml +23 -29
  64. data/config/locales/cs.yml +24 -30
  65. data/config/locales/de.yml +23 -29
  66. data/config/locales/el.yml +2 -29
  67. data/config/locales/en.yml +23 -29
  68. data/config/locales/es-MX.yml +23 -29
  69. data/config/locales/es-PY.yml +23 -29
  70. data/config/locales/es.yml +23 -29
  71. data/config/locales/eu.yml +2 -23
  72. data/config/locales/fi-plain.yml +22 -28
  73. data/config/locales/fi.yml +22 -28
  74. data/config/locales/fr-CA.yml +19 -29
  75. data/config/locales/fr.yml +19 -29
  76. data/config/locales/gl.yml +17 -25
  77. data/config/locales/hu.yml +2 -23
  78. data/config/locales/id-ID.yml +2 -23
  79. data/config/locales/is-IS.yml +0 -8
  80. data/config/locales/it.yml +4 -29
  81. data/config/locales/ja.yml +2 -29
  82. data/config/locales/lv.yml +2 -22
  83. data/config/locales/nl.yml +17 -29
  84. data/config/locales/no.yml +2 -23
  85. data/config/locales/pl.yml +22 -28
  86. data/config/locales/pt-BR.yml +2 -22
  87. data/config/locales/pt.yml +2 -29
  88. data/config/locales/ro-RO.yml +13 -29
  89. data/config/locales/ru.yml +0 -8
  90. data/config/locales/sk.yml +5 -23
  91. data/config/locales/sv.yml +23 -28
  92. data/config/locales/tr-TR.yml +17 -29
  93. data/config/locales/uk.yml +0 -8
  94. data/config/locales/zh-CN.yml +2 -29
  95. data/db/migrate/20210310102839_add_followable_counter_cache_to_proposals.rb +16 -0
  96. data/db/migrate/20210310120812_add_followable_counter_cache_to_collaborative_drafts.rb +16 -0
  97. data/db/migrate/20210318082934_fix_counters_for_copied_proposals.rb +9 -7
  98. data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_filter.rb +0 -0
  99. data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_sort.rb +3 -5
  100. data/lib/decidim/api/proposal_type.rb +56 -0
  101. data/lib/decidim/api/proposals_type.rb +43 -0
  102. data/lib/decidim/content_renderers/proposal_renderer.rb +1 -1
  103. data/lib/decidim/proposals.rb +2 -0
  104. data/lib/decidim/proposals/api.rb +10 -0
  105. data/lib/decidim/proposals/component.rb +30 -19
  106. data/lib/decidim/proposals/engine.rb +6 -27
  107. data/lib/decidim/proposals/proposal_creator.rb +98 -0
  108. data/lib/decidim/proposals/test/factories.rb +22 -8
  109. data/lib/decidim/proposals/version.rb +1 -1
  110. metadata +49 -35
  111. data/app/commands/decidim/proposals/create_proposal_export.rb +0 -37
  112. data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +0 -0
  113. data/app/queries/decidim/proposals/similar_collaborative_drafts.rb +0 -52
  114. data/app/types/decidim/proposals/proposal_type.rb +0 -70
  115. data/app/types/decidim/proposals/proposals_type.rb +0 -41
  116. data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +0 -13
  117. data/app/views/decidim/proposals/collaborative_drafts/compare.html.erb +0 -21
  118. data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +0 -24
  119. data/app/views/decidim/proposals/proposals/_proposal_preview.html.erb +0 -1
@@ -7,7 +7,7 @@ module Decidim
7
7
  mimic :proposal
8
8
 
9
9
  attribute :title, String
10
- attribute :body, String
10
+ attribute :body, Decidim::Attributes::CleanString
11
11
  attribute :body_template, String
12
12
  attribute :user_group_id, Integer
13
13
 
@@ -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
- content_tag(:li, filter_link_value(:state_null, true, i18n_scope))
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
- state = humanize_proposal_state(proposal.state)
36
- state += " (#{humanize_proposal_state(proposal.internal_state)})" if proposal.answered? && !proposal.published_state?
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 << content_tag(:span, class: "label secondary") do
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 << content_tag(:span, class: "label secondary") do
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 << content_tag(:span, class: "label secondary") do
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 << content_tag(:span, class: "label secondary") do
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 << content_tag(:span, class: "label secondary") do
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
- # state - The String state of the proposal.
33
+ # proposal - The proposal to evaluate.
34
34
  #
35
35
  # Returns a String.
36
- def proposal_state_css_class(state)
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,16 +10,39 @@ 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
- proposal
14
- .slice(:latitude, :longitude, :address)
15
- .merge(
16
- title: decidim_html_escape(present(proposal).title),
17
- body: html_truncate(decidim_sanitize(present(proposal).body), length: 100),
18
- icon: icon("proposals", width: 40, height: 70, remove_icon_class: true),
19
- link: proposal_path(proposal)
20
- )
13
+ proposal_data_for_map(proposal)
21
14
  end
22
15
  end
16
+
17
+ def proposal_data_for_map(proposal)
18
+ proposal
19
+ .slice(:latitude, :longitude, :address)
20
+ .merge(
21
+ title: decidim_html_escape(present(proposal).title),
22
+ body: html_truncate(decidim_sanitize(present(proposal).body), length: 100),
23
+ icon: icon("proposals", width: 40, height: 70, remove_icon_class: true),
24
+ link: proposal_path(proposal)
25
+ )
26
+ end
27
+
28
+ def proposal_preview_data_for_map(proposal)
29
+ [
30
+ proposal.slice(
31
+ :latitude,
32
+ :longitude,
33
+ :address
34
+ ).merge(
35
+ icon: icon("proposals", width: 40, height: 70, remove_icon_class: true),
36
+ draggable: true
37
+ )
38
+ ]
39
+ end
40
+
41
+ def has_position?(proposal)
42
+ return if proposal.address.blank?
43
+
44
+ proposal.latitude.present? && proposal.longitude.present?
45
+ end
23
46
  end
24
47
  end
25
48
  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.#{type_of}.wizard_steps.#{step}")
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.#{type_of}.#{step_title}.title")
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.#{type_of}.wizard_steps")
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
- case type_of
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
- case type_of
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
- url = case step
153
- when :step_1
154
- proposals_path
155
- when :step_3
156
- compare_proposal_path
157
- when :step_4
158
- edit_draft_proposal_path
159
- end
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
- case type_of
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 proposal_reason_callout_args
7
+ def proposal_reason_callout_announcement
8
8
  {
9
- announcement: {
10
- title: proposal_reason_callout_title,
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 + "ASC NULLS FIRST")
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 + "DESC NULLS LAST")
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("decidim_coauthorships.coauthorable_type = ?", name)
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
 
@@ -227,6 +228,16 @@ module Decidim
227
228
  ResourceLocatorPresenter.new(self).url
228
229
  end
229
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
+
230
241
  # Public: Whether the proposal is official or not.
231
242
  def official?
232
243
  authors.first.is_a?(Decidim::Organization)
@@ -286,7 +297,7 @@ module Decidim
286
297
 
287
298
  # Defines the base query so that ransack can actually sort by this value
288
299
  def self.sort_by_valuation_assignments_count_nulls_last_query
289
- <<-SQL
300
+ <<-SQL.squish
290
301
  (
291
302
  SELECT COUNT(decidim_proposals_valuation_assignments.id)
292
303
  FROM decidim_proposals_valuation_assignments
@@ -298,7 +309,7 @@ module Decidim
298
309
 
299
310
  # method to filter by assigned valuator role ID
300
311
  def self.valuator_role_ids_has(value)
301
- query = <<-SQL
312
+ query = <<-SQL.squish
302
313
  :value = any(
303
314
  (SELECT decidim_proposals_valuation_assignments.valuator_role_id
304
315
  FROM decidim_proposals_valuation_assignments
@@ -326,10 +337,6 @@ module Decidim
326
337
  ")
327
338
  end
328
339
 
329
- ransacker :state do
330
- Arel.sql("CASE WHEN state = 'withdrawn' THEN 'withdrawn' WHEN state_published_at IS NULL THEN NULL ELSE state END")
331
- end
332
-
333
340
  ransacker :title do
334
341
  Arel.sql(%{("decidim_proposals_proposals"."title")::text})
335
342
  end
@@ -339,7 +346,7 @@ module Decidim
339
346
  end
340
347
 
341
348
  ransacker :is_emendation do |_parent|
342
- query = <<-SQL
349
+ query = <<-SQL.squish
343
350
  (
344
351
  SELECT EXISTS (
345
352
  SELECT 1 FROM decidim_amendments
@@ -367,6 +374,7 @@ module Decidim
367
374
  # Checks whether the proposal is inside the time window to be editable or not once published.
368
375
  def within_edit_time_limit?
369
376
  return true if draft?
377
+ return true if component.settings.proposal_edit_time == "infinite"
370
378
 
371
379
  limit = updated_at + component.settings.proposal_edit_before_minutes.minutes
372
380
  Time.current < limit
@@ -57,9 +57,9 @@ module Decidim
57
57
  # Only admin users can publish many answers at once
58
58
  toggle_allow(user.admin?) if permission_action.subject == :proposals && permission_action.action == :publish_answers
59
59
 
60
- if permission_action.subject == :participatory_texts && participatory_texts_are_enabled?
60
+ if permission_action.subject == :participatory_texts && participatory_texts_are_enabled? && permission_action.action == :manage
61
61
  # Every user allowed by the space can manage (import, update and publish) participatory texts to proposals
62
- allow! if permission_action.action == :manage
62
+ allow!
63
63
  end
64
64
 
65
65
  permission_action
@@ -10,9 +10,10 @@ module Decidim
10
10
  return Decidim::Proposals::Admin::Permissions.new(user, permission_action, context).permissions if permission_action.scope == :admin
11
11
  return permission_action if permission_action.scope != :public
12
12
 
13
- if permission_action.subject == :proposal
13
+ case permission_action.subject
14
+ when :proposal
14
15
  apply_proposal_permissions(permission_action)
15
- elsif permission_action.subject == :collaborative_draft
16
+ when :collaborative_draft
16
17
  apply_collaborative_draft_permissions(permission_action)
17
18
  else
18
19
  permission_action
@@ -100,13 +100,13 @@ module Decidim
100
100
  private
101
101
 
102
102
  def sanitize_unordered_lists(text)
103
- text.gsub(%r{(?=.*<\/ul>)(?!.*?<li>.*?<\/ol>.*?<\/ul>)<li>}) { |li| li + "• " }
103
+ text.gsub(%r{(?=.*</ul>)(?!.*?<li>.*?</ol>.*?</ul>)<li>}) { |li| "#{li}• " }
104
104
  end
105
105
 
106
106
  def sanitize_ordered_lists(text)
107
107
  i = 0
108
108
 
109
- text.gsub(%r{(?=.*<\/ol>)(?!.*?<li>.*?<\/ul>.*?<\/ol>)<li>}) do |li|
109
+ text.gsub(%r{(?=.*</ol>)(?!.*?<li>.*?</ul>.*?</ol>)<li>}) do |li|
110
110
  i += 1
111
111
 
112
112
  li + "#{i}. "
@@ -114,11 +114,11 @@ module Decidim
114
114
  end
115
115
 
116
116
  def add_line_feeds_to_paragraphs(text)
117
- text.gsub("</p>") { |p| p + "\n\n" }
117
+ text.gsub("</p>") { |p| "#{p}\n\n" }
118
118
  end
119
119
 
120
120
  def add_line_feeds_to_list_items(text)
121
- text.gsub("</li>") { |li| li + "\n" }
121
+ text.gsub("</li>") { |li| "#{li}\n" }
122
122
  end
123
123
 
124
124
  # Adds line feeds after the paragraph and list item closing tags.
@@ -17,8 +17,8 @@ module Decidim
17
17
  cumulative_users |= retrieve_drafts_followers.pluck(:decidim_user_id)
18
18
 
19
19
  quantity_users = []
20
- quantity_users |= retrieve_proposals_followers(true).pluck(:decidim_user_id)
21
- quantity_users |= retrieve_drafts_followers(true).pluck(:decidim_user_id)
20
+ quantity_users |= retrieve_proposals_followers(from_start: true).pluck(:decidim_user_id)
21
+ quantity_users |= retrieve_drafts_followers(from_start: true).pluck(:decidim_user_id)
22
22
 
23
23
  {
24
24
  cumulative_users: cumulative_users.uniq,
@@ -28,7 +28,7 @@ module Decidim
28
28
 
29
29
  private
30
30
 
31
- def retrieve_proposals_followers(from_start = false)
31
+ def retrieve_proposals_followers(from_start: false)
32
32
  @proposals_followers ||= Decidim::Follow.where(followable: retrieve_proposals).joins(:user)
33
33
  .where("decidim_follows.created_at <= ?", end_time)
34
34
 
@@ -37,7 +37,7 @@ module Decidim
37
37
  @proposals_followers
38
38
  end
39
39
 
40
- def retrieve_drafts_followers(from_start = false)
40
+ def retrieve_drafts_followers(from_start: false)
41
41
  @drafts_followers ||= Decidim::Follow.where(followable: retrieve_collaborative_drafts).joins(:user)
42
42
  .where("decidim_follows.created_at <= ?", end_time)
43
43
  return @drafts_followers.where("decidim_follows.created_at >= ?", start_time) if from_start