decidim-proposals 0.19.1 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/admin/decidim_proposals_manifest.js +1 -0
- data/app/assets/images/decidim/gamification/badges/accepted_proposals.svg +1 -234
- data/app/assets/images/decidim/gamification/badges/proposal_votes.svg +1 -95
- data/app/assets/images/decidim/gamification/badges/proposals.svg +1 -229
- data/app/assets/images/decidim/proposals/icon.svg +1 -3
- data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +6 -0
- data/app/assets/javascripts/decidim/proposals/admin/proposals.es6 +24 -11
- data/app/assets/javascripts/decidim/proposals/admin/proposals_form.js.es6 +3 -5
- data/app/assets/javascripts/decidim/proposals/admin/proposals_picker.js.es6 +35 -0
- data/app/cells/decidim/proposals/collaborative_draft_cell.rb +1 -1
- data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +1 -1
- data/app/cells/decidim/proposals/collaborative_draft_m/footer.erb +1 -1
- data/app/cells/decidim/proposals/collaborative_draft_m_cell.rb +1 -1
- data/app/cells/decidim/proposals/cost_report/show.erb +35 -0
- data/app/cells/decidim/proposals/cost_report_cell.rb +42 -0
- data/app/cells/decidim/proposals/highlighted_proposals_for_component/show.erb +3 -3
- data/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb +1 -1
- data/app/cells/decidim/proposals/irreversible_action_modal/show.erb +2 -2
- data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +1 -1
- data/app/cells/decidim/proposals/participatory_text_proposal/buttons.erb +3 -3
- data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +2 -2
- data/app/cells/decidim/proposals/proposal_cell.rb +1 -1
- data/app/cells/decidim/proposals/proposal_m/footer.erb +4 -1
- data/app/cells/decidim/proposals/proposal_m_cell.rb +37 -9
- data/app/cells/decidim/proposals/proposal_tags/show.erb +18 -10
- data/app/cells/decidim/proposals/proposal_tags_cell.rb +5 -0
- data/app/cells/decidim/proposals/proposals_picker/proposals.erb +12 -0
- data/app/cells/decidim/proposals/proposals_picker/show.erb +14 -0
- data/app/cells/decidim/proposals/proposals_picker_cell.rb +72 -0
- data/app/commands/decidim/proposals/admin/answer_proposal.rb +24 -46
- data/app/commands/decidim/proposals/admin/assign_proposals_to_valuator.rb +61 -0
- data/app/commands/decidim/proposals/admin/create_proposal.rb +10 -3
- data/app/commands/decidim/proposals/admin/create_proposal_note.rb +15 -0
- data/app/commands/decidim/proposals/admin/notify_proposal_answer.rb +85 -0
- data/app/commands/decidim/proposals/admin/publish_answers.rb +67 -0
- data/app/commands/decidim/proposals/admin/publish_participatory_text.rb +6 -1
- data/app/commands/decidim/proposals/admin/unassign_proposals_from_valuator.rb +62 -0
- data/app/commands/decidim/proposals/admin/update_participatory_text.rb +10 -2
- data/app/commands/decidim/proposals/admin/update_proposal.rb +5 -3
- data/app/commands/decidim/proposals/admin/update_proposal_scope.rb +75 -0
- data/app/commands/decidim/proposals/create_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/create_proposal.rb +7 -3
- data/app/commands/decidim/proposals/gallery_methods.rb +2 -51
- data/app/commands/decidim/proposals/publish_collaborative_draft.rb +2 -2
- data/app/commands/decidim/proposals/update_proposal.rb +25 -9
- data/app/controllers/concerns/decidim/proposals/admin/filterable.rb +82 -0
- data/app/controllers/concerns/decidim/proposals/admin/picker.rb +21 -0
- data/app/controllers/concerns/decidim/proposals/orderable.rb +13 -2
- data/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +16 -6
- data/app/controllers/decidim/proposals/admin/proposal_notes_controller.rb +8 -9
- data/app/controllers/decidim/proposals/admin/proposals_controller.rb +107 -31
- data/app/controllers/decidim/proposals/admin/valuation_assignments_controller.rb +58 -0
- data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +10 -3
- data/app/controllers/decidim/proposals/proposals_controller.rb +31 -11
- data/app/controllers/decidim/proposals/versions_controller.rb +9 -16
- data/app/controllers/decidim/proposals/{proposal_widgets_controller.rb → widgets_controller.rb} +2 -2
- data/app/events/decidim/proposals/admin/proposal_note_created_event.rb +27 -0
- data/app/events/decidim/proposals/admin/update_proposal_scope_event.rb +11 -0
- data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +3 -1
- data/app/forms/decidim/proposals/admin/participatory_text_proposal_form.rb +20 -0
- data/app/forms/decidim/proposals/admin/preview_participatory_text_form.rb +2 -2
- data/app/forms/decidim/proposals/admin/proposal_answer_form.rb +27 -2
- data/app/forms/decidim/proposals/admin/proposal_base_form.rb +136 -0
- data/app/forms/decidim/proposals/admin/proposal_form.rb +6 -117
- data/app/forms/decidim/proposals/admin/valuation_assignment_form.rb +37 -0
- data/app/forms/decidim/proposals/proposal_form.rb +25 -12
- data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +13 -1
- data/app/helpers/decidim/proposals/admin/filterable_helper.rb +17 -0
- data/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb +35 -0
- data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +63 -0
- data/app/helpers/decidim/proposals/admin/proposals_helper.rb +124 -0
- data/app/helpers/decidim/proposals/admin/proposals_picker_helper.rb +30 -0
- data/app/helpers/decidim/proposals/application_helper.rb +64 -38
- data/app/helpers/decidim/proposals/collaborative_draft_helper.rb +9 -9
- data/app/helpers/decidim/proposals/control_version_helper.rb +1 -37
- data/app/helpers/decidim/proposals/proposal_cells_helper.rb +1 -1
- data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +0 -145
- data/app/helpers/decidim/proposals/proposal_votes_helper.rb +2 -2
- data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +24 -7
- data/app/helpers/decidim/proposals/proposals_helper.rb +66 -0
- data/app/models/decidim/proposals/collaborative_draft.rb +2 -2
- data/app/models/decidim/proposals/participatory_text.rb +3 -0
- data/app/models/decidim/proposals/proposal.rb +153 -42
- data/app/models/decidim/proposals/valuation_assignment.rb +24 -0
- data/app/permissions/decidim/proposals/admin/permissions.rb +77 -11
- data/app/permissions/decidim/proposals/permissions.rb +1 -22
- data/app/presenters/decidim/proposals/admin_log/proposal_presenter.rb +1 -1
- data/app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb +51 -0
- data/app/presenters/decidim/proposals/admin_log/value_types/proposal_title_body_presenter.rb +6 -1
- data/app/presenters/decidim/proposals/admin_log/value_types/valuator_role_user_presenter.rb +19 -0
- data/app/presenters/decidim/proposals/collaborative_draft_presenter.rb +2 -28
- data/app/presenters/decidim/proposals/log/valuation_assignment_presenter.rb +22 -0
- data/app/presenters/decidim/proposals/official_author_presenter.rb +1 -29
- data/app/presenters/decidim/proposals/proposal_presenter.rb +80 -12
- data/app/queries/decidim/proposals/metrics/accepted_proposals_metric_manage.rb +1 -2
- data/app/queries/decidim/proposals/metrics/endorsements_metric_manage.rb +15 -12
- data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +5 -4
- data/app/queries/decidim/proposals/metrics/proposals_metric_manage.rb +2 -8
- data/app/queries/decidim/proposals/metrics/votes_metric_manage.rb +3 -9
- data/app/queries/decidim/proposals/similar_proposals.rb +4 -4
- data/app/services/decidim/proposals/collaborative_draft_search.rb +8 -10
- data/app/services/decidim/proposals/diff_renderer.rb +17 -5
- data/app/services/decidim/proposals/proposal_builder.rb +9 -3
- data/app/services/decidim/proposals/proposal_search.rb +17 -70
- data/app/types/decidim/proposals/proposal_input_filter.rb +29 -0
- data/app/types/decidim/proposals/proposal_input_sort.rb +22 -0
- data/app/types/decidim/proposals/proposal_type.rb +34 -13
- data/app/types/decidim/proposals/proposals_type.rb +22 -15
- data/app/validators/proposal_length_validator.rb +38 -0
- data/app/views/decidim/proposals/admin/participatory_texts/index.html.erb +9 -1
- data/app/views/decidim/proposals/admin/proposal_answers/_form.html.erb +35 -0
- data/app/views/decidim/proposals/admin/proposal_notes/_form.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes.html.erb +3 -3
- data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +8 -2
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +8 -28
- data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +26 -27
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_assign_to_valuator.html.erb +15 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_dropdown.html.erb +21 -1
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_publish_answers.html.erb +14 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_scope-change.html.erb +25 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_unassign_from_valuator.html.erb +15 -0
- data/app/views/decidim/proposals/admin/proposals/index.html.erb +18 -9
- data/app/views/decidim/proposals/admin/proposals/publish_answers.js.erb +12 -0
- data/app/views/decidim/proposals/admin/proposals/show.html.erb +186 -0
- data/app/views/decidim/proposals/admin/proposals/update_category.js.erb +3 -2
- data/app/views/decidim/proposals/admin/proposals/update_scope.js.erb +27 -0
- data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +11 -9
- data/app/views/decidim/proposals/collaborative_drafts/_filters.html.erb +10 -8
- data/app/views/decidim/proposals/collaborative_drafts/_new_collaborative_draft_button.html.erb +4 -4
- data/app/views/decidim/proposals/collaborative_drafts/_reject_request_access_form.html.erb +1 -1
- data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +4 -2
- data/app/views/decidim/proposals/collaborative_drafts/compare.html.erb +2 -0
- data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +2 -0
- data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +3 -1
- data/app/views/decidim/proposals/collaborative_drafts/index.html.erb +4 -2
- data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +4 -0
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +29 -30
- data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +52 -22
- data/app/views/decidim/proposals/proposals/_endorsements_card_row.html.erb +0 -16
- data/app/views/decidim/proposals/proposals/_filters.html.erb +19 -17
- data/app/views/decidim/proposals/proposals/_proposal_badge.html.erb +1 -4
- data/app/views/decidim/proposals/proposals/_proposal_preview.html.erb +1 -11
- data/app/views/decidim/proposals/proposals/_proposal_similar.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_proposals.html.erb +14 -0
- data/app/views/decidim/proposals/proposals/_vote_button.html.erb +14 -7
- data/app/views/decidim/proposals/proposals/_wizard_aside.html.erb +4 -2
- data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +4 -3
- data/app/views/decidim/proposals/proposals/compare.html.erb +2 -0
- data/app/views/decidim/proposals/proposals/complete.html.erb +2 -0
- data/app/views/decidim/proposals/proposals/edit.html.erb +3 -1
- data/app/views/decidim/proposals/proposals/edit_draft.html.erb +2 -0
- data/app/views/decidim/proposals/proposals/index.html.erb +7 -14
- data/app/views/decidim/proposals/proposals/new.html.erb +6 -2
- data/app/views/decidim/proposals/proposals/participatory_texts/_index.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/participatory_texts/_proposal_vote_button.html.erb +10 -3
- data/app/views/decidim/proposals/proposals/participatory_texts/_view_index.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/preview.html.erb +7 -8
- data/app/views/decidim/proposals/proposals/show.html.erb +62 -71
- data/app/views/decidim/proposals/versions/index.html.erb +14 -32
- data/app/views/decidim/proposals/versions/show.html.erb +16 -34
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +73 -67
- data/config/locales/bg-BG.yml +237 -0
- data/config/locales/bg.yml +237 -0
- data/config/locales/ca.yml +183 -67
- data/config/locales/cs.yml +196 -80
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +269 -162
- data/config/locales/el-GR.yml +1 -0
- data/config/locales/el.yml +876 -0
- data/config/locales/en.yml +187 -71
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +181 -65
- data/config/locales/es-PY.yml +181 -65
- data/config/locales/es.yml +186 -70
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +28 -63
- data/config/locales/fi-plain.yml +181 -65
- data/config/locales/fi.yml +219 -103
- data/config/locales/fr-CA.yml +906 -0
- data/config/locales/fr.yml +184 -68
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +28 -63
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +148 -70
- data/config/locales/id-ID.yml +28 -62
- data/config/locales/is-IS.yml +274 -0
- data/config/locales/is.yml +274 -0
- data/config/locales/it.yml +177 -85
- data/config/locales/ja-JP.yml +865 -0
- data/config/locales/ja.yml +889 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +858 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +282 -188
- data/config/locales/no.yml +586 -19
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +524 -393
- data/config/locales/pt-BR.yml +29 -67
- data/config/locales/pt.yml +438 -331
- data/config/locales/ro-RO.yml +841 -0
- data/config/locales/ru.yml +14 -47
- data/config/locales/sk-SK.yml +896 -0
- data/config/locales/sk.yml +869 -0
- data/config/locales/sl.yml +26 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +126 -0
- data/config/locales/sv.yml +285 -171
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +28 -63
- data/config/locales/uk.yml +14 -47
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +885 -0
- data/config/locales/zh-TW.yml +1 -0
- data/db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb +4 -0
- data/db/migrate/20191206154128_add_endorsements_counter_cache_to_proposals.rb +7 -0
- data/db/migrate/20200120215928_move_proposal_endorsements_to_core_endorsements.rb +54 -0
- data/db/migrate/20200120230130_drop_proposal_endorsements.rb +8 -0
- data/db/migrate/20200203111239_add_proposal_valuation_assignments.rb +12 -0
- data/db/migrate/20200210135152_add_costs_to_proposals.rb +9 -0
- data/db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb +28 -0
- data/db/migrate/20200227175922_add_state_published_at_to_proposals.rb +7 -0
- data/db/migrate/20200306123652_publish_existing_proposals_state.rb +15 -0
- data/db/migrate/20200708091228_move_proposals_fields_to_i18n.rb +80 -0
- data/db/migrate/20200730131631_move_proposal_endorsed_event_notifications_to_resource_endorsed_event.rb +20 -0
- data/db/migrate/20200827154156_add_commentable_counter_cache_to_proposals.rb +12 -0
- data/db/migrate/20200915151348_fix_proposals_data_to_ensure_title_and_body_are_hashes.rb +37 -0
- data/db/migrate/20201002085508_fix_proposals_data.rb +37 -0
- data/lib/decidim/content_renderers/proposal_renderer.rb +3 -1
- data/lib/decidim/proposals.rb +1 -0
- data/lib/decidim/proposals/admin_engine.rb +7 -3
- data/lib/decidim/proposals/component.rb +55 -28
- data/lib/decidim/proposals/engine.rb +3 -7
- data/lib/decidim/proposals/markdown_to_proposals.rb +2 -2
- data/lib/decidim/proposals/proposal_serializer.rb +3 -3
- data/lib/decidim/proposals/test/capybara_proposals_picker.rb +49 -0
- data/lib/decidim/proposals/test/factories.rb +100 -28
- data/lib/decidim/proposals/valuatable.rb +21 -0
- data/lib/decidim/proposals/version.rb +1 -1
- metadata +119 -54
- data/app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6 +0 -56
- data/app/cells/decidim/proposals/endorsers_list/show.erb +0 -17
- data/app/cells/decidim/proposals/endorsers_list_cell.rb +0 -31
- data/app/commands/decidim/proposals/attachment_methods.rb +0 -43
- data/app/commands/decidim/proposals/endorse_proposal.rb +0 -59
- data/app/commands/decidim/proposals/unendorse_proposal.rb +0 -40
- data/app/controllers/decidim/proposals/proposal_endorsements_controller.rb +0 -60
- data/app/models/decidim/proposals/proposal_endorsement.rb +0 -37
- data/app/views/decidim/proposals/admin/proposal_answers/edit.html.erb +0 -22
- data/app/views/decidim/proposals/admin/proposal_notes/index.html.erb +0 -3
- data/app/views/decidim/proposals/admin/shared/_info_proposal.html.erb +0 -20
- data/app/views/decidim/proposals/proposal_endorsements/_identity.html.erb +0 -9
- data/app/views/decidim/proposals/proposal_endorsements/identities.html.erb +0 -12
- data/app/views/decidim/proposals/proposal_endorsements/update_buttons_and_counters.js.erb +0 -20
- data/app/views/decidim/proposals/proposal_widgets/show.html.erb +0 -4
- data/app/views/decidim/proposals/proposals/_endorsement_button.html.erb +0 -11
- data/app/views/decidim/proposals/proposals/_endorsement_identities_cabin.html.erb +0 -13
- data/app/views/decidim/proposals/versions/_version.html.erb +0 -20
@@ -10,6 +10,7 @@ module Decidim
|
|
10
10
|
|
11
11
|
include Decidim::ApplicationHelper
|
12
12
|
include FormFactory
|
13
|
+
include Flaggable
|
13
14
|
include FilterResource
|
14
15
|
include CollaborativeOrderable
|
15
16
|
include Paginable
|
@@ -171,12 +172,18 @@ module Decidim
|
|
171
172
|
def default_filter_params
|
172
173
|
{
|
173
174
|
search_text: "",
|
174
|
-
category_id:
|
175
|
-
state:
|
176
|
-
scope_id:
|
175
|
+
category_id: default_filter_category_params,
|
176
|
+
state: %w(open),
|
177
|
+
scope_id: default_filter_scope_params,
|
177
178
|
related_to: ""
|
178
179
|
}
|
179
180
|
end
|
181
|
+
|
182
|
+
def default_filter_category_params
|
183
|
+
return unless current_component.participatory_space.categories.any?
|
184
|
+
|
185
|
+
["without"] + current_component.participatory_space.categories.map { |category| category.id.to_s }
|
186
|
+
end
|
180
187
|
end
|
181
188
|
end
|
182
189
|
end
|
@@ -8,12 +8,14 @@ module Decidim
|
|
8
8
|
helper ProposalWizardHelper
|
9
9
|
helper ParticipatoryTextsHelper
|
10
10
|
include Decidim::ApplicationHelper
|
11
|
+
include Flaggable
|
12
|
+
include Withdrawable
|
11
13
|
include FormFactory
|
12
14
|
include FilterResource
|
13
15
|
include Decidim::Proposals::Orderable
|
14
16
|
include Paginable
|
15
17
|
|
16
|
-
helper_method :form_presenter
|
18
|
+
helper_method :proposal_presenter, :form_presenter
|
17
19
|
|
18
20
|
before_action :authenticate_user!, only: [:new, :create, :complete]
|
19
21
|
before_action :ensure_is_draft, only: [:compare, :complete, :preview, :publish, :edit_draft, :update_draft, :destroy_draft]
|
@@ -37,8 +39,7 @@ module Decidim
|
|
37
39
|
.results
|
38
40
|
.published
|
39
41
|
.not_hidden
|
40
|
-
.includes(:category)
|
41
|
-
.includes(:scope)
|
42
|
+
.includes(:amendable, :category, :component, :resource_permission, :scope)
|
42
43
|
|
43
44
|
@voted_proposals = if current_user
|
44
45
|
ProposalVote.where(
|
@@ -65,14 +66,14 @@ module Decidim
|
|
65
66
|
if proposal_draft.present?
|
66
67
|
redirect_to edit_draft_proposal_path(proposal_draft, component_id: proposal_draft.component.id, question_slug: proposal_draft.component.participatory_space.slug)
|
67
68
|
else
|
68
|
-
@form = form(ProposalWizardCreateStepForm).from_params(
|
69
|
+
@form = form(ProposalWizardCreateStepForm).from_params(body: translated_proposal_body_template)
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
72
73
|
def create
|
73
74
|
enforce_permission_to :create, :proposal
|
74
75
|
@step = :step_1
|
75
|
-
@form = form(ProposalWizardCreateStepForm).from_params(
|
76
|
+
@form = form(ProposalWizardCreateStepForm).from_params(proposal_creation_params)
|
76
77
|
|
77
78
|
CreateProposal.call(@form, current_user) do
|
78
79
|
on(:ok) do |proposal|
|
@@ -212,16 +213,23 @@ module Decidim
|
|
212
213
|
def default_filter_params
|
213
214
|
{
|
214
215
|
search_text: "",
|
215
|
-
origin:
|
216
|
-
activity: "",
|
217
|
-
category_id:
|
218
|
-
state:
|
219
|
-
scope_id:
|
216
|
+
origin: default_filter_origin_params,
|
217
|
+
activity: "all",
|
218
|
+
category_id: default_filter_category_params,
|
219
|
+
state: %w(accepted evaluating state_not_published),
|
220
|
+
scope_id: default_filter_scope_params,
|
220
221
|
related_to: "",
|
221
222
|
type: "all"
|
222
223
|
}
|
223
224
|
end
|
224
225
|
|
226
|
+
def default_filter_origin_params
|
227
|
+
filter_origin_params = %w(citizens meeting)
|
228
|
+
filter_origin_params << "official" if component_settings.official_proposals_enabled
|
229
|
+
filter_origin_params << "user_group" if current_organization.user_groups_enabled?
|
230
|
+
filter_origin_params
|
231
|
+
end
|
232
|
+
|
225
233
|
def proposal_draft
|
226
234
|
Proposal.from_all_author_identities(current_user).not_hidden.only_amendables
|
227
235
|
.where(component: current_component).find_by(published_at: nil)
|
@@ -245,6 +253,10 @@ module Decidim
|
|
245
253
|
Proposal.only_visible_emendations_for(current_user, current_component).published.include?(@proposal)
|
246
254
|
end
|
247
255
|
|
256
|
+
def proposal_presenter
|
257
|
+
@proposal_presenter ||= present(@proposal)
|
258
|
+
end
|
259
|
+
|
248
260
|
def form_proposal_params
|
249
261
|
form(ProposalForm).from_params(params)
|
250
262
|
end
|
@@ -258,7 +270,7 @@ module Decidim
|
|
258
270
|
end
|
259
271
|
|
260
272
|
def form_attachment_new
|
261
|
-
form(AttachmentForm).
|
273
|
+
form(AttachmentForm).from_model(Attachment.new)
|
262
274
|
end
|
263
275
|
|
264
276
|
def edit_form
|
@@ -271,6 +283,14 @@ module Decidim
|
|
271
283
|
def set_participatory_text
|
272
284
|
@participatory_text = Decidim::Proposals::ParticipatoryText.find_by(component: current_component)
|
273
285
|
end
|
286
|
+
|
287
|
+
def translated_proposal_body_template
|
288
|
+
translated_attribute component_settings.new_proposal_body_template
|
289
|
+
end
|
290
|
+
|
291
|
+
def proposal_creation_params
|
292
|
+
params[:proposal].merge(body_template: translated_proposal_body_template)
|
293
|
+
end
|
274
294
|
end
|
275
295
|
end
|
276
296
|
end
|
@@ -5,23 +5,16 @@ module Decidim
|
|
5
5
|
# Exposes Proposals versions so users can see how a Proposal/CollaborativeDraft
|
6
6
|
# has been updated through time.
|
7
7
|
class VersionsController < Decidim::Proposals::ApplicationController
|
8
|
-
|
9
|
-
|
8
|
+
include Decidim::ApplicationHelper
|
9
|
+
include Decidim::ResourceVersionsConcern
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def current_version
|
22
|
-
return nil unless params[:id].to_i.positive?
|
23
|
-
|
24
|
-
@current_version ||= item.versions[params[:id].to_i - 1]
|
11
|
+
def versioned_resource
|
12
|
+
@versioned_resource ||=
|
13
|
+
if params[:proposal_id]
|
14
|
+
present(Proposal.where(component: current_component).find(params[:proposal_id]))
|
15
|
+
else
|
16
|
+
CollaborativeDraft.where(component: current_component).find(params[:collaborative_draft_id])
|
17
|
+
end
|
25
18
|
end
|
26
19
|
end
|
27
20
|
end
|
data/app/controllers/decidim/proposals/{proposal_widgets_controller.rb → widgets_controller.rb}
RENAMED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Proposals
|
5
|
-
class
|
5
|
+
class WidgetsController < Decidim::WidgetsController
|
6
6
|
helper Proposals::ApplicationHelper
|
7
7
|
|
8
8
|
private
|
@@ -12,7 +12,7 @@ module Decidim
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def iframe_url
|
15
|
-
@iframe_url ||=
|
15
|
+
@iframe_url ||= proposal_widget_url(model)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen-string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module Admin
|
6
|
+
class ProposalNoteCreatedEvent < Decidim::Events::SimpleEvent
|
7
|
+
include Rails.application.routes.mounted_helpers
|
8
|
+
|
9
|
+
i18n_attributes :admin_proposal_info_url, :admin_proposal_info_path
|
10
|
+
|
11
|
+
def admin_proposal_info_path
|
12
|
+
ResourceLocatorPresenter.new(resource).show
|
13
|
+
end
|
14
|
+
|
15
|
+
def admin_proposal_info_url
|
16
|
+
decidim_admin_participatory_process_proposals.proposal_url(resource, resource.component.mounted_params)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def organization
|
22
|
+
@organization ||= component.participatory_space.organization
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -8,6 +8,8 @@ module Decidim
|
|
8
8
|
class ImportParticipatoryTextForm < Decidim::Form
|
9
9
|
include TranslatableAttributes
|
10
10
|
|
11
|
+
# WARNING: consider adding/removing the relative translation key at
|
12
|
+
# decidim.assemblies.admin.new_import.accepted_types when modifying this hash
|
11
13
|
ACCEPTED_MIME_TYPES = Decidim::Proposals::DocToMarkdown::ACCEPTED_MIME_TYPES
|
12
14
|
|
13
15
|
translatable_attribute :title, String
|
@@ -33,7 +35,7 @@ module Decidim
|
|
33
35
|
|
34
36
|
# Return ACCEPTED_MIME_TYPES plus `text/plain` for better markdown support
|
35
37
|
def valid_mime_types
|
36
|
-
ACCEPTED_MIME_TYPES.values + [Decidim::Proposals::DocToMarkdown::TEXT_PLAIN_MIME_TYPE]
|
38
|
+
ACCEPTED_MIME_TYPES.values + [Decidim::Proposals::DocToMarkdown::TEXT_PLAIN_MIME_TYPE] + ["application/octet-stream"]
|
37
39
|
end
|
38
40
|
|
39
41
|
def document_type
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module Admin
|
6
|
+
# A form object to be used when admin users want to create a proposal
|
7
|
+
# through the participatory texts.
|
8
|
+
class ParticipatoryTextProposalForm < Admin::ProposalBaseForm
|
9
|
+
attribute :title, String
|
10
|
+
attribute :body, String
|
11
|
+
validates :title, length: { maximum: 150 }, presence: true
|
12
|
+
|
13
|
+
def map_model(model)
|
14
|
+
self.title = translated_attribute(model.title)
|
15
|
+
self.body = translated_attribute(model.body)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,11 +6,11 @@ module Decidim
|
|
6
6
|
# A form object to be used when admin users want to review a collection of proposals
|
7
7
|
# from a participatory text.
|
8
8
|
class PreviewParticipatoryTextForm < Decidim::Form
|
9
|
-
attribute :proposals, Array[Decidim::Proposals::Admin::
|
9
|
+
attribute :proposals, Array[Decidim::Proposals::Admin::ParticipatoryTextProposalForm]
|
10
10
|
|
11
11
|
def from_models(proposals)
|
12
12
|
self.proposals = proposals.collect do |proposal|
|
13
|
-
|
13
|
+
Admin::ParticipatoryTextProposalForm.from_model(proposal)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -9,10 +9,35 @@ module Decidim
|
|
9
9
|
mimic :proposal_answer
|
10
10
|
|
11
11
|
translatable_attribute :answer, String
|
12
|
-
|
12
|
+
translatable_attribute :cost_report, String
|
13
|
+
translatable_attribute :execution_period, String
|
14
|
+
attribute :cost, Float
|
15
|
+
attribute :internal_state, String
|
13
16
|
|
14
|
-
validates :
|
17
|
+
validates :internal_state, presence: true, inclusion: { in: %w(accepted rejected evaluating) }
|
15
18
|
validates :answer, translatable_presence: true, if: ->(form) { form.state == "rejected" }
|
19
|
+
|
20
|
+
with_options if: :costs_required? do
|
21
|
+
validates :cost, numericality: true, presence: true
|
22
|
+
validates :cost_report, translatable_presence: true
|
23
|
+
validates :execution_period, translatable_presence: true
|
24
|
+
end
|
25
|
+
|
26
|
+
alias state internal_state
|
27
|
+
|
28
|
+
def costs_required?
|
29
|
+
costs_enabled? && state == "accepted"
|
30
|
+
end
|
31
|
+
|
32
|
+
def publish_answer?
|
33
|
+
current_component.current_settings.publish_answers_immediately?
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def costs_enabled?
|
39
|
+
current_component.current_settings.answers_with_costs?
|
40
|
+
end
|
16
41
|
end
|
17
42
|
end
|
18
43
|
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module Admin
|
6
|
+
# A form object to be used when admin users want to create a proposal.
|
7
|
+
class ProposalBaseForm < Decidim::Form
|
8
|
+
include Decidim::TranslatableAttributes
|
9
|
+
include Decidim::ApplicationHelper
|
10
|
+
|
11
|
+
mimic :proposal
|
12
|
+
|
13
|
+
attribute :address, String
|
14
|
+
attribute :latitude, Float
|
15
|
+
attribute :longitude, Float
|
16
|
+
attribute :category_id, Integer
|
17
|
+
attribute :scope_id, Integer
|
18
|
+
attribute :attachment, AttachmentForm
|
19
|
+
attribute :position, Integer
|
20
|
+
attribute :created_in_meeting, Boolean
|
21
|
+
attribute :meeting_id, Integer
|
22
|
+
attribute :suggested_hashtags, Array[String]
|
23
|
+
attribute :photos, Array[String]
|
24
|
+
attribute :add_photos, Array
|
25
|
+
|
26
|
+
validates :address, geocoding: true, if: ->(form) { form.has_address? && !form.geocoded? }
|
27
|
+
validates :category, presence: true, if: ->(form) { form.category_id.present? }
|
28
|
+
validates :scope, presence: true, if: ->(form) { form.scope_id.present? }
|
29
|
+
validates :scope_id, scope_belongs_to_component: true, if: ->(form) { form.scope_id.present? }
|
30
|
+
validates :meeting_as_author, presence: true, if: ->(form) { form.created_in_meeting? }
|
31
|
+
|
32
|
+
validate :notify_missing_attachment_if_errored
|
33
|
+
|
34
|
+
delegate :categories, to: :current_component
|
35
|
+
|
36
|
+
def map_model(model)
|
37
|
+
body = translated_attribute(model.body)
|
38
|
+
@suggested_hashtags = Decidim::ContentRenderers::HashtagRenderer.new(body).extra_hashtags.map(&:name).map(&:downcase)
|
39
|
+
|
40
|
+
return unless model.categorization
|
41
|
+
|
42
|
+
self.category_id = model.categorization.decidim_category_id
|
43
|
+
self.scope_id = model.decidim_scope_id
|
44
|
+
end
|
45
|
+
|
46
|
+
alias component current_component
|
47
|
+
|
48
|
+
# Finds the Category from the category_id.
|
49
|
+
#
|
50
|
+
# Returns a Decidim::Category
|
51
|
+
def category
|
52
|
+
@category ||= categories.find_by(id: category_id)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
|
56
|
+
#
|
57
|
+
# Returns a Decidim::Scope
|
58
|
+
def scope
|
59
|
+
@scope ||= @scope_id ? current_component.scopes.find_by(id: @scope_id) : current_component.scope
|
60
|
+
end
|
61
|
+
|
62
|
+
# Scope identifier
|
63
|
+
#
|
64
|
+
# Returns the scope identifier related to the proposal
|
65
|
+
def scope_id
|
66
|
+
@scope_id || scope&.id
|
67
|
+
end
|
68
|
+
|
69
|
+
def geocoding_enabled?
|
70
|
+
Decidim::Map.available?(:geocoding) && current_component.settings.geocoding_enabled?
|
71
|
+
end
|
72
|
+
|
73
|
+
def has_address?
|
74
|
+
geocoding_enabled? && address.present?
|
75
|
+
end
|
76
|
+
|
77
|
+
def geocoded?
|
78
|
+
latitude.present? && longitude.present?
|
79
|
+
end
|
80
|
+
|
81
|
+
# Finds the Meetings of the current participatory space
|
82
|
+
def meetings
|
83
|
+
@meetings ||= Decidim.find_resource_manifest(:meetings).try(:resource_scope, current_component)
|
84
|
+
&.order(title: :asc)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Return the meeting as author
|
88
|
+
def meeting_as_author
|
89
|
+
@meeting_as_author ||= meetings.find_by(id: meeting_id)
|
90
|
+
end
|
91
|
+
|
92
|
+
def author
|
93
|
+
return current_organization unless created_in_meeting?
|
94
|
+
|
95
|
+
meeting_as_author
|
96
|
+
end
|
97
|
+
|
98
|
+
def extra_hashtags
|
99
|
+
@extra_hashtags ||= (component_automatic_hashtags + suggested_hashtags).uniq
|
100
|
+
end
|
101
|
+
|
102
|
+
def suggested_hashtags
|
103
|
+
downcased_suggested_hashtags = Array(@suggested_hashtags&.map(&:downcase)).to_set
|
104
|
+
component_suggested_hashtags.select { |hashtag| downcased_suggested_hashtags.member?(hashtag.downcase) }
|
105
|
+
end
|
106
|
+
|
107
|
+
def suggested_hashtag_checked?(hashtag)
|
108
|
+
suggested_hashtags.member?(hashtag)
|
109
|
+
end
|
110
|
+
|
111
|
+
def component_automatic_hashtags
|
112
|
+
@component_automatic_hashtags ||= ordered_hashtag_list(current_component.current_settings.automatic_hashtags)
|
113
|
+
end
|
114
|
+
|
115
|
+
def component_suggested_hashtags
|
116
|
+
@component_suggested_hashtags ||= ordered_hashtag_list(current_component.current_settings.suggested_hashtags)
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
# This method will add an error to the `attachment` field only if there's
|
122
|
+
# any error in any other field. This is needed because when the form has
|
123
|
+
# an error, the attachment is lost, so we need a way to inform the user of
|
124
|
+
# this problem.
|
125
|
+
def notify_missing_attachment_if_errored
|
126
|
+
errors.add(:attachment, :needs_to_be_reattached) if errors.any? && attachment.present?
|
127
|
+
errors.add(:add_photos, :needs_to_be_reattached) if errors.any? && add_photos.present?
|
128
|
+
end
|
129
|
+
|
130
|
+
def ordered_hashtag_list(string)
|
131
|
+
string.to_s.split.reject(&:blank?).uniq.sort_by(&:parameterize)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|