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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecc460610a2df7a98ede2d5b06ea8a55d9e2e6a49c0c368117e8ded7cc12175c
4
- data.tar.gz: 21af14b20655d697993a7df7ccd25802668dda3fa211c0a5e5633b6edfabfa65
3
+ metadata.gz: 142f24896edb193343adcd4361f279c716308d4129b89b704eac4277bd308b4e
4
+ data.tar.gz: 3d773dff5a2699d99ea4682327c544fe7e7f2f80ea0765a7f8fb412b665791a4
5
5
  SHA512:
6
- metadata.gz: 961eeb89b2eb70156db42f8067d1f2092615c1047f3fc5b0c348a3e40862f0908c708f756263ee17dff4195a85fe1df0c4caba8e1dbbed88ad21bd9a725bd476
7
- data.tar.gz: 7bc5bcf68d405c2c54bde3b9d4dfdc351bed74079fab81903b7d8fcf6beda06a0c99bf39414f7291e884184aa24ea4920a285715cfc880944aba9965cb4b5d00
6
+ metadata.gz: ff5254b374646ce49a0de1ac169b77de11a9caa6fb1c3eb60958705d9ff26207d8d278f83168ce38de7d438fb839325f03ab5db64fb495e6375924ddb4a56cc3
7
+ data.tar.gz: f1844b7927f54884c2a396231e9c0b9443e30849741b66e971225fde426313b2cfca7a44500bb8054c45d0f4c8b8d1bdac93949ab247d1246eaaf4a74722b53f
@@ -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
 
@@ -21,6 +21,9 @@ $(() => {
21
21
  $proposalCreatedInMeeting.on("change", toggleDisabledHiddenFields);
22
22
  toggleDisabledHiddenFields();
23
23
 
24
- attachGeocoding($form.find("#proposal_address"));
24
+ const $proposalAddress = $form.find("#proposal_address");
25
+ if ($proposalAddress.length !== 0) {
26
+ attachGeocoding($proposalAddress);
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
@@ -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.cache_key_with_version)
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 << model.follows_count
142
+ hash << Digest::MD5.hexdigest(model.authors.map(&:cache_key_with_version).to_s)
143
+
144
+ hash.join("/")
145
+ end
125
146
  end
126
147
  end
127
148
  end
@@ -50,7 +50,7 @@ module Decidim
50
50
 
51
51
  def filtered_proposals
52
52
  @filtered_proposals ||= if filtered?
53
- proposals.where("title ILIKE ?", "%#{search_text}%")
53
+ proposals.where("title::text ILIKE ?", "%#{search_text}%")
54
54
  .or(proposals.where("reference ILIKE ?", "%#{search_text}%"))
55
55
  .or(proposals.where("id::text ILIKE ?", "%#{search_text}%"))
56
56
  else
@@ -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
@@ -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
@@ -30,8 +30,6 @@ module Decidim
30
30
  return broadcast(:invalid) if invalid?
31
31
 
32
32
  if process_attachments?
33
- @proposal.attachments.destroy_all
34
-
35
33
  build_attachments
36
34
  return broadcast(:invalid) if attachments_invalid?
37
35
  end
@@ -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
@@ -40,7 +40,7 @@ module Decidim
40
40
  .published
41
41
  .not_hidden
42
42
 
43
- @proposals = @base_query.includes(:amendable, :category, :component, :resource_permission, :scope)
43
+ @proposals = @base_query.includes(:component, :coauthorships)
44
44
  @all_geocoded_proposals = @base_query.geocoded
45
45
 
46
46
  @voted_proposals = if current_user
@@ -58,8 +58,6 @@ module Decidim
58
58
 
59
59
  def show
60
60
  raise ActionController::RoutingError, "Not Found" if @proposal.blank? || !can_show_proposal?
61
-
62
- @report_form = form(Decidim::ReportForm).from_params(reason: "spam")
63
61
  end
64
62
 
65
63
  def new
@@ -81,7 +79,7 @@ module Decidim
81
79
  on(:ok) do |proposal|
82
80
  flash[:notice] = I18n.t("proposals.create.success", scope: "decidim")
83
81
 
84
- redirect_to Decidim::ResourceLocatorPresenter.new(proposal).path + "/compare"
82
+ redirect_to "#{Decidim::ResourceLocatorPresenter.new(proposal).path}/compare"
85
83
  end
86
84
 
87
85
  on(:invalid) do
@@ -99,7 +97,7 @@ module Decidim
99
97
 
100
98
  if @similar_proposals.blank?
101
99
  flash[:notice] = I18n.t("proposals.proposals.compare.no_similars_found", scope: "decidim")
102
- redirect_to Decidim::ResourceLocatorPresenter.new(@proposal).path + "/complete"
100
+ redirect_to "#{Decidim::ResourceLocatorPresenter.new(@proposal).path}/complete"
103
101
  end
104
102
  end
105
103
 
@@ -114,6 +112,7 @@ module Decidim
114
112
 
115
113
  def preview
116
114
  @step = :step_4
115
+ @form = form(ProposalForm).from_model(@proposal)
117
116
  end
118
117
 
119
118
  def publish
@@ -144,7 +143,7 @@ module Decidim
144
143
  UpdateProposal.call(@form, current_user, @proposal) do
145
144
  on(:ok) do |proposal|
146
145
  flash[:notice] = I18n.t("proposals.update_draft.success", scope: "decidim")
147
- redirect_to Decidim::ResourceLocatorPresenter.new(proposal).path + "/preview"
146
+ redirect_to "#{Decidim::ResourceLocatorPresenter.new(proposal).path}/preview"
148
147
  end
149
148
 
150
149
  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? }
@@ -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
- attribute :photos, Array[String]
20
- attribute :add_photos, Array
21
- attribute :documents, Array[String]
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
- geocoding_enabled? && has_address
78
+ return unless has_address
79
+
80
+ geocoding_enabled? && address.present?
71
81
  end
72
82
 
73
83
  def geocoded?