decidim-proposals 0.27.8 → 0.28.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/proposals/collaborative_draft_cell.rb +1 -1
- data/app/cells/decidim/proposals/collaborative_draft_l_cell.rb +16 -0
- data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal/show.erb +4 -12
- data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +0 -29
- data/app/cells/decidim/proposals/collaborative_draft_metadata_cell.rb +30 -0
- data/app/cells/decidim/proposals/content_blocks/highlighted_proposals_cell.rb +2 -8
- data/app/cells/decidim/proposals/cost_report/show.erb +5 -34
- data/app/cells/decidim/proposals/cost_report_cell.rb +0 -13
- data/app/cells/decidim/proposals/highlighted_proposals_for_component/show.erb +29 -17
- data/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb +34 -8
- data/app/cells/decidim/proposals/irreversible_action_modal/show.erb +9 -17
- data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +7 -9
- data/app/cells/decidim/proposals/participatory_text_proposal/buttons.erb +21 -31
- data/app/cells/decidim/proposals/participatory_text_proposal/show.erb +5 -9
- data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +0 -9
- data/app/cells/decidim/proposals/proposal_activity_cell.rb +1 -12
- data/app/cells/decidim/proposals/proposal_cell.rb +6 -1
- data/app/cells/decidim/proposals/proposal_l_cell.rb +47 -0
- data/app/cells/decidim/proposals/proposal_link_to_collaborative_draft_cell.rb +6 -4
- data/app/cells/decidim/proposals/proposal_link_to_rejected_emendation_cell.rb +9 -7
- data/app/cells/decidim/proposals/proposal_linked_resources/show.erb +3 -8
- data/app/cells/decidim/proposals/proposal_metadata_cell.rb +61 -0
- data/app/cells/decidim/proposals/proposal_s_cell.rb +21 -0
- data/app/cells/decidim/proposals/proposals_picker/show.erb +13 -13
- data/app/cells/decidim/proposals/proposals_picker_cell.rb +15 -38
- data/app/commands/decidim/proposals/accept_access_to_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/admin/answer_proposal.rb +1 -1
- data/app/commands/decidim/proposals/admin/assign_proposals_to_valuator.rb +3 -3
- data/app/commands/decidim/proposals/admin/create_proposal.rb +2 -2
- data/app/commands/decidim/proposals/admin/create_proposal_note.rb +4 -4
- data/app/commands/decidim/proposals/admin/discard_participatory_text.rb +1 -1
- data/app/commands/decidim/proposals/admin/import_participatory_text.rb +1 -1
- data/app/commands/decidim/proposals/admin/import_proposals.rb +2 -13
- data/app/commands/decidim/proposals/admin/merge_proposals.rb +1 -1
- data/app/commands/decidim/proposals/admin/notify_proposal_answer.rb +3 -3
- data/app/commands/decidim/proposals/admin/publish_answers.rb +1 -1
- data/app/commands/decidim/proposals/admin/publish_participatory_text.rb +2 -2
- data/app/commands/decidim/proposals/admin/split_proposals.rb +1 -1
- data/app/commands/decidim/proposals/admin/unassign_proposals_from_valuator.rb +2 -2
- data/app/commands/decidim/proposals/admin/update_participatory_text.rb +1 -1
- data/app/commands/decidim/proposals/admin/update_proposal.rb +5 -1
- data/app/commands/decidim/proposals/admin/update_proposal_scope.rb +1 -1
- data/app/commands/decidim/proposals/create_collaborative_draft.rb +13 -3
- data/app/commands/decidim/proposals/create_proposal.rb +14 -5
- data/app/commands/decidim/proposals/hashtags_methods.rb +1 -1
- data/app/commands/decidim/proposals/publish_proposal.rb +1 -1
- data/app/commands/decidim/proposals/reject_access_to_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/request_access_to_collaborative_draft.rb +1 -1
- data/app/commands/decidim/proposals/unvote_proposal.rb +2 -2
- data/app/commands/decidim/proposals/update_collaborative_draft.rb +12 -2
- data/app/commands/decidim/proposals/update_proposal.rb +16 -14
- data/app/commands/decidim/proposals/vote_proposal.rb +2 -2
- data/app/controllers/concerns/decidim/proposals/admin/filterable.rb +4 -13
- data/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +2 -2
- data/app/controllers/decidim/proposals/admin/proposal_notes_controller.rb +1 -1
- data/app/controllers/decidim/proposals/admin/proposals_controller.rb +2 -2
- data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +3 -9
- data/app/controllers/decidim/proposals/proposal_votes_controller.rb +3 -3
- data/app/controllers/decidim/proposals/proposals_controller.rb +42 -12
- data/app/events/decidim/proposals/accepted_proposal_event.rb +1 -1
- data/app/events/decidim/proposals/admin/proposal_note_created_event.rb +1 -1
- data/app/events/decidim/proposals/admin/update_proposal_category_event.rb +1 -1
- data/app/events/decidim/proposals/admin/update_proposal_scope_event.rb +1 -1
- data/app/events/decidim/proposals/collaborative_draft_access_accepted_event.rb +1 -1
- data/app/events/decidim/proposals/collaborative_draft_access_rejected_event.rb +1 -1
- data/app/events/decidim/proposals/collaborative_draft_access_request_event.rb +1 -1
- data/app/events/decidim/proposals/collaborative_draft_access_requested_event.rb +1 -1
- data/app/events/decidim/proposals/collaborative_draft_access_requester_accepted_event.rb +1 -1
- data/app/events/decidim/proposals/collaborative_draft_access_requester_rejected_event.rb +1 -1
- data/app/events/decidim/proposals/collaborative_draft_withdrawn_event.rb +1 -1
- data/app/events/decidim/proposals/evaluating_proposal_event.rb +1 -1
- data/app/events/decidim/proposals/proposal_endorsed_event.rb +1 -1
- data/app/events/decidim/proposals/proposal_mentioned_event.rb +1 -1
- data/app/events/decidim/proposals/publish_proposal_event.rb +1 -1
- data/app/events/decidim/proposals/rejected_proposal_event.rb +1 -1
- data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +1 -1
- data/app/forms/decidim/proposals/admin/proposal_base_form.rb +2 -2
- data/app/forms/decidim/proposals/admin/proposal_form.rb +1 -1
- data/app/forms/decidim/proposals/admin/proposals_fork_form.rb +1 -1
- data/app/forms/decidim/proposals/admin/valuation_assignment_form.rb +1 -1
- data/app/forms/decidim/proposals/proposal_form.rb +9 -27
- data/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb +1 -1
- data/app/helpers/decidim/proposals/admin/proposals_helper.rb +13 -13
- data/app/helpers/decidim/proposals/application_helper.rb +80 -28
- data/app/helpers/decidim/proposals/collaborative_draft_helper.rb +44 -4
- data/app/helpers/decidim/proposals/map_helper.rb +3 -4
- data/app/helpers/decidim/proposals/participatory_texts_helper.rb +1 -9
- data/app/helpers/decidim/proposals/proposal_cells_helper.rb +1 -1
- data/app/helpers/decidim/proposals/proposal_votes_helper.rb +2 -24
- data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +14 -81
- data/app/helpers/decidim/proposals/proposals_helper.rb +0 -12
- data/app/jobs/decidim/proposals/hide_all_created_by_author_job.rb +20 -0
- data/app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb +1 -1
- data/app/jobs/decidim/proposals/settings_change_job.rb +2 -2
- data/app/models/decidim/proposals/collaborative_draft.rb +4 -16
- data/app/models/decidim/proposals/proposal.rb +33 -16
- data/app/models/decidim/proposals/proposal_vote.rb +3 -3
- data/app/models/decidim/proposals/valuation_assignment.rb +1 -2
- data/app/packs/documents/decidim/proposals/participatory_texts/participatory_text.md +9 -4
- data/app/packs/entrypoints/decidim_proposals.js +4 -0
- data/app/packs/entrypoints/decidim_proposals_admin.js +0 -1
- data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_accepted_proposals.svg +68 -1
- data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_proposal_votes.svg +34 -1
- data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_proposals.svg +64 -1
- data/app/packs/src/decidim/proposals/add_proposal.js +25 -39
- data/app/packs/src/decidim/proposals/admin/proposals.js +0 -7
- data/app/packs/src/decidim/proposals/choose_proposals.js +20 -0
- data/app/packs/stylesheets/decidim/proposals/proposals.scss +97 -0
- data/app/permissions/decidim/proposals/admin/permissions.rb +3 -3
- data/app/permissions/decidim/proposals/permissions.rb +1 -10
- data/app/presenters/decidim/proposals/admin_log/proposal_note_presenter.rb +2 -2
- data/app/presenters/decidim/proposals/admin_log/proposal_presenter.rb +7 -3
- data/app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb +2 -2
- data/app/presenters/decidim/proposals/admin_log/value_types/proposal_title_body_presenter.rb +3 -1
- data/app/presenters/decidim/proposals/log/resource_presenter.rb +22 -0
- data/app/presenters/decidim/proposals/log/valuation_assignment_presenter.rb +1 -1
- data/app/presenters/decidim/proposals/proposal_presenter.rb +6 -2
- data/app/services/decidim/proposals/diff_renderer.rb +3 -3
- data/app/services/decidim/proposals/proposal_builder.rb +6 -6
- data/app/views/decidim/proposals/admin/participatory_texts/_article-preview.html.erb +2 -4
- data/app/views/decidim/proposals/admin/participatory_texts/_bulk-actions.html.erb +2 -2
- data/app/views/decidim/proposals/admin/participatory_texts/index.html.erb +58 -46
- data/app/views/decidim/proposals/admin/participatory_texts/new_import.html.erb +31 -33
- data/app/views/decidim/proposals/admin/proposal_answers/_form.html.erb +17 -11
- data/app/views/decidim/proposals/admin/proposal_notes/_form.html.erb +5 -6
- data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes.html.erb +28 -36
- data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +27 -30
- data/app/views/decidim/proposals/admin/proposals/_documents.html.erb +13 -0
- data/app/views/decidim/proposals/admin/proposals/_endorsers.html.erb +25 -0
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +70 -90
- data/app/views/decidim/proposals/admin/proposals/_meetings.html.erb +13 -0
- data/app/views/decidim/proposals/admin/proposals/_photos.html.erb +13 -0
- data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +31 -25
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_assign_to_valuator.html.erb +3 -3
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_dropdown.html.erb +3 -2
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_merge.html.erb +4 -4
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_publish_answers.html.erb +3 -3
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_recategorize.html.erb +3 -3
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_scope-change.html.erb +4 -8
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_split.html.erb +3 -3
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_unassign_from_valuator.html.erb +3 -3
- data/app/views/decidim/proposals/admin/proposals/edit.html.erb +17 -7
- data/app/views/decidim/proposals/admin/proposals/index.html.erb +50 -63
- data/app/views/decidim/proposals/admin/proposals/new.html.erb +16 -6
- data/app/views/decidim/proposals/admin/proposals/publish_answers.js.erb +2 -2
- data/app/views/decidim/proposals/admin/proposals/show.html.erb +204 -162
- data/app/views/decidim/proposals/admin/proposals/update_attribute.js.erb +5 -6
- data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +48 -34
- data/app/views/decidim/proposals/collaborative_drafts/_accept_request_access_form.html.erb +1 -1
- data/app/views/decidim/proposals/collaborative_drafts/_actions.html.erb +7 -0
- data/app/views/decidim/proposals/collaborative_drafts/_collaborative_draft_aside.html.erb +53 -0
- data/app/views/decidim/proposals/collaborative_drafts/_collaborative_drafts.html.erb +12 -13
- data/app/views/decidim/proposals/collaborative_drafts/_collaborator_requests.html.erb +8 -12
- data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +26 -54
- data/app/views/decidim/proposals/collaborative_drafts/_reject_request_access_form.html.erb +1 -3
- data/app/views/decidim/proposals/collaborative_drafts/_request_access_form.html.erb +1 -1
- data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +23 -25
- data/app/views/decidim/proposals/collaborative_drafts/index.html.erb +30 -22
- data/app/views/decidim/proposals/collaborative_drafts/index.js.erb +0 -5
- data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +22 -18
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +39 -109
- data/app/views/decidim/proposals/proposal_votes/update_buttons_and_counters.js.erb +2 -2
- data/app/views/decidim/proposals/proposals/_actions.html.erb +13 -0
- data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +31 -70
- data/app/views/decidim/proposals/proposals/_linked_proposals.html.erb +3 -35
- data/app/views/decidim/proposals/proposals/_proposal_aside.html.erb +40 -0
- data/app/views/decidim/proposals/proposals/_proposals.html.erb +18 -39
- data/app/views/decidim/proposals/proposals/_proposals_picker.html.erb +5 -0
- data/app/views/decidim/proposals/proposals/_remaining_votes_count.html.erb +3 -3
- data/app/views/decidim/proposals/proposals/_vote_button.html.erb +16 -17
- data/app/views/decidim/proposals/proposals/_votes_count.html.erb +3 -6
- data/app/views/decidim/proposals/proposals/_voting_rules.html.erb +28 -41
- data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +19 -25
- data/app/views/decidim/proposals/proposals/compare.html.erb +17 -16
- data/app/views/decidim/proposals/proposals/complete.html.erb +26 -21
- data/app/views/decidim/proposals/proposals/edit.html.erb +32 -27
- data/app/views/decidim/proposals/proposals/edit_draft.html.erb +21 -19
- data/app/views/decidim/proposals/proposals/index.html.erb +56 -47
- data/app/views/decidim/proposals/proposals/index.js.erb +0 -5
- data/app/views/decidim/proposals/proposals/new.html.erb +30 -35
- data/app/views/decidim/proposals/proposals/participatory_texts/_proposal_vote_button.html.erb +5 -5
- data/app/views/decidim/proposals/proposals/participatory_texts/_view_index.html.erb +15 -8
- data/app/views/decidim/proposals/proposals/participatory_texts/participatory_text.html.erb +32 -15
- data/app/views/decidim/proposals/proposals/preview.html.erb +37 -34
- data/app/views/decidim/proposals/proposals/show.html.erb +90 -108
- data/app/views/decidim/proposals/versions/show.html.erb +14 -6
- data/config/assets.rb +0 -1
- data/config/brakeman.ignore +31 -56
- data/config/locales/ar.yml +23 -158
- data/config/locales/bg.yml +1 -776
- data/config/locales/ca.yml +92 -150
- data/config/locales/cs.yml +75 -134
- data/config/locales/de.yml +83 -141
- data/config/locales/el.yml +58 -121
- data/config/locales/en.yml +76 -134
- data/config/locales/es-MX.yml +77 -135
- data/config/locales/es-PY.yml +76 -134
- data/config/locales/es.yml +84 -142
- data/config/locales/eu.yml +75 -133
- data/config/locales/fi-plain.yml +68 -126
- data/config/locales/fi.yml +67 -125
- data/config/locales/fr-CA.yml +73 -132
- data/config/locales/fr.yml +77 -136
- data/config/locales/ga-IE.yml +0 -45
- data/config/locales/gl.yml +12 -131
- data/config/locales/hu.yml +45 -149
- data/config/locales/id-ID.yml +9 -114
- data/config/locales/is-IS.yml +5 -60
- data/config/locales/it.yml +14 -146
- data/config/locales/ja.yml +78 -141
- data/config/locales/lb.yml +0 -5
- data/config/locales/lt.yml +65 -126
- data/config/locales/lv.yml +13 -144
- data/config/locales/nl.yml +16 -148
- data/config/locales/no.yml +11 -134
- data/config/locales/pl.yml +16 -239
- data/config/locales/pt-BR.yml +14 -199
- data/config/locales/pt.yml +11 -142
- data/config/locales/ro-RO.yml +12 -146
- data/config/locales/ru.yml +5 -70
- data/config/locales/sk.yml +19 -145
- data/config/locales/sr-CS.yml +0 -23
- data/config/locales/sv.yml +26 -145
- data/config/locales/tr-TR.yml +16 -150
- data/config/locales/uk.yml +5 -70
- data/config/locales/zh-CN.yml +9 -135
- data/config/locales/zh-TW.yml +35 -107
- data/db/migrate/20170307085300_migrate_proposal_reports_data_to_reports.rb +1 -1
- data/db/migrate/20230427105700_change_states_on_collaborative_drafts.rb +34 -0
- data/db/migrate/20230427105700_change_states_on_proposals.rb +34 -0
- data/lib/decidim/api/proposals_type.rb +2 -2
- data/lib/decidim/proposals/component.rb +11 -289
- data/lib/decidim/proposals/doc_to_markdown.rb +0 -4
- data/lib/decidim/proposals/engine.rb +43 -7
- data/lib/decidim/proposals/import/proposal_answer_creator.rb +1 -1
- data/lib/decidim/proposals/import/proposal_creator.rb +10 -10
- data/lib/decidim/proposals/markdown_to_proposals.rb +8 -2
- data/lib/decidim/proposals/proposal_serializer.rb +4 -56
- data/lib/decidim/proposals/seeds.rb +278 -0
- data/lib/decidim/proposals/test/factories.rb +106 -85
- data/lib/decidim/proposals/valuatable.rb +1 -2
- data/lib/decidim/proposals/version.rb +1 -1
- metadata +55 -66
- data/app/cells/decidim/proposals/collaborative_draft_m/footer.erb +0 -6
- data/app/cells/decidim/proposals/collaborative_draft_m/tags.erb +0 -1
- data/app/cells/decidim/proposals/collaborative_draft_m_cell.rb +0 -44
- data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/elements.erb +0 -5
- data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/heading.erb +0 -1
- data/app/cells/decidim/proposals/proposal_link_to_rejected_emendation/show.erb +0 -9
- data/app/cells/decidim/proposals/proposal_m/footer.erb +0 -26
- data/app/cells/decidim/proposals/proposal_m/tags.erb +0 -1
- data/app/cells/decidim/proposals/proposal_m_cell.rb +0 -151
- data/app/cells/decidim/proposals/proposal_tags/show.erb +0 -33
- data/app/cells/decidim/proposals/proposal_tags_cell.rb +0 -35
- data/app/cells/decidim/proposals/proposals_picker/proposals.erb +0 -12
- data/app/controllers/concerns/decidim/proposals/admin/picker.rb +0 -21
- data/app/controllers/decidim/proposals/widgets_controller.rb +0 -29
- data/app/helpers/decidim/proposals/admin/filterable_helper.rb +0 -17
- data/app/helpers/decidim/proposals/admin/proposals_picker_helper.rb +0 -30
- data/app/packs/src/decidim/proposals/admin/proposals_picker.js +0 -50
- data/app/packs/stylesheets/decidim/proposals/_proposals.scss +0 -1
- data/app/packs/stylesheets/decidim/proposals/proposals/_preview.scss +0 -3
- data/app/views/decidim/proposals/collaborative_drafts/_count.html.erb +0 -1
- data/app/views/decidim/proposals/collaborative_drafts/_filters.html.erb +0 -32
- data/app/views/decidim/proposals/collaborative_drafts/_filters_small_view.html.erb +0 -18
- data/app/views/decidim/proposals/collaborative_drafts/_new_collaborative_draft_button.html.erb +0 -11
- data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +0 -13
- data/app/views/decidim/proposals/collaborative_drafts/_wizard_header.html.erb +0 -14
- data/app/views/decidim/proposals/proposals/_count.html.erb +0 -1
- data/app/views/decidim/proposals/proposals/_dynamic_map_instructions.html.erb +0 -4
- data/app/views/decidim/proposals/proposals/_filters.html.erb +0 -48
- data/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +0 -18
- data/app/views/decidim/proposals/proposals/_proposal_similar.html.erb +0 -22
- data/app/views/decidim/proposals/proposals/_wizard_aside.html.erb +0 -20
- data/app/views/decidim/proposals/proposals/participatory_texts/_index.html.erb +0 -19
- data/app/views/decidim/proposals/versions/index.html.erb +0 -16
- data/config/locales/he-IL.yml +0 -1
- data/db/migrate/20240404202756_add_valuation_assignments_count_to_decidim_proposals_proposals.rb +0 -16
- data/decidim-proposals.gemspec +0 -40
- data/lib/decidim/proposals/test/capybara_proposals_picker.rb +0 -59
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "decidim/components/namer"
|
4
3
|
require "decidim/meetings"
|
5
4
|
|
6
5
|
Decidim.register_component(:proposals) do |component|
|
@@ -8,9 +7,10 @@ Decidim.register_component(:proposals) do |component|
|
|
8
7
|
component.admin_engine = Decidim::Proposals::AdminEngine
|
9
8
|
component.stylesheet = "decidim/proposals/proposals"
|
10
9
|
component.icon = "media/images/decidim_proposals.svg"
|
10
|
+
component.icon_key = "chat-new-line"
|
11
11
|
|
12
12
|
component.on(:before_destroy) do |instance|
|
13
|
-
raise "
|
13
|
+
raise "Cannot destroy this component when there are proposals" if Decidim::Proposals::Proposal.where(component: instance).any?
|
14
14
|
end
|
15
15
|
|
16
16
|
component.data_portable_entities = ["Decidim::Proposals::Proposal"]
|
@@ -51,7 +51,10 @@ Decidim.register_component(:proposals) do |component|
|
|
51
51
|
settings.attribute :amendments_enabled, type: :boolean, default: false
|
52
52
|
settings.attribute :amendments_wizard_help_text, type: :text, translated: true, editor: true, required: false
|
53
53
|
settings.attribute :announcement, type: :text, translated: true, editor: true
|
54
|
-
settings.attribute :new_proposal_body_template,
|
54
|
+
settings.attribute :new_proposal_body_template,
|
55
|
+
type: :text, translated: true,
|
56
|
+
editor: ->(context) { context[:component].organization.rich_text_editor_in_public_views },
|
57
|
+
required: false
|
55
58
|
settings.attribute :new_proposal_help_text, type: :text, translated: true, editor: true
|
56
59
|
settings.attribute :proposal_wizard_step_1_help_text, type: :text, translated: true, editor: true
|
57
60
|
settings.attribute :proposal_wizard_step_2_help_text, type: :text, translated: true, editor: true
|
@@ -135,7 +138,7 @@ Decidim.register_component(:proposals) do |component|
|
|
135
138
|
.where(component: component_instance)
|
136
139
|
.includes(:scope, :category, :component)
|
137
140
|
|
138
|
-
if space.user_roles(:valuator).where(user:
|
141
|
+
if space.user_roles(:valuator).where(user:).any?
|
139
142
|
collection.with_valuation_assigned_to(user, space)
|
140
143
|
else
|
141
144
|
collection
|
@@ -164,7 +167,7 @@ Decidim.register_component(:proposals) do |component|
|
|
164
167
|
imports.form_class_name = "Decidim::Proposals::Admin::ProposalsFileImportForm"
|
165
168
|
|
166
169
|
imports.messages do |msg|
|
167
|
-
msg.set(:resource_name) { |count: 1| I18n.t("decidim.proposals.admin.imports.resources.proposals", count:
|
170
|
+
msg.set(:resource_name) { |count: 1| I18n.t("decidim.proposals.admin.imports.resources.proposals", count:) }
|
168
171
|
msg.set(:title) { I18n.t("decidim.proposals.admin.imports.title.proposals") }
|
169
172
|
msg.set(:label) { I18n.t("decidim.proposals.admin.imports.label.proposals") }
|
170
173
|
msg.set(:help) { I18n.t("decidim.proposals.admin.imports.help.proposals") }
|
@@ -175,7 +178,7 @@ Decidim.register_component(:proposals) do |component|
|
|
175
178
|
|
176
179
|
component.imports :answers do |imports|
|
177
180
|
imports.messages do |msg|
|
178
|
-
msg.set(:resource_name) { |count: 1| I18n.t("decidim.proposals.admin.imports.resources.answers", count:
|
181
|
+
msg.set(:resource_name) { |count: 1| I18n.t("decidim.proposals.admin.imports.resources.answers", count:) }
|
179
182
|
msg.set(:title) { I18n.t("decidim.proposals.admin.imports.title.answers") }
|
180
183
|
msg.set(:label) { I18n.t("decidim.proposals.admin.imports.label.answers") }
|
181
184
|
msg.set(:help) { I18n.t("decidim.proposals.admin.imports.help.answers") }
|
@@ -194,289 +197,8 @@ Decidim.register_component(:proposals) do |component|
|
|
194
197
|
end
|
195
198
|
|
196
199
|
component.seeds do |participatory_space|
|
197
|
-
|
198
|
-
organization: participatory_space.organization,
|
199
|
-
email: "admin@example.org"
|
200
|
-
)
|
201
|
-
|
202
|
-
step_settings = if participatory_space.allows_steps?
|
203
|
-
{ participatory_space.active_step.id => { votes_enabled: true, votes_blocked: false, creation_enabled: true } }
|
204
|
-
else
|
205
|
-
{}
|
206
|
-
end
|
207
|
-
|
208
|
-
params = {
|
209
|
-
name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :proposals).i18n_name,
|
210
|
-
manifest_name: :proposals,
|
211
|
-
published_at: Time.current,
|
212
|
-
participatory_space: participatory_space,
|
213
|
-
settings: {
|
214
|
-
vote_limit: 0,
|
215
|
-
collaborative_drafts_enabled: true
|
216
|
-
},
|
217
|
-
step_settings: step_settings
|
218
|
-
}
|
219
|
-
|
220
|
-
component = Decidim.traceability.perform_action!(
|
221
|
-
"publish",
|
222
|
-
Decidim::Component,
|
223
|
-
admin_user,
|
224
|
-
visibility: "all"
|
225
|
-
) do
|
226
|
-
Decidim::Component.create!(params)
|
227
|
-
end
|
228
|
-
|
229
|
-
if participatory_space.scope
|
230
|
-
scopes = participatory_space.scope.descendants
|
231
|
-
global = participatory_space.scope
|
232
|
-
else
|
233
|
-
scopes = participatory_space.organization.scopes
|
234
|
-
global = nil
|
235
|
-
end
|
236
|
-
|
237
|
-
5.times do |n|
|
238
|
-
state, answer, state_published_at = if n > 3
|
239
|
-
["accepted", Decidim::Faker::Localized.sentence(word_count: 10), Time.current]
|
240
|
-
elsif n > 2
|
241
|
-
["rejected", nil, Time.current]
|
242
|
-
elsif n > 1
|
243
|
-
["evaluating", nil, Time.current]
|
244
|
-
elsif n.positive?
|
245
|
-
["accepted", Decidim::Faker::Localized.sentence(word_count: 10), nil]
|
246
|
-
else
|
247
|
-
[nil, nil, nil]
|
248
|
-
end
|
249
|
-
|
250
|
-
params = {
|
251
|
-
component: component,
|
252
|
-
category: participatory_space.categories.sample,
|
253
|
-
scope: Faker::Boolean.boolean(true_ratio: 0.5) ? global : scopes.sample,
|
254
|
-
title: { en: Faker::Lorem.sentence(word_count: 2) },
|
255
|
-
body: { en: Faker::Lorem.paragraphs(number: 2).join("\n") },
|
256
|
-
state: state,
|
257
|
-
answer: answer,
|
258
|
-
answered_at: state.present? ? Time.current : nil,
|
259
|
-
state_published_at: state_published_at,
|
260
|
-
published_at: Time.current
|
261
|
-
}
|
262
|
-
|
263
|
-
proposal = Decidim.traceability.perform_action!(
|
264
|
-
"publish",
|
265
|
-
Decidim::Proposals::Proposal,
|
266
|
-
admin_user,
|
267
|
-
visibility: "all"
|
268
|
-
) do
|
269
|
-
proposal = Decidim::Proposals::Proposal.new(params)
|
270
|
-
meeting_component = participatory_space.components.find_by(manifest_name: "meetings")
|
271
|
-
|
272
|
-
coauthor = case n
|
273
|
-
when 0
|
274
|
-
Decidim::User.where(decidim_organization_id: participatory_space.decidim_organization_id).order(Arel.sql("RANDOM()")).first
|
275
|
-
when 1
|
276
|
-
Decidim::UserGroup.where(decidim_organization_id: participatory_space.decidim_organization_id).order(Arel.sql("RANDOM()")).first
|
277
|
-
when 2
|
278
|
-
Decidim::Meetings::Meeting.where(component: meeting_component).order(Arel.sql("RANDOM()")).first
|
279
|
-
else
|
280
|
-
participatory_space.organization
|
281
|
-
end
|
282
|
-
proposal.add_coauthor(coauthor)
|
283
|
-
proposal.save!
|
284
|
-
proposal
|
285
|
-
end
|
286
|
-
|
287
|
-
if proposal.state.nil?
|
288
|
-
email = "amendment-author-#{participatory_space.underscored_name}-#{participatory_space.id}-#{n}-amend#{n}@example.org"
|
289
|
-
name = "#{Faker::Name.name} #{participatory_space.id} #{n} amend#{n}"
|
290
|
-
|
291
|
-
author = Decidim::User.find_or_initialize_by(email: email)
|
292
|
-
author.update!(
|
293
|
-
password: "decidim123456789",
|
294
|
-
password_confirmation: "decidim123456789",
|
295
|
-
name: name,
|
296
|
-
nickname: Faker::Twitter.unique.screen_name,
|
297
|
-
organization: component.organization,
|
298
|
-
tos_agreement: "1",
|
299
|
-
confirmed_at: Time.current
|
300
|
-
)
|
301
|
-
|
302
|
-
group = Decidim::UserGroup.create!(
|
303
|
-
name: Faker::Name.name,
|
304
|
-
nickname: Faker::Twitter.unique.screen_name,
|
305
|
-
email: Faker::Internet.email,
|
306
|
-
extended_data: {
|
307
|
-
document_number: Faker::Code.isbn,
|
308
|
-
phone: Faker::PhoneNumber.phone_number,
|
309
|
-
verified_at: Time.current
|
310
|
-
},
|
311
|
-
decidim_organization_id: component.organization.id,
|
312
|
-
confirmed_at: Time.current
|
313
|
-
)
|
314
|
-
|
315
|
-
Decidim::UserGroupMembership.create!(
|
316
|
-
user: author,
|
317
|
-
role: "creator",
|
318
|
-
user_group: group
|
319
|
-
)
|
320
|
-
|
321
|
-
params = {
|
322
|
-
component: component,
|
323
|
-
category: participatory_space.categories.sample,
|
324
|
-
scope: Faker::Boolean.boolean(true_ratio: 0.5) ? global : scopes.sample,
|
325
|
-
title: { en: "#{proposal.title["en"]} #{Faker::Lorem.sentence(word_count: 1)}" },
|
326
|
-
body: { en: "#{proposal.body["en"]} #{Faker::Lorem.sentence(word_count: 3)}" },
|
327
|
-
state: "evaluating",
|
328
|
-
answer: nil,
|
329
|
-
answered_at: Time.current,
|
330
|
-
published_at: Time.current
|
331
|
-
}
|
332
|
-
|
333
|
-
emendation = Decidim.traceability.perform_action!(
|
334
|
-
"create",
|
335
|
-
Decidim::Proposals::Proposal,
|
336
|
-
author,
|
337
|
-
visibility: "public-only"
|
338
|
-
) do
|
339
|
-
emendation = Decidim::Proposals::Proposal.new(params)
|
340
|
-
emendation.add_coauthor(author, user_group: author.user_groups.first)
|
341
|
-
emendation.save!
|
342
|
-
emendation
|
343
|
-
end
|
344
|
-
|
345
|
-
Decidim::Amendment.create!(
|
346
|
-
amender: author,
|
347
|
-
amendable: proposal,
|
348
|
-
emendation: emendation,
|
349
|
-
state: "evaluating"
|
350
|
-
)
|
351
|
-
end
|
352
|
-
|
353
|
-
(n % 3).times do |m|
|
354
|
-
email = "vote-author-#{participatory_space.underscored_name}-#{participatory_space.id}-#{n}-#{m}@example.org"
|
355
|
-
name = "#{Faker::Name.name} #{participatory_space.id} #{n} #{m}"
|
356
|
-
|
357
|
-
author = Decidim::User.find_or_initialize_by(email: email)
|
358
|
-
author.update!(
|
359
|
-
password: "decidim123456789",
|
360
|
-
password_confirmation: "decidim123456789",
|
361
|
-
name: name,
|
362
|
-
nickname: Faker::Twitter.unique.screen_name,
|
363
|
-
organization: component.organization,
|
364
|
-
tos_agreement: "1",
|
365
|
-
confirmed_at: Time.current,
|
366
|
-
personal_url: Faker::Internet.url,
|
367
|
-
about: Faker::Lorem.paragraph(sentence_count: 2)
|
368
|
-
)
|
369
|
-
|
370
|
-
Decidim::Proposals::ProposalVote.create!(proposal: proposal, author: author) unless proposal.published_state? && proposal.rejected?
|
371
|
-
Decidim::Proposals::ProposalVote.create!(proposal: emendation, author: author) if emendation
|
372
|
-
end
|
373
|
-
|
374
|
-
unless proposal.published_state? && proposal.rejected?
|
375
|
-
(n * 2).times do |index|
|
376
|
-
email = "endorsement-author-#{participatory_space.underscored_name}-#{participatory_space.id}-#{n}-endr#{index}@example.org"
|
377
|
-
name = "#{Faker::Name.name} #{participatory_space.id} #{n} endr#{index}"
|
378
|
-
|
379
|
-
author = Decidim::User.find_or_initialize_by(email: email)
|
380
|
-
author.update!(
|
381
|
-
password: "decidim123456789",
|
382
|
-
password_confirmation: "decidim123456789",
|
383
|
-
name: name,
|
384
|
-
nickname: Faker::Twitter.unique.screen_name,
|
385
|
-
organization: component.organization,
|
386
|
-
tos_agreement: "1",
|
387
|
-
confirmed_at: Time.current
|
388
|
-
)
|
389
|
-
if index.even?
|
390
|
-
group = Decidim::UserGroup.create!(
|
391
|
-
name: Faker::Name.name,
|
392
|
-
nickname: Faker::Twitter.unique.screen_name,
|
393
|
-
email: Faker::Internet.email,
|
394
|
-
extended_data: {
|
395
|
-
document_number: Faker::Code.isbn,
|
396
|
-
phone: Faker::PhoneNumber.phone_number,
|
397
|
-
verified_at: Time.current
|
398
|
-
},
|
399
|
-
decidim_organization_id: component.organization.id,
|
400
|
-
confirmed_at: Time.current
|
401
|
-
)
|
402
|
-
|
403
|
-
Decidim::UserGroupMembership.create!(
|
404
|
-
user: author,
|
405
|
-
role: "creator",
|
406
|
-
user_group: group
|
407
|
-
)
|
408
|
-
end
|
409
|
-
Decidim::Endorsement.create!(resource: proposal, author: author, user_group: author.user_groups.first)
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
413
|
-
(n % 3).times do
|
414
|
-
author_admin = Decidim::User.where(organization: component.organization, admin: true).all.sample
|
415
|
-
|
416
|
-
Decidim::Proposals::ProposalNote.create!(
|
417
|
-
proposal: proposal,
|
418
|
-
author: author_admin,
|
419
|
-
body: Faker::Lorem.paragraphs(number: 2).join("\n")
|
420
|
-
)
|
421
|
-
end
|
422
|
-
|
423
|
-
Decidim::Comments::Seed.comments_for(proposal)
|
424
|
-
|
425
|
-
#
|
426
|
-
# Collaborative drafts
|
427
|
-
#
|
428
|
-
state = if n > 3
|
429
|
-
"published"
|
430
|
-
elsif n > 2
|
431
|
-
"withdrawn"
|
432
|
-
else
|
433
|
-
"open"
|
434
|
-
end
|
435
|
-
author = Decidim::User.where(organization: component.organization).all.sample
|
436
|
-
|
437
|
-
draft = Decidim.traceability.perform_action!("create", Decidim::Proposals::CollaborativeDraft, author) do
|
438
|
-
draft = Decidim::Proposals::CollaborativeDraft.new(
|
439
|
-
component: component,
|
440
|
-
category: participatory_space.categories.sample,
|
441
|
-
scope: Faker::Boolean.boolean(true_ratio: 0.5) ? global : scopes.sample,
|
442
|
-
title: Faker::Lorem.sentence(word_count: 2),
|
443
|
-
body: Faker::Lorem.paragraphs(number: 2).join("\n"),
|
444
|
-
state: state,
|
445
|
-
published_at: Time.current
|
446
|
-
)
|
447
|
-
draft.coauthorships.build(author: participatory_space.organization)
|
448
|
-
draft.save!
|
449
|
-
draft
|
450
|
-
end
|
451
|
-
|
452
|
-
case n
|
453
|
-
when 2
|
454
|
-
author2 = Decidim::User.where(organization: component.organization).all.sample
|
455
|
-
Decidim::Coauthorship.create(coauthorable: draft, author: author2)
|
456
|
-
author3 = Decidim::User.where(organization: component.organization).all.sample
|
457
|
-
Decidim::Coauthorship.create(coauthorable: draft, author: author3)
|
458
|
-
author4 = Decidim::User.where(organization: component.organization).all.sample
|
459
|
-
Decidim::Coauthorship.create(coauthorable: draft, author: author4)
|
460
|
-
author5 = Decidim::User.where(organization: component.organization).all.sample
|
461
|
-
Decidim::Coauthorship.create(coauthorable: draft, author: author5)
|
462
|
-
author6 = Decidim::User.where(organization: component.organization).all.sample
|
463
|
-
Decidim::Coauthorship.create(coauthorable: draft, author: author6)
|
464
|
-
when 3
|
465
|
-
author2 = Decidim::User.where(organization: component.organization).all.sample
|
466
|
-
Decidim::Coauthorship.create(coauthorable: draft, author: author2)
|
467
|
-
end
|
468
|
-
|
469
|
-
Decidim::Comments::Seed.comments_for(draft)
|
470
|
-
end
|
200
|
+
require "decidim/proposals/seeds"
|
471
201
|
|
472
|
-
Decidim.
|
473
|
-
Decidim::Proposals::CollaborativeDraft.all.sample,
|
474
|
-
Decidim::User.where(organization: component.organization).all.sample,
|
475
|
-
component: component,
|
476
|
-
category: participatory_space.categories.sample,
|
477
|
-
scope: Faker::Boolean.boolean(true_ratio: 0.5) ? global : scopes.sample,
|
478
|
-
title: Faker::Lorem.sentence(word_count: 2),
|
479
|
-
body: Faker::Lorem.paragraphs(number: 2).join("\n")
|
480
|
-
)
|
202
|
+
Decidim::Proposals::Seeds.new(participatory_space:).call
|
481
203
|
end
|
482
204
|
end
|
@@ -17,7 +17,6 @@ module Decidim
|
|
17
17
|
# sometimes markdown documents are classified as text/plain
|
18
18
|
TEXT_PLAIN_MIME_TYPE = "text/plain"
|
19
19
|
ODT_MIME_TYPE = "application/vnd.oasis.opendocument.text"
|
20
|
-
DOCX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
21
20
|
|
22
21
|
# Accepted mime types
|
23
22
|
# keys: are used for dynamic help text on admin form.
|
@@ -36,9 +35,6 @@ module Decidim
|
|
36
35
|
when ODT_MIME_TYPE
|
37
36
|
# convert libreoffice odt to markdown
|
38
37
|
OdtToMarkdown.new(doc)
|
39
|
-
when DOCX_MIME_TYPE
|
40
|
-
# convert word 2013 docx to markdown
|
41
|
-
DocxToMarkdown.new(doc)
|
42
38
|
end
|
43
39
|
end
|
44
40
|
|
@@ -23,8 +23,7 @@ module Decidim
|
|
23
23
|
put :withdraw
|
24
24
|
end
|
25
25
|
resource :proposal_vote, only: [:create, :destroy]
|
26
|
-
|
27
|
-
resources :versions, only: [:show, :index]
|
26
|
+
resources :versions, only: [:show]
|
28
27
|
end
|
29
28
|
resources :collaborative_drafts, except: [:destroy] do
|
30
29
|
member do
|
@@ -34,12 +33,33 @@ module Decidim
|
|
34
33
|
post :withdraw
|
35
34
|
post :publish
|
36
35
|
end
|
37
|
-
resources :versions, only: [:show
|
36
|
+
resources :versions, only: [:show]
|
38
37
|
end
|
39
|
-
|
38
|
+
scope "/proposals" do
|
39
|
+
root to: "proposals#index"
|
40
|
+
end
|
41
|
+
get "/", to: redirect("proposals", status: 301)
|
42
|
+
end
|
43
|
+
|
44
|
+
initializer "decidim_proposals.register_icons" do
|
45
|
+
Decidim.icons.register(name: "Decidim::Proposals::CollaborativeDraft", icon: "draft-line", category: "activity",
|
46
|
+
description: "Collaborative draft", engine: :proposals)
|
47
|
+
Decidim.icons.register(name: "Decidim::Proposals::Proposal", icon: "chat-new-line", category: "activity",
|
48
|
+
description: "Proposal", engine: :proposals)
|
49
|
+
Decidim.icons.register(name: "participatory_texts_item", icon: "bookmark-line", description: "Index item", category: "participatory_texts",
|
50
|
+
engine: :proposals)
|
51
|
+
|
52
|
+
Decidim.icons.register(name: "scan-line", icon: "scan-line", category: "system", description: "", engine: :proposals)
|
53
|
+
Decidim.icons.register(name: "edit-2-line", icon: "edit-2-line",
|
54
|
+
category: "action", description: "Edit icon for Collaborative Drafts", engine: :proposals)
|
55
|
+
|
56
|
+
Decidim.icons.register(name: "bookmark-line", icon: "bookmark-line", category: "system", description: "", engine: :proposals)
|
57
|
+
Decidim.icons.register(name: "arrow-right-s-fill", icon: "arrow-right-s-fill", category: "system", description: "", engine: :proposals)
|
58
|
+
Decidim.icons.register(name: "bar-chart-2-line", icon: "bar-chart-2-line", category: "system", description: "", engine: :proposals)
|
59
|
+
Decidim.icons.register(name: "scales-line", icon: "scales-line", category: "system", description: "", engine: :proposals)
|
40
60
|
end
|
41
61
|
|
42
|
-
initializer "
|
62
|
+
initializer "decidim_proposals.content_processors" do |_app|
|
43
63
|
Decidim.configure do |config|
|
44
64
|
config.content_processors += [:proposal]
|
45
65
|
end
|
@@ -51,7 +71,7 @@ module Decidim
|
|
51
71
|
end
|
52
72
|
end
|
53
73
|
|
54
|
-
initializer "
|
74
|
+
initializer "decidim_proposals.settings_changes" do
|
55
75
|
config.to_prepare do
|
56
76
|
Decidim::SettingsChange.subscribe "surveys" do |changes|
|
57
77
|
Decidim::Proposals::SettingsChangeJob.perform_later(
|
@@ -91,7 +111,7 @@ module Decidim
|
|
91
111
|
end
|
92
112
|
|
93
113
|
initializer "decidim_proposals.remove_space_admins" do
|
94
|
-
ActiveSupport::Notifications.subscribe("decidim.
|
114
|
+
ActiveSupport::Notifications.subscribe("decidim.admin.participatorty_space.destroy_admin:after") do |_event_name, klass, id|
|
95
115
|
Decidim::Proposals::ValuationAssignment.where(valuator_role_type: klass, valuator_role_id: id).destroy_all
|
96
116
|
end
|
97
117
|
end
|
@@ -208,6 +228,22 @@ module Decidim
|
|
208
228
|
initializer "decidim_proposals.webpacker.assets_path" do
|
209
229
|
Decidim.register_assets_path File.expand_path("app/packs", root)
|
210
230
|
end
|
231
|
+
|
232
|
+
initializer "decidim_proposals.authorization_transfer" do
|
233
|
+
config.to_prepare do
|
234
|
+
Decidim::AuthorizationTransfer.register(:proposals) do |transfer|
|
235
|
+
transfer.move_records(Decidim::Proposals::ProposalVote, :decidim_author_id)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
initializer "decidim_proposals.moderation_content" do
|
241
|
+
config.to_prepare do
|
242
|
+
ActiveSupport::Notifications.subscribe("decidim.admin.block_user:after") do |_event_name, data|
|
243
|
+
Decidim::Proposals::HideAllCreatedByAuthorJob.perform_later(**data)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
211
247
|
end
|
212
248
|
end
|
213
249
|
end
|
@@ -45,26 +45,26 @@ module Decidim
|
|
45
45
|
|
46
46
|
def resource
|
47
47
|
@resource ||= Decidim::Proposals::Proposal.new(
|
48
|
-
category
|
49
|
-
scope
|
50
|
-
title
|
51
|
-
body
|
52
|
-
address
|
53
|
-
latitude
|
54
|
-
longitude
|
55
|
-
component
|
48
|
+
category:,
|
49
|
+
scope:,
|
50
|
+
title:,
|
51
|
+
body:,
|
52
|
+
address:,
|
53
|
+
latitude:,
|
54
|
+
longitude:,
|
55
|
+
component:,
|
56
56
|
published_at: Time.current
|
57
57
|
)
|
58
58
|
end
|
59
59
|
|
60
60
|
def category
|
61
61
|
id = data.has_key?(:category) ? data[:category]["id"] : data[:"category/id"].to_i
|
62
|
-
Decidim::Category.find_by(id:
|
62
|
+
Decidim::Category.find_by(id:)
|
63
63
|
end
|
64
64
|
|
65
65
|
def scope
|
66
66
|
id = data.has_key?(:scope) ? data[:scope]["id"] : data[:"scope/id"].to_i
|
67
|
-
Decidim::Scope.find_by(id:
|
67
|
+
Decidim::Scope.find_by(id:)
|
68
68
|
end
|
69
69
|
|
70
70
|
def title
|
@@ -41,6 +41,12 @@ module Decidim
|
|
41
41
|
|
42
42
|
# Block-level calls ######################
|
43
43
|
|
44
|
+
# Recarpet callback to preprocess the document.
|
45
|
+
# Removes the HTML comment from the markdown file
|
46
|
+
def preprocess(document)
|
47
|
+
document.gsub(/<!--.*-->/, "")
|
48
|
+
end
|
49
|
+
|
44
50
|
# Recarpet callback to process headers.
|
45
51
|
# Creates Paricipatory Text Proposals at Section and Subsection levels.
|
46
52
|
def header(title, level)
|
@@ -133,12 +139,12 @@ module Decidim
|
|
133
139
|
component: @component,
|
134
140
|
title: { I18n.locale => title },
|
135
141
|
body: { I18n.locale => body },
|
136
|
-
participatory_text_level:
|
142
|
+
participatory_text_level:
|
137
143
|
}
|
138
144
|
|
139
145
|
PaperTrail.request(enabled: false) do
|
140
146
|
proposal = Decidim::Proposals::ProposalBuilder.create(
|
141
|
-
attributes
|
147
|
+
attributes:,
|
142
148
|
author: @component.organization,
|
143
149
|
action_user: @current_user
|
144
150
|
)
|
@@ -19,9 +19,6 @@ module Decidim
|
|
19
19
|
def serialize
|
20
20
|
{
|
21
21
|
id: proposal.id,
|
22
|
-
author: {
|
23
|
-
**author_fields
|
24
|
-
},
|
25
22
|
category: {
|
26
23
|
id: proposal.category.try(:id),
|
27
24
|
name: proposal.category.try(:name) || empty_translatable
|
@@ -43,19 +40,18 @@ module Decidim
|
|
43
40
|
state: proposal.state.to_s,
|
44
41
|
reference: proposal.reference,
|
45
42
|
answer: ensure_translatable(proposal.answer),
|
46
|
-
answered_at: proposal.answered_at,
|
47
43
|
supports: proposal.proposal_votes_count,
|
48
44
|
endorsements: {
|
49
45
|
total_count: proposal.endorsements.size,
|
50
|
-
user_endorsements:
|
46
|
+
user_endorsements:
|
51
47
|
},
|
52
48
|
comments: proposal.comments_count,
|
53
|
-
attachments: proposal.attachments.
|
49
|
+
attachments: proposal.attachments.count,
|
54
50
|
followers: proposal.follows.size,
|
55
51
|
published_at: proposal.published_at,
|
56
|
-
url
|
52
|
+
url:,
|
57
53
|
meeting_urls: meetings,
|
58
|
-
related_proposals
|
54
|
+
related_proposals:,
|
59
55
|
is_amend: proposal.emendation?,
|
60
56
|
original_proposal: {
|
61
57
|
title: proposal&.amendable&.title,
|
@@ -105,54 +101,6 @@ module Decidim
|
|
105
101
|
|
106
102
|
convert_to_text(value)
|
107
103
|
end
|
108
|
-
|
109
|
-
def author_fields
|
110
|
-
is_author_user_group = resource.coauthorships.map(&:decidim_user_group_id).any?
|
111
|
-
|
112
|
-
{
|
113
|
-
id: resource.authors.map(&:id),
|
114
|
-
name: resource.authors.map do |author|
|
115
|
-
author_name(is_author_user_group ? resource.coauthorships.first.user_group : author)
|
116
|
-
end,
|
117
|
-
url: resource.authors.map do |author|
|
118
|
-
author_url(is_author_user_group ? resource.coauthorships.first.user_group : author)
|
119
|
-
end
|
120
|
-
}
|
121
|
-
end
|
122
|
-
|
123
|
-
def author_name(author)
|
124
|
-
if author.respond_to?(:name)
|
125
|
-
translated_attribute(author.name) # is a Decidim::User or Decidim::Organization or Decidim::UserGroup
|
126
|
-
elsif author.respond_to?(:title)
|
127
|
-
translated_attribute(author.title) # is a Decidim::Meetings::Meeting
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def author_url(author)
|
132
|
-
if author.respond_to?(:nickname)
|
133
|
-
profile_url(author.nickname) # is a Decidim::User or Decidim::UserGroup
|
134
|
-
elsif author.respond_to?(:title)
|
135
|
-
meeting_url(author) # is a Decidim::Meetings::Meeting
|
136
|
-
else
|
137
|
-
root_url # is a Decidim::Organization
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def profile_url(nickname)
|
142
|
-
Decidim::Core::Engine.routes.url_helpers.profile_url(nickname, host: host)
|
143
|
-
end
|
144
|
-
|
145
|
-
def meeting_url(meeting)
|
146
|
-
Decidim::EngineRouter.main_proxy(meeting.component).meeting_url(id: meeting.id, host: host)
|
147
|
-
end
|
148
|
-
|
149
|
-
def root_url
|
150
|
-
Decidim::Core::Engine.routes.url_helpers.root_url(host: host)
|
151
|
-
end
|
152
|
-
|
153
|
-
def host
|
154
|
-
resource.organization.host
|
155
|
-
end
|
156
104
|
end
|
157
105
|
end
|
158
106
|
end
|