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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +4 -1
- data/app/assets/javascripts/decidim/proposals/admin/proposals_form.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/proposals_picker_cell.rb +1 -1
- 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/hashtags_methods.rb +1 -1
- data/app/commands/decidim/proposals/update_proposal.rb +0 -2
- data/app/controllers/decidim/proposals/admin/proposals_controller.rb +6 -4
- 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/proposal_form.rb +15 -5
- data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +1 -1
- 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 +31 -8
- 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 +18 -10
- data/app/permissions/decidim/proposals/admin/permissions.rb +2 -2
- data/app/permissions/decidim/proposals/permissions.rb +3 -2
- data/app/presenters/decidim/proposals/proposal_presenter.rb +4 -4
- 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/collaborative_draft_search.rb +1 -1
- data/app/services/decidim/proposals/diff_renderer.rb +7 -11
- data/app/services/decidim/proposals/proposal_builder.rb +1 -0
- data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +8 -1
- 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/_filters_small_view.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 +1 -3
- data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +5 -13
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -7
- data/app/views/decidim/proposals/proposals/_dynamic_map_instructions.html.erb +3 -0
- data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +6 -6
- data/app/views/decidim/proposals/proposals/_filters.html.erb +34 -32
- data/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +21 -11
- data/app/views/decidim/proposals/proposals/edit.html.erb +1 -3
- data/app/views/decidim/proposals/proposals/preview.html.erb +50 -2
- data/app/views/decidim/proposals/proposals/show.html.erb +2 -8
- data/config/locales/ar.yml +2 -23
- data/config/locales/bg.yml +0 -4
- data/config/locales/ca.yml +23 -29
- data/config/locales/cs.yml +24 -30
- data/config/locales/de.yml +23 -29
- data/config/locales/el.yml +2 -29
- data/config/locales/en.yml +23 -29
- data/config/locales/es-MX.yml +23 -29
- data/config/locales/es-PY.yml +23 -29
- data/config/locales/es.yml +23 -29
- data/config/locales/eu.yml +2 -23
- data/config/locales/fi-plain.yml +22 -28
- data/config/locales/fi.yml +22 -28
- data/config/locales/fr-CA.yml +19 -29
- data/config/locales/fr.yml +19 -29
- data/config/locales/gl.yml +17 -25
- data/config/locales/hu.yml +2 -23
- data/config/locales/id-ID.yml +2 -23
- data/config/locales/is-IS.yml +0 -8
- data/config/locales/it.yml +4 -29
- data/config/locales/ja.yml +2 -29
- data/config/locales/lv.yml +2 -22
- data/config/locales/nl.yml +17 -29
- data/config/locales/no.yml +2 -23
- data/config/locales/pl.yml +22 -28
- data/config/locales/pt-BR.yml +2 -22
- data/config/locales/pt.yml +2 -29
- data/config/locales/ro-RO.yml +13 -29
- data/config/locales/ru.yml +0 -8
- data/config/locales/sk.yml +5 -23
- data/config/locales/sv.yml +23 -28
- data/config/locales/tr-TR.yml +17 -29
- data/config/locales/uk.yml +0 -8
- data/config/locales/zh-CN.yml +2 -29
- data/db/migrate/20210310102839_add_followable_counter_cache_to_proposals.rb +16 -0
- data/db/migrate/20210310120812_add_followable_counter_cache_to_collaborative_drafts.rb +16 -0
- data/db/migrate/20210318082934_fix_counters_for_copied_proposals.rb +9 -7
- 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 +49 -35
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 142f24896edb193343adcd4361f279c716308d4129b89b704eac4277bd308b4e
|
4
|
+
data.tar.gz: 3d773dff5a2699d99ea4682327c544fe7e7f2f80ea0765a7f8fb412b665791a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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($
|
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
|
-
|
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/*";
|
@@ -23,13 +23,13 @@ module Decidim
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def link_header
|
26
|
-
|
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
|
-
|
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
|
-
|
42
|
+
tag.u do
|
43
43
|
t("version_history", scope: "decidim.proposals.collaborative_drafts.show")
|
44
44
|
end
|
45
45
|
end
|
@@ -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 @@
|
|
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
|
@@ -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 =
|
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")
|
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,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
|
17
|
+
ret += "\n#{body_extra_hashtags.strip}" unless body_extra_hashtags.empty?
|
18
18
|
ret
|
19
19
|
end
|
20
20
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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(:
|
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
|
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
|
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
|
146
|
+
redirect_to "#{Decidim::ResourceLocatorPresenter.new(proposal).path}/preview"
|
148
147
|
end
|
149
148
|
|
150
149
|
on(:invalid) do
|
@@ -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
|
-
|
24
|
-
|
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
|
-
|
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?
|