decidim-proposals 0.23.1 → 0.24.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +4 -1
  3. data/app/assets/stylesheets/decidim/proposals/_proposals.css.scss +1 -0
  4. data/app/assets/stylesheets/decidim/proposals/proposals/_preview.css.scss +3 -0
  5. data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +3 -3
  6. data/app/cells/decidim/proposals/collaborative_drafts/reported_content/show.erb +3 -0
  7. data/app/cells/decidim/proposals/collaborative_drafts/reported_content_cell.rb +15 -0
  8. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/elements.erb +5 -0
  9. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/heading.erb +1 -0
  10. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals_cell.rb +19 -0
  11. data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +1 -1
  12. data/app/cells/decidim/proposals/proposal_activity_cell.rb +13 -5
  13. data/app/cells/decidim/proposals/proposal_m_cell.rb +23 -2
  14. data/app/cells/decidim/proposals/reported_content/show.erb +4 -0
  15. data/app/cells/decidim/proposals/reported_content_cell.rb +13 -0
  16. data/app/commands/decidim/proposals/admin/update_proposal.rb +2 -0
  17. data/app/commands/decidim/proposals/hashtags_methods.rb +1 -1
  18. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +7 -5
  19. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +1 -30
  20. data/app/controllers/decidim/proposals/proposals_controller.rb +5 -6
  21. data/app/events/decidim/proposals/publish_proposal_event.rb +1 -1
  22. data/app/forms/decidim/proposals/access_to_collaborative_draft_form.rb +1 -3
  23. data/app/forms/decidim/proposals/admin/proposal_base_form.rb +3 -2
  24. data/app/forms/decidim/proposals/admin/proposal_form.rb +13 -0
  25. data/app/forms/decidim/proposals/proposal_form.rb +15 -5
  26. data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +1 -9
  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 +25 -4
  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 +21 -11
  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/admin_log/proposal_presenter.rb +2 -2
  39. data/app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb +2 -2
  40. data/app/presenters/decidim/proposals/proposal_presenter.rb +35 -16
  41. data/app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb +4 -4
  42. data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +6 -6
  43. data/app/services/decidim/proposals/diff_renderer.rb +7 -11
  44. data/app/services/decidim/proposals/proposal_builder.rb +1 -0
  45. data/app/validators/proposal_length_validator.rb +4 -2
  46. data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +8 -1
  47. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +8 -2
  48. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +5 -1
  49. data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +1 -1
  50. data/app/views/decidim/proposals/collaborative_drafts/_filters_small_view.html.erb +1 -1
  51. data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +2 -7
  52. data/app/views/decidim/proposals/collaborative_drafts/_wizard_header.html.erb +14 -0
  53. data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +7 -7
  54. data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +5 -13
  55. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +7 -11
  56. data/app/views/decidim/proposals/proposals/_dynamic_map_instructions.html.erb +3 -0
  57. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +2 -2
  58. data/app/views/decidim/proposals/proposals/_filters.html.erb +34 -32
  59. data/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +1 -1
  60. data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +21 -11
  61. data/app/views/decidim/proposals/proposals/edit.html.erb +7 -7
  62. data/app/views/decidim/proposals/proposals/preview.html.erb +50 -2
  63. data/app/views/decidim/proposals/proposals/show.html.erb +8 -12
  64. data/config/locales/ar.yml +2 -22
  65. data/config/locales/ca.yml +28 -32
  66. data/config/locales/cs.yml +48 -52
  67. data/config/locales/de.yml +127 -104
  68. data/config/locales/el.yml +2 -29
  69. data/config/locales/en.yml +25 -29
  70. data/config/locales/es-MX.yml +24 -29
  71. data/config/locales/es-PY.yml +24 -29
  72. data/config/locales/es.yml +24 -29
  73. data/config/locales/eu.yml +4 -22
  74. data/config/locales/fi-plain.yml +24 -28
  75. data/config/locales/fi.yml +31 -35
  76. data/config/locales/fr-CA.yml +21 -29
  77. data/config/locales/fr.yml +21 -29
  78. data/config/locales/gl.yml +4 -22
  79. data/config/locales/hu.yml +2 -22
  80. data/config/locales/id-ID.yml +2 -22
  81. data/config/locales/is-IS.yml +0 -5
  82. data/config/locales/it.yml +4 -29
  83. data/config/locales/ja.yml +2 -29
  84. data/config/locales/lv.yml +2 -21
  85. data/config/locales/nl.yml +33 -43
  86. data/config/locales/no.yml +4 -24
  87. data/config/locales/pl.yml +31 -31
  88. data/config/locales/pt-BR.yml +2 -21
  89. data/config/locales/pt.yml +2 -29
  90. data/config/locales/ro-RO.yml +5 -28
  91. data/config/locales/ru.yml +0 -5
  92. data/config/locales/si-LK.yml +1 -0
  93. data/config/locales/sk.yml +5 -22
  94. data/config/locales/sv.yml +12 -34
  95. data/config/locales/sw-KE.yml +1 -0
  96. data/config/locales/tr-TR.yml +383 -231
  97. data/config/locales/uk.yml +0 -5
  98. data/config/locales/zh-CN.yml +2 -29
  99. data/db/migrate/20210127115628_fix_answered_proposals_after_copy.rb +14 -0
  100. data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_filter.rb +0 -0
  101. data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_sort.rb +3 -5
  102. data/lib/decidim/api/proposal_type.rb +56 -0
  103. data/lib/decidim/api/proposals_type.rb +43 -0
  104. data/lib/decidim/content_renderers/proposal_renderer.rb +1 -1
  105. data/lib/decidim/proposals.rb +2 -0
  106. data/lib/decidim/proposals/api.rb +10 -0
  107. data/lib/decidim/proposals/component.rb +30 -19
  108. data/lib/decidim/proposals/engine.rb +6 -27
  109. data/lib/decidim/proposals/proposal_creator.rb +98 -0
  110. data/lib/decidim/proposals/test/factories.rb +22 -8
  111. data/lib/decidim/proposals/version.rb +1 -1
  112. metadata +55 -41
  113. data/app/commands/decidim/proposals/create_proposal_export.rb +0 -37
  114. data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +0 -0
  115. data/app/queries/decidim/proposals/similar_collaborative_drafts.rb +0 -52
  116. data/app/types/decidim/proposals/proposal_type.rb +0 -70
  117. data/app/types/decidim/proposals/proposals_type.rb +0 -41
  118. data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +0 -13
  119. data/app/views/decidim/proposals/collaborative_drafts/compare.html.erb +0 -21
  120. data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +0 -24
  121. data/app/views/decidim/proposals/proposals/_proposal_preview.html.erb +0 -1
  122. data/db/migrate/20200915151348_fix_proposals_data_to_ensure_title_and_body_are_hashes.rb +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82abb8e700200d86798c63c09f42604c50e8117ec6f162eac16f93fbbe51d2b4
