decidim-proposals 0.23.0 → 0.24.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +4 -1
- data/app/assets/stylesheets/decidim/proposals/_proposals.css.scss +1 -0
- data/app/assets/stylesheets/decidim/proposals/proposals/_preview.css.scss +3 -0
- data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +3 -3
- data/app/cells/decidim/proposals/collaborative_drafts/reported_content/show.erb +3 -0
- data/app/cells/decidim/proposals/collaborative_drafts/reported_content_cell.rb +15 -0
- data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/elements.erb +5 -0
- data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/heading.erb +1 -0
- data/app/cells/decidim/proposals/content_blocks/highlighted_proposals_cell.rb +19 -0
- data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +1 -1
- data/app/cells/decidim/proposals/proposal_m_cell.rb +23 -2
- data/app/cells/decidim/proposals/reported_content/show.erb +4 -0
- data/app/cells/decidim/proposals/reported_content_cell.rb +13 -0
- data/app/commands/decidim/proposals/admin/update_proposal.rb +2 -0
- data/app/commands/decidim/proposals/hashtags_methods.rb +1 -1
- data/app/controllers/decidim/proposals/admin/proposals_controller.rb +7 -5
- data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +1 -30
- data/app/controllers/decidim/proposals/proposals_controller.rb +5 -6
- data/app/events/decidim/proposals/publish_proposal_event.rb +1 -1
- data/app/forms/decidim/proposals/access_to_collaborative_draft_form.rb +1 -3
- data/app/forms/decidim/proposals/admin/proposal_base_form.rb +3 -2
- data/app/forms/decidim/proposals/admin/proposal_form.rb +13 -0
- data/app/forms/decidim/proposals/proposal_form.rb +15 -5
- data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +1 -9
- data/app/helpers/decidim/proposals/admin/filterable_helper.rb +1 -1
- data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +1 -1
- data/app/helpers/decidim/proposals/admin/proposals_helper.rb +8 -8
- data/app/helpers/decidim/proposals/application_helper.rb +5 -2
- data/app/helpers/decidim/proposals/map_helper.rb +25 -4
- data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +14 -44
- data/app/helpers/decidim/proposals/proposals_helper.rb +3 -6
- data/app/models/decidim/proposals/collaborative_draft.rb +10 -0
- data/app/models/decidim/proposals/proposal.rb +21 -11
- data/app/permissions/decidim/proposals/admin/permissions.rb +2 -2
- data/app/permissions/decidim/proposals/permissions.rb +3 -2
- data/app/presenters/decidim/proposals/admin_log/proposal_presenter.rb +2 -2
- data/app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb +2 -2
- data/app/presenters/decidim/proposals/proposal_presenter.rb +35 -16
- data/app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb +4 -4
- data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +6 -6
- data/app/services/decidim/proposals/diff_renderer.rb +7 -11
- data/app/services/decidim/proposals/proposal_builder.rb +1 -0
- data/app/validators/proposal_length_validator.rb +4 -2
- data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +8 -1
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +8 -2
- data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +5 -1
- data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +1 -1
- data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +2 -7
- data/app/views/decidim/proposals/collaborative_drafts/_wizard_header.html.erb +14 -0
- data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +7 -7
- data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +5 -13
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +7 -11
- data/app/views/decidim/proposals/proposals/_dynamic_map_instructions.html.erb +3 -0
- data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_filters.html.erb +34 -32
- data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +21 -11
- data/app/views/decidim/proposals/proposals/edit.html.erb +7 -7
- data/app/views/decidim/proposals/proposals/preview.html.erb +50 -2
- data/app/views/decidim/proposals/proposals/show.html.erb +8 -12
- data/config/locales/ar.yml +2 -22
- data/config/locales/ca.yml +9 -30
- data/config/locales/cs.yml +47 -52
- data/config/locales/de.yml +126 -104
- data/config/locales/el.yml +2 -29
- data/config/locales/en.yml +24 -29
- data/config/locales/es-MX.yml +3 -29
- data/config/locales/es-PY.yml +3 -29
- data/config/locales/es.yml +3 -29
- data/config/locales/eu.yml +4 -22
- data/config/locales/fi-plain.yml +19 -28
- data/config/locales/fi.yml +26 -35
- data/config/locales/fr-CA.yml +20 -29
- data/config/locales/fr.yml +20 -29
- data/config/locales/gl.yml +4 -22
- data/config/locales/hu.yml +2 -22
- data/config/locales/id-ID.yml +2 -22
- data/config/locales/is-IS.yml +0 -5
- data/config/locales/it.yml +4 -29
- data/config/locales/ja.yml +2 -29
- data/config/locales/lv.yml +2 -21
- data/config/locales/nl.yml +28 -43
- data/config/locales/no.yml +4 -24
- data/config/locales/pl.yml +17 -30
- data/config/locales/pt-BR.yml +2 -21
- data/config/locales/pt.yml +2 -29
- data/config/locales/ro-RO.yml +5 -28
- data/config/locales/ru.yml +0 -5
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +5 -22
- data/config/locales/sv.yml +12 -34
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/tr-TR.yml +383 -231
- data/config/locales/uk.yml +0 -5
- data/config/locales/zh-CN.yml +2 -29
- data/db/migrate/20200708091228_move_proposals_fields_to_i18n.rb +8 -2
- data/db/migrate/20210127115628_fix_answered_proposals_after_copy.rb +14 -0
- data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_filter.rb +0 -0
- data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_sort.rb +3 -5
- data/lib/decidim/api/proposal_type.rb +56 -0
- data/lib/decidim/api/proposals_type.rb +43 -0
- data/lib/decidim/content_renderers/proposal_renderer.rb +1 -1
- data/lib/decidim/proposals.rb +2 -0
- data/lib/decidim/proposals/api.rb +10 -0
- data/lib/decidim/proposals/component.rb +30 -19
- data/lib/decidim/proposals/engine.rb +6 -27
- data/lib/decidim/proposals/proposal_creator.rb +98 -0
- data/lib/decidim/proposals/test/factories.rb +22 -8
- data/lib/decidim/proposals/version.rb +1 -1
- metadata +55 -40
- data/app/commands/decidim/proposals/create_proposal_export.rb +0 -37
- data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +0 -0
- data/app/queries/decidim/proposals/similar_collaborative_drafts.rb +0 -52
- data/app/types/decidim/proposals/proposal_type.rb +0 -70
- data/app/types/decidim/proposals/proposals_type.rb +0 -41
- data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +0 -13
- data/app/views/decidim/proposals/collaborative_drafts/compare.html.erb +0 -21
- data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +0 -24
- data/app/views/decidim/proposals/proposals/_proposal_preview.html.erb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67cf84b4e45cd888f61855ec0cf7b6f8bdc7ac95436dbb26f210d8208d6b14ea
|
4
|
+
data.tar.gz: f6948e12bbea3e8cb7a260657ff242a19e4c79c4d1d7784531d3e2a5978b0e4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3827d2e0bcf65100d5ece6725335fe3b5cea50199edb951d4fa8356ad7d326c330342af4df0260cf69bf712d8c33473d059976602268c7a57e2763e8a34da532
|
7
|
+
data.tar.gz: bc2419606befb1ca8a7cff9817b2d4b4bce0612e320e36b389c0257cb3bbca72bc3f603b52f783ea342285ec82b2fb6d97c42bafb3575e72fae4d27fcbc51a69
|
@@ -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
|
|
@@ -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_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_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_version).to_s)
|
143
|
+
|
144
|
+
hash.join("/")
|
145
|
+
end
|
125
146
|
end
|
126
147
|
end
|
127
148
|
end
|
@@ -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
|
@@ -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
|
-
|
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
|
@@ -39,7 +39,7 @@ module Decidim
|
|
39
39
|
.results
|
40
40
|
.published
|
41
41
|
.not_hidden
|
42
|
-
.includes(:
|
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
|
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
|
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
|
144
|
+
redirect_to "#{Decidim::ResourceLocatorPresenter.new(proposal).path}/preview"
|
146
145
|
end
|
147
146
|
|
148
147
|
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? }
|
@@ -13,6 +13,19 @@ module Decidim
|
|
13
13
|
validates :title, :body, translatable_presence: true
|
14
14
|
|
15
15
|
validate :notify_missing_attachment_if_errored
|
16
|
+
|
17
|
+
def map_model(model)
|
18
|
+
super(model)
|
19
|
+
presenter = ProposalPresenter.new(model)
|
20
|
+
|
21
|
+
self.title = presenter.title(all_locales: title.is_a?(Hash))
|
22
|
+
self.body = presenter.body(all_locales: body.is_a?(Hash))
|
23
|
+
self.attachment = if model.documents.first.present?
|
24
|
+
{ file: model.documents.first.file, title: translated_attribute(model.documents.first.title) }
|
25
|
+
else
|
26
|
+
{}
|
27
|
+
end
|
28
|
+
end
|
16
29
|
end
|
17
30
|
end
|
18
31
|
end
|