4
- data.tar.gz: 8becaeaae84754886571c87b1f2df2caa01e8dd17b81808aa1af4e2dff9ecaaa
3
+ metadata.gz: 651e0b6a4c3eb957e436b43b59af16f0f003dafd053982e9ad731007d928b98a
4
+ data.tar.gz: 9b17adde9c0c8726bdbc8f0b6b9b5783b7f2b16f7fcb89a98a33cc906b55146f
5
5
  SHA512:
6
- metadata.gz: bc3725296a98abca0ae3b7634813ceb50a28be31045082b7764bb12b39974a5de013e01b86818c648293ca6147ba4a900ea985413a023bc6b73b71ce73ede570
7
- data.tar.gz: b586bdd3ebec54dc6f29de58a2bbabc6dbd77209884cdde6fbd3eef3b7e53f282d862536eb84a064e1105fe51cb1e58d2d64e0ce25e2f0f1428b065b22b002bf
6
+ metadata.gz: ae7a065f2d8b9edd8da8993bc338882d076f63a0236ad6a1594d0a294cb00492a76f368206413771fd560d91f883fc7272150e502abbec6a0e9184590f50ea66
7
+ data.tar.gz: 0f878229e8d1dd67dfd73af3dfef2b0775a3a4ceb49ef728390b45ec0266d33237228556697bb21e3d63fe23c5a363a5db086b155cf7e07691edbcae6538e173
@@ -6,13 +6,16 @@ $(() => {
6
6
  window.DecidimProposals.bindProposalAddress = () => {
7
7
  const $checkbox = $("input:checkbox[name$='[has_address]']");
8
8
  const $addressInput = $("#address_input");
9
+ const $addressInputField = $("input", $addressInput);
9
10
 
10
11
  if ($checkbox.length > 0) {
11
12
  const toggleInput = () => {
12
13
  if ($checkbox[0].checked) {
13
14
  $addressInput.show();
15
+ $addressInputField.prop("disabled", false);
14
16
  } else {
15
17
  $addressInput.hide();
18
+ $addressInputField.prop("disabled", true);
16
19
  }
17
20
  }
18
21
  toggleInput();
@@ -20,7 +23,7 @@ $(() => {
20
23
  }
21
24
 
22
25
  if ($addressInput.length > 0) {
23
- attachGeocoding($("input", $addressInput));
26
+ attachGeocoding($addressInputField);
24
27
  }
25
28
  };
26
29
 
@@ -0,0 +1 @@
1
+ @import "proposals/*";
@@ -0,0 +1,3 @@
1
+ .preview--form__hidden{
2
+ display: none;
3
+ }
@@ -23,13 +23,13 @@ module Decidim
23
23
  end
24
24
 
25
25
  def link_header
26
- content_tag :strong, class: "text-large" do
26
+ tag.strong(class: "text-large") do
27
27
  t("final_proposal", scope: "decidim.proposals.collaborative_drafts.show")
28
28
  end
29
29
  end
30
30
 
31
31
  def link_help_text
32
- content_tag :span, class: "text-medium" do
32
+ tag.span(class: "text-medium") do
33
33
  t("final_proposal_help_text", scope: "decidim.proposals.collaborative_drafts.show")
34
34
  end
35
35
  end
@@ -39,7 +39,7 @@ module Decidim
39
39
  collaborative_draft_id: model.id
40
40
  )
41
41
  link_to @path, class: "text-medium" do
42
- content_tag :u do
42
+ tag.u do
43
43
  t("version_history", scope: "decidim.proposals.collaborative_drafts.show")
44
44
  end
45
45
  end
@@ -0,0 +1,3 @@
1
+ <blockquote>
2
+ <p><%= render_value model.body %></p>
3
+ </blockquote>
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ module CollaborativeDrafts
6
+ # This cells renders a small preview of the `CollaborativeDraft` that is
7
+ # used in the moderations panel.
8
+ class ReportedContentCell < Decidim::ReportedContentCell
9
+ def show
10
+ render :show
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ <div class="row small-up-1 medium-up-2 mediumlarge-up-3 large-up-3 card-grid">
2
+ <% elements.each do |element| %>
3
+ <%= card_for element, context: { show_space: true } %>
4
+ <% end %>
5
+ </div>
@@ -0,0 +1 @@
1
+ <h2 class="section-heading"><%= t("decidim.proposals.content_blocks.highlighted_proposals.proposals") %></h2>
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ module ContentBlocks
6
+ class HighlightedProposalsCell < Decidim::ContentBlocks::HighlightedElementsCell
7
+ def base_relation
8
+ @base_relation ||= Decidim::Proposals::Proposal.published.not_hidden.except_withdrawn.where(component: published_components)
9
+ end
10
+
11
+ private
12
+
13
+ def limit
14
+ Decidim::Proposals.config.process_group_highlighted_proposals_limit
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -60,7 +60,7 @@ module Decidim
60
60
  end
61
61
 
62
62
  def button_cancel
63
- content_tag :div, class: "columns medium-6" do
63
+ tag.div(class: "columns medium-6") do
64
64
  button_tag type: "button", class: "clear button secondary expanded", "data-close": "" do
65
65
  close_label
66
66
  end
@@ -2,13 +2,21 @@
2
2
 
3
3
  module Decidim
4
4
  module Proposals
5
- # A cell to display when a proposal has been published.
5
+ # A cell to display when actions happen on a proposal.
6
6
  class ProposalActivityCell < ActivityCell
7
7
  def title
8
- I18n.t(
9
- "decidim.proposals.last_activity.new_proposal_at_html",
10
- link: participatory_space_link
11
- )
8
+ case action
9
+ when "update"
10
+ I18n.t(
11
+ "decidim.proposals.last_activity.proposal_updated_at_html",
12
+ link: participatory_space_link
13
+ )
14
+ else
15
+ I18n.t(
16
+ "decidim.proposals.last_activity.new_proposal_at_html",
17
+ link: participatory_space_link
18
+ )
19
+ end
12
20
  end
13
21
 
14
22
  def resource_link_text
@@ -8,6 +8,8 @@ module Decidim
8
8
  class ProposalMCell < Decidim::CardMCell
9
9
  include ProposalCellsHelper
10
10
 
11
+ delegate :current_locale, to: :controller
12
+
11
13
  def badge
12
14
  render if has_badge?
13
15
  end
@@ -73,7 +75,7 @@ module Decidim
73
75
  end
74
76
 
75
77
  def creation_date_status
76
- explanation = content_tag(:strong, t("activemodel.attributes.common.created_at"))
78
+ explanation = tag.strong(t("activemodel.attributes.common.created_at"))
77
79
  "#{explanation}<br>#{l(model.published_at.to_date, format: :decidim_short)}"
78
80
  end
79
81
 
@@ -87,7 +89,7 @@ module Decidim
87
89
 
88
90
  def endorsements_count
89
91
  with_tooltip t("decidim.endorsable.endorsements") do
90
- icon("bullhorn", class: "icon--small") + " " + model.endorsements_count.to_s
92
+ "#{icon("bullhorn", class: "icon--small")} #{model.endorsements_count}"
91
93
  end
92
94
  end
93
95
 
@@ -122,6 +124,25 @@ module Decidim
122
124
  def resource_image_path
123
125
  @resource_image_path ||= has_image? ? model.attachments.find_by("content_type like '%image%'").url : nil
124
126
  end
127
+
128
+ def cache_hash
129
+ hash = []
130
+ hash << "decidim/proposals/proposal_m"
131
+ hash << I18n.locale.to_s
132
+ hash << model.cache_key_with_version
133
+ hash << model.proposal_votes_count
134
+ hash << model.endorsements_count
135
+ hash << Digest::MD5.hexdigest(model.component.settings.to_json)
136
+ hash << Digest::MD5.hexdigest(resource_image_path) if resource_image_path
137
+ if current_user
138
+ hash << current_user.cache_key_with_version
139
+ hash << current_user.follows?(model) ? 1 : 0
140
+ end
141
+ hash << Digest::MD5.hexdigest(model.followers.to_json)
142
+ hash << Digest::MD5.hexdigest(model.coauthorships.map(&:cache_key_with_version).to_s)
143
+
144
+ hash.join("/")
145
+ end
125
146
  end
126
147
  end
127
148
  end
@@ -0,0 +1,4 @@
1
+ <blockquote>
2
+ <h5><%= render_value model.title %></h5>
3
+ <p><%= render_value model.body %></p>
4
+ </blockquote>
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ # This cells renders a small preview of the `Proposal` that is
6
+ # used in the moderations panel.
7
+ class ReportedContentCell < Decidim::ReportedContentCell
8
+ def show
9
+ render :show
10
+ end
11
+ end
12
+ end
13
+ end
@@ -28,6 +28,8 @@ module Decidim
28
28
  def call
29
29
  return broadcast(:invalid) if form.invalid?
30
30
 
31
+ delete_attachment(form.attachment) if delete_attachment?
32
+
31
33
  if process_attachments?
32
34
  @proposal.attachments.destroy_all
33
35
 
@@ -14,7 +14,7 @@ module Decidim
14
14
  def body_with_hashtags
15
15
  @body_with_hashtags ||= begin
16
16
  ret = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.body, current_organization: form.current_organization).rewrite.strip
17
- ret += "\n" + body_extra_hashtags.strip unless body_extra_hashtags.empty?
17
+ ret += "\n#{body_extra_hashtags.strip}" unless body_extra_hashtags.empty?
18
18
  ret
19
19
  end
20
20
  end
@@ -124,13 +124,13 @@ module Decidim
124
124
  def edit
125
125
  enforce_permission_to :edit, :proposal, proposal: proposal
126
126
  @form = form(Admin::ProposalForm).from_model(proposal)
127
- @form.attachment = form(AttachmentForm).from_params({})
128
127
  end
129
128
 
130
129
  def update
131
130
  enforce_permission_to :edit, :proposal, proposal: proposal
132
131
 
133
132
  @form = form(Admin::ProposalForm).from_params(params)
133
+
134
134
  Admin::UpdateProposal.call(@form, @proposal) do
135
135
  on(:ok) do |_proposal|
136
136
  flash[:notice] = t("proposals.update.success", scope: "decidim")
@@ -165,14 +165,15 @@ module Decidim
165
165
  def update_proposals_bulk_response_successful(response, subject)
166
166
  return if response[:successful].blank?
167
167
 
168
- if subject == :category
168
+ case subject
169
+ when :category
169
170
  t(
170
171
  "proposals.update_category.success",
171
172
  subject_name: response[:subject_name],
172
173
  proposals: response[:successful].to_sentence,
173
174
  scope: "decidim.proposals.admin"
174
175
  )
175
- elsif subject == :scope
176
+ when :scope
176
177
  t(
177
178
  "proposals.update_scope.success",
178
179
  subject_name: response[:subject_name],
@@ -185,14 +186,15 @@ module Decidim
185
186
  def update_proposals_bulk_response_errored(response, subject)
186
187
  return if response[:errored].blank?
187
188
 
188
- if subject == :category
189
+ case subject
190
+ when :category
189
191
  t(
190
192
  "proposals.update_category.invalid",
191
193
  subject_name: response[:subject_name],
192
194
  proposals: response[:errored].to_sentence,
193
195
  scope: "decidim.proposals.admin"
194
196
  )
195
- elsif subject == :scope
197
+ when :scope
196
198
  t(
197
199
  "proposals.update_scope.invalid",
198
200
  subject_name: response[:subject_name],
@@ -19,7 +19,7 @@ module Decidim
19
19
 
20
20
  helper_method :geocoded_collaborative_draft, :collaborative_draft
21
21
  before_action :collaborative_drafts_enabled?
22
- before_action :authenticate_user!, only: [:new, :create, :complete]
22
+ before_action :authenticate_user!, only: [:new, :create]
23
23
  before_action :retrieve_collaborative_draft, only: [:show, :edit, :update, :withdraw, :publish]
24
24
 
25
25
  def index
@@ -36,7 +36,6 @@ module Decidim
36
36
  def show
37
37
  raise ActionController::RoutingError, "Not Found" unless retrieve_collaborative_draft
38
38
 
39
- @report_form = form(Decidim::ReportForm).from_params(reason: "spam")
40
39
  @request_access_form = form(RequestAccessToCollaborativeDraftForm).from_params({})
41
40
  @accept_request_form = form(AcceptAccessToCollaborativeDraftForm).from_params({})
42
41
  @reject_request_form = form(RejectAccessToCollaborativeDraftForm).from_params({})
@@ -44,42 +43,14 @@ module Decidim
44
43
 
45
44
  def new
46
45
  enforce_permission_to :create, :collaborative_draft
47
- @step = :step_1
48
46
 
49
47
  @form = form(CollaborativeDraftForm).from_params(
50
48
  attachment: form(AttachmentForm).from_params({})
51
49
  )
52
50
  end
53
51
 
54
- def compare
55
- @step = :step_2
56
- @similar_collaborative_drafts ||= Decidim::Proposals::SimilarCollaborativeDrafts
57
- .for(current_component, params[:collaborative_draft])
58
- .all
59
- @form = form(CollaborativeDraftForm).from_params(params)
60
-
61
- if @similar_collaborative_drafts.blank?
62
- flash[:notice] = I18n.t("proposals.collaborative_drafts.compare.no_similars_found", scope: "decidim")
63
- redirect_to complete_collaborative_drafts_path(collaborative_draft: { title: @form.title, body: @form.body })
64
- end
65
- end
66
-
67
- def complete
68
- enforce_permission_to :create, :collaborative_draft
69
- @step = :step_3
70
- if params[:collaborative_draft].present?
71
- params[:collaborative_draft][:attachment] = form(AttachmentForm).from_params({})
72
- @form = form(CollaborativeDraftForm).from_params(params)
73
- else
74
- @form = form(CollaborativeDraftForm).from_params(
75
- attachment: form(AttachmentForm).from_params({})
76
- )
77
- end
78
- end
79
-
80
52
  def create
81
53
  enforce_permission_to :create, :collaborative_draft
82
- @step = :step_3
83
54
  @form = form(CollaborativeDraftForm).from_params(params)
84
55
 
85
56
  CreateCollaborativeDraft.call(@form, current_user) do
@@ -39,7 +39,7 @@ module Decidim
39
39
  .results
40
40
  .published
41
41
  .not_hidden
42
- .includes(:amendable, :category, :component, :resource_permission, :scope)
42
+ .includes(:component, :coauthorships)
43
43
 
44
44
  @voted_proposals = if current_user
45
45
  ProposalVote.where(
@@ -56,8 +56,6 @@ module Decidim
56
56
 
57
57
  def show
58
58
  raise ActionController::RoutingError, "Not Found" if @proposal.blank? || !can_show_proposal?
59
-
60
- @report_form = form(Decidim::ReportForm).from_params(reason: "spam")
61
59
  end
62
60
 
63
61
  def new
@@ -79,7 +77,7 @@ module Decidim
79
77
  on(:ok) do |proposal|
80
78
  flash[:notice] = I18n.t("proposals.create.success", scope: "decidim")
81
79
 
82
- redirect_to Decidim::ResourceLocatorPresenter.new(proposal).path + "/compare"
80
+ redirect_to "#{Decidim::ResourceLocatorPresenter.new(proposal).path}/compare"
83
81
  end
84
82
 
85
83
  on(:invalid) do
@@ -97,7 +95,7 @@ module Decidim
97
95
 
98
96
  if @similar_proposals.blank?
99
97
  flash[:notice] = I18n.t("proposals.proposals.compare.no_similars_found", scope: "decidim")
100
- redirect_to Decidim::ResourceLocatorPresenter.new(@proposal).path + "/complete"
98
+ redirect_to "#{Decidim::ResourceLocatorPresenter.new(@proposal).path}/complete"
101
99
  end
102
100
  end
103
101
 
@@ -112,6 +110,7 @@ module Decidim
112
110
 
113
111
  def preview
114
112
  @step = :step_4
113
+ @form = form(ProposalForm).from_model(@proposal)
115
114
  end
116
115
 
117
116
  def publish
@@ -142,7 +141,7 @@ module Decidim
142
141
  UpdateProposal.call(@form, current_user, @proposal) do
143
142
  on(:ok) do |proposal|
144
143
  flash[:notice] = I18n.t("proposals.update_draft.success", scope: "decidim")
145
- redirect_to Decidim::ResourceLocatorPresenter.new(proposal).path + "/preview"
144
+ redirect_to "#{Decidim::ResourceLocatorPresenter.new(proposal).path}/preview"
146
145
  end
147
146
 
148
147
  on(:invalid) do
@@ -18,7 +18,7 @@ module Decidim
18
18
  end
19
19
 
20
20
  def participatory_space_event?
21
- extra.dig(:participatory_space)
21
+ extra[:participatory_space]
22
22
  end
23
23
  end
24
24
  end
@@ -26,9 +26,7 @@ module Decidim
26
26
  private
27
27
 
28
28
  def existence_of_requester_in_requesters
29
- if collaborative_draft
30
- errors.add(:requester_user_id, :invalid) unless collaborative_draft.requesters.exists? requester_user_id
31
- end
29
+ errors.add(:requester_user_id, :invalid) if collaborative_draft && !collaborative_draft.requesters.exists?(requester_user_id)
32
30
  end
33
31
  end
34
32
  end
@@ -6,6 +6,7 @@ module Decidim
6
6
  # A form object to be used when admin users want to create a proposal.
7
7
  class ProposalBaseForm < Decidim::Form
8
8
  include Decidim::TranslatableAttributes
9
+ include Decidim::AttachmentAttributes
9
10
  include Decidim::ApplicationHelper
10
11
 
11
12
  mimic :proposal
@@ -20,8 +21,8 @@ module Decidim
20
21
  attribute :created_in_meeting, Boolean
21
22
  attribute :meeting_id, Integer
22
23
  attribute :suggested_hashtags, Array[String]
23
- attribute :photos, Array[String]
24
- attribute :add_photos, Array
24
+
25
+ attachments_attribute :photos
25
26
 
26
27
  validates :address, geocoding: true, if: ->(form) { form.has_address? && !form.geocoded? }
27
28
  validates :category, presence: true, if: ->(form) { form.category_id.present? }