decidim-proposals 0.20.1 → 0.23.1
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 +1 -1
- 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 +30 -10
- 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 +54 -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 +24 -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 +152 -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 +79 -5
- 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 +11 -69
- 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 +18 -16
- 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 +6 -13
- 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 -50
- 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 +62 -66
- data/config/locales/bg-BG.yml +237 -0
- data/config/locales/bg.yml +237 -0
- data/config/locales/ca.yml +176 -66
- data/config/locales/cs.yml +188 -78
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +169 -62
- data/config/locales/el.yml +876 -0
- data/config/locales/en.yml +179 -69
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +173 -63
- data/config/locales/es-PY.yml +173 -63
- data/config/locales/es.yml +179 -69
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +28 -61
- data/config/locales/fi-plain.yml +174 -64
- data/config/locales/fi.yml +210 -100
- data/config/locales/fr-CA.yml +906 -0
- data/config/locales/fr.yml +184 -66
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +28 -61
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +135 -63
- data/config/locales/id-ID.yml +28 -60
- data/config/locales/is-IS.yml +14 -30
- data/config/locales/is.yml +274 -0
- data/config/locales/it.yml +166 -80
- 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 +151 -63
- data/config/locales/no.yml +62 -67
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +525 -392
- data/config/locales/pt-BR.yml +30 -66
- data/config/locales/pt.yml +439 -330
- data/config/locales/ro-RO.yml +841 -0
- data/config/locales/ru.yml +14 -45
- 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 -169
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +28 -61
- data/config/locales/uk.yml +14 -45
- 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 +86 -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 +117 -55
- 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
@@ -1,25 +1,33 @@
|
|
1
1
|
<figure>
|
2
|
-
<
|
3
|
-
<strong>
|
4
|
-
<%= t("filed_as", scope: "decidim.proposals.proposals.tags") %>
|
5
|
-
</strong>
|
6
|
-
</figcaption>
|
7
|
-
|
8
|
-
<ul>
|
2
|
+
<ul class="tags tags--proposal tags--list">
|
9
3
|
<% if category.present? %>
|
10
4
|
<li>
|
11
|
-
<%= link_to
|
5
|
+
<%= link_to resource_locator(model).index(filter: { category_id: [category.id.to_s] }), title: t("decidim.tags.filter_results_for_category", resource: translated_attribute(category.name)) do %>
|
6
|
+
<span class="show-for-sr"><%= t "decidim.tags.filter_results_for_category", resource: translated_attribute(category.name) %></span>
|
7
|
+
<span aria-hidden="true"><%= translated_attribute(category.name) %></span>
|
8
|
+
<% end %>
|
12
9
|
<% if previous_category.present? && show_previous_category? %>
|
13
10
|
|
14
11
|
<small class="text-small">
|
15
|
-
<%= t("changed_from", scope: "decidim.proposals.proposals.tags",
|
12
|
+
<%= t("changed_from", scope: "decidim.proposals.proposals.tags", previous_name: "#{previous_category.translated_name}").html_safe %>
|
16
13
|
</small>
|
17
14
|
<% end %>
|
18
15
|
</li>
|
19
16
|
<% end %>
|
20
17
|
|
21
18
|
<% if has_visible_scopes?(model) %>
|
22
|
-
<li
|
19
|
+
<li>
|
20
|
+
<%= link_to resource_locator(model).index(filter: { scope_id: [scope.id] }), title: t("decidim.tags.filter_results_for_scope", resource: translated_attribute(scope.name)) do %>
|
21
|
+
<span class="show-for-sr"><%= t "decidim.tags.filter_results_for_scope", resource: translated_attribute(scope.name) %></span>
|
22
|
+
<span aria-hidden="true"><%= translated_attribute(scope.name) %></span>
|
23
|
+
<% end %>
|
24
|
+
<% if previous_scope.present? && show_previous_scope? %>
|
25
|
+
|
26
|
+
<small class="text-small">
|
27
|
+
<%= t("changed_from", scope: "decidim.proposals.proposals.tags", previous_name: "#{translated_attribute(previous_scope.name)}").html_safe %>
|
28
|
+
</small>
|
29
|
+
<% end %>
|
30
|
+
</li>
|
23
31
|
<% end %>
|
24
32
|
</ul>
|
25
33
|
</figure>
|
@@ -11,6 +11,7 @@ module Decidim
|
|
11
11
|
property :category
|
12
12
|
property :previous_category
|
13
13
|
property :scope
|
14
|
+
property :previous_scope
|
14
15
|
|
15
16
|
def show
|
16
17
|
render if has_category_or_scopes?
|
@@ -22,6 +23,10 @@ module Decidim
|
|
22
23
|
options[:show_previous_category].to_s != "false"
|
23
24
|
end
|
24
25
|
|
26
|
+
def show_previous_scope?
|
27
|
+
options[:show_previous_scope].to_s != "false"
|
28
|
+
end
|
29
|
+
|
25
30
|
def has_category_or_scopes?
|
26
31
|
category.present? || has_visible_scopes?(model)
|
27
32
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<ul id="proposals_list">
|
2
|
+
<% decorated_proposals do |proposal| %>
|
3
|
+
<li>
|
4
|
+
<label><input type="checkbox" data-picker-text="<%= proposal.id_and_title(html_escape: true) %>" data-picker-url="<%= picker_path %>" value="<%= proposal.id %>" data-picker-choose> <%= proposal.id_and_title(html_escape: true) %> (<%= proposal.reference %>)</label>
|
5
|
+
</li>
|
6
|
+
<% end %>
|
7
|
+
<% if more_proposals? %>
|
8
|
+
<li><div class="callout warning"><%= t("proposals_picker.more_proposals", scope: "decidim.proposals", number: more_proposals_count) %></div>
|
9
|
+
</li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
<div id="no_proposals" class="callout warning"><%= t("proposals_picker.no_proposals", scope: "decidim.proposals") %></div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class="picker-header">
|
2
|
+
<h1><%= t("proposals_picker.choose_proposals", scope: "decidim.proposals") %></h1>
|
3
|
+
<input type="text" name="proposals-filter" id="proposals_filter" placeholder="<%= t("decidim.admin.filters.search_placeholder.id_string_or_title_cont", collection: proposals_collection_name) %>">
|
4
|
+
</div>
|
5
|
+
<div class="picker-content picker-list" data-picker-path="<%= picker_path %>" data-picker-more="<%= more_proposals? %>">
|
6
|
+
<%= render :proposals %>
|
7
|
+
</div>
|
8
|
+
<div class="picker-footer">
|
9
|
+
<div class="buttons button--double">
|
10
|
+
<a class="button" data-close=""><%= t("proposals_picker.close", scope: "decidim.proposals") %></a>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= javascript_include_tag "decidim/proposals/admin/proposals_picker" %>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cell/partial"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Proposals
|
7
|
+
# This cell renders a proposals picker.
|
8
|
+
class ProposalsPickerCell < Decidim::ViewModel
|
9
|
+
MAX_PROPOSALS = 1000
|
10
|
+
|
11
|
+
def show
|
12
|
+
if filtered?
|
13
|
+
render :proposals
|
14
|
+
else
|
15
|
+
render
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
alias component model
|
20
|
+
|
21
|
+
def filtered?
|
22
|
+
!search_text.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
def picker_path
|
26
|
+
request.path
|
27
|
+
end
|
28
|
+
|
29
|
+
def search_text
|
30
|
+
params[:q]
|
31
|
+
end
|
32
|
+
|
33
|
+
def more_proposals?
|
34
|
+
@more_proposals ||= more_proposals_count.positive?
|
35
|
+
end
|
36
|
+
|
37
|
+
def more_proposals_count
|
38
|
+
@more_proposals_count ||= proposals_count - MAX_PROPOSALS
|
39
|
+
end
|
40
|
+
|
41
|
+
def proposals_count
|
42
|
+
@proposals_count ||= filtered_proposals.count
|
43
|
+
end
|
44
|
+
|
45
|
+
def decorated_proposals
|
46
|
+
filtered_proposals.limit(MAX_PROPOSALS).each do |proposal|
|
47
|
+
yield Decidim::Proposals::ProposalPresenter.new(proposal)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def filtered_proposals
|
52
|
+
@filtered_proposals ||= if filtered?
|
53
|
+
proposals.where("title ILIKE ?", "%#{search_text}%")
|
54
|
+
.or(proposals.where("reference ILIKE ?", "%#{search_text}%"))
|
55
|
+
.or(proposals.where("id::text ILIKE ?", "%#{search_text}%"))
|
56
|
+
else
|
57
|
+
proposals
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def proposals
|
62
|
+
@proposals ||= Decidim.find_resource_manifest(:proposals).try(:resource_scope, component)
|
63
|
+
&.published
|
64
|
+
&.order(id: :asc)
|
65
|
+
end
|
66
|
+
|
67
|
+
def proposals_collection_name
|
68
|
+
Decidim::Proposals::Proposal.model_name.human(count: 2)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -23,16 +23,19 @@ module Decidim
|
|
23
23
|
def call
|
24
24
|
return broadcast(:invalid) if form.invalid?
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
store_initial_proposal_state
|
27
|
+
|
28
|
+
transaction do
|
29
|
+
answer_proposal
|
30
|
+
notify_proposal_answer
|
31
|
+
end
|
29
32
|
|
30
33
|
broadcast(:ok)
|
31
34
|
end
|
32
35
|
|
33
36
|
private
|
34
37
|
|
35
|
-
attr_reader :form, :proposal
|
38
|
+
attr_reader :form, :proposal, :initial_has_state_published, :initial_state
|
36
39
|
|
37
40
|
def answer_proposal
|
38
41
|
Decidim.traceability.perform_action!(
|
@@ -40,55 +43,30 @@ module Decidim
|
|
40
43
|
proposal,
|
41
44
|
form.current_user
|
42
45
|
) do
|
43
|
-
|
44
|
-
state:
|
45
|
-
answer:
|
46
|
-
answered_at: Time.current
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
attributes = {
|
47
|
+
state: form.state,
|
48
|
+
answer: form.answer,
|
49
|
+
answered_at: Time.current,
|
50
|
+
cost: form.cost,
|
51
|
+
cost_report: form.cost_report,
|
52
|
+
execution_period: form.execution_period
|
53
|
+
}
|
50
54
|
|
51
|
-
|
52
|
-
return if (proposal.previous_changes.keys & %w(state)).empty?
|
55
|
+
attributes[:state_published_at] = Time.current if !initial_has_state_published && form.publish_answer?
|
53
56
|
|
54
|
-
|
55
|
-
publish_event(
|
56
|
-
"decidim.events.proposals.proposal_accepted",
|
57
|
-
Decidim::Proposals::AcceptedProposalEvent
|
58
|
-
)
|
59
|
-
elsif proposal.rejected?
|
60
|
-
publish_event(
|
61
|
-
"decidim.events.proposals.proposal_rejected",
|
62
|
-
Decidim::Proposals::RejectedProposalEvent
|
63
|
-
)
|
64
|
-
elsif proposal.evaluating?
|
65
|
-
publish_event(
|
66
|
-
"decidim.events.proposals.proposal_evaluating",
|
67
|
-
Decidim::Proposals::EvaluatingProposalEvent
|
68
|
-
)
|
57
|
+
proposal.update!(attributes)
|
69
58
|
end
|
70
59
|
end
|
71
60
|
|
72
|
-
def
|
73
|
-
|
74
|
-
event: event,
|
75
|
-
event_class: event_class,
|
76
|
-
resource: proposal,
|
77
|
-
affected_users: proposal.notifiable_identities,
|
78
|
-
followers: proposal.followers - proposal.notifiable_identities
|
79
|
-
)
|
80
|
-
end
|
61
|
+
def notify_proposal_answer
|
62
|
+
return if !initial_has_state_published && !form.publish_answer?
|
81
63
|
|
82
|
-
|
83
|
-
|
64
|
+
NotifyProposalAnswer.call(proposal, initial_state)
|
65
|
+
end
|
84
66
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
else
|
89
|
-
Decidim::Gamification.increment_score(coauthorship.author, :accepted_proposals)
|
90
|
-
end
|
91
|
-
end
|
67
|
+
def store_initial_proposal_state
|
68
|
+
@initial_has_state_published = proposal.published_state?
|
69
|
+
@initial_state = proposal.state
|
92
70
|
end
|
93
71
|
end
|
94
72
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module Admin
|
6
|
+
# A command with all the business logic to assign proposals to a given
|
7
|
+
# valuator.
|
8
|
+
class AssignProposalsToValuator < Rectify::Command
|
9
|
+
# Public: Initializes the command.
|
10
|
+
#
|
11
|
+
# form - A form object with the params.
|
12
|
+
def initialize(form)
|
13
|
+
@form = form
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
return broadcast(:invalid) unless form.valid?
|
24
|
+
|
25
|
+
assign_proposals
|
26
|
+
broadcast(:ok)
|
27
|
+
rescue ActiveRecord::RecordInvalid
|
28
|
+
broadcast(:invalid)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :form
|
34
|
+
|
35
|
+
def assign_proposals
|
36
|
+
transaction do
|
37
|
+
form.proposals.flat_map do |proposal|
|
38
|
+
find_assignment(proposal) || assign_proposal(proposal)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def find_assignment(proposal)
|
44
|
+
Decidim::Proposals::ValuationAssignment.find_by(
|
45
|
+
proposal: proposal,
|
46
|
+
valuator_role: form.valuator_role
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def assign_proposal(proposal)
|
51
|
+
Decidim.traceability.create!(
|
52
|
+
Decidim::Proposals::ValuationAssignment,
|
53
|
+
form.current_user,
|
54
|
+
proposal: proposal,
|
55
|
+
valuator_role: form.valuator_role
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when a user creates a new proposal.
|
7
7
|
class CreateProposal < Rectify::Command
|
8
|
-
include AttachmentMethods
|
8
|
+
include ::Decidim::AttachmentMethods
|
9
9
|
include GalleryMethods
|
10
10
|
include HashtagsMethods
|
11
11
|
|
@@ -39,6 +39,7 @@ module Decidim
|
|
39
39
|
create_proposal
|
40
40
|
create_attachment if process_attachments?
|
41
41
|
create_gallery if process_gallery?
|
42
|
+
link_author_meeeting if form.created_in_meeting?
|
42
43
|
send_notification
|
43
44
|
end
|
44
45
|
|
@@ -59,9 +60,11 @@ module Decidim
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def attributes
|
63
|
+
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
|
64
|
+
parsed_body = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.body, current_organization: form.current_organization).rewrite
|
62
65
|
{
|
63
|
-
title:
|
64
|
-
body:
|
66
|
+
title: parsed_title,
|
67
|
+
body: parsed_body,
|
65
68
|
category: form.category,
|
66
69
|
scope: form.scope,
|
67
70
|
component: form.component,
|
@@ -73,6 +76,10 @@ module Decidim
|
|
73
76
|
}
|
74
77
|
end
|
75
78
|
|
79
|
+
def link_author_meeeting
|
80
|
+
proposal.link_resources(form.author, "proposals_from_meeting")
|
81
|
+
end
|
82
|
+
|
76
83
|
def send_notification
|
77
84
|
Decidim::EventsManager.publish(
|
78
85
|
event: "decidim.events.proposals.proposal_published",
|
@@ -24,6 +24,7 @@ module Decidim
|
|
24
24
|
return broadcast(:invalid) if form.invalid?
|
25
25
|
|
26
26
|
create_proposal_note
|
27
|
+
notify_admins_and_valuators
|
27
28
|
|
28
29
|
broadcast(:ok, proposal_note)
|
29
30
|
end
|
@@ -46,6 +47,20 @@ module Decidim
|
|
46
47
|
}
|
47
48
|
)
|
48
49
|
end
|
50
|
+
|
51
|
+
def notify_admins_and_valuators
|
52
|
+
affected_users = Decidim::User.org_admins_except_me(form.current_user).all
|
53
|
+
affected_users += Decidim::Proposals::ValuationAssignment.includes(valuator_role: :user).where.not(id: form.current_user.id).where(proposal: proposal).map(&:valuator)
|
54
|
+
|
55
|
+
data = {
|
56
|
+
event: "decidim.events.proposals.admin.proposal_note_created",
|
57
|
+
event_class: Decidim::Proposals::Admin::ProposalNoteCreatedEvent,
|
58
|
+
resource: proposal,
|
59
|
+
affected_users: affected_users
|
60
|
+
}
|
61
|
+
|
62
|
+
Decidim::EventsManager.publish(data)
|
63
|
+
end
|
49
64
|
end
|
50
65
|
end
|
51
66
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
module Admin
|
6
|
+
# A command to notify about the change of the published state for a proposal.
|
7
|
+
class NotifyProposalAnswer < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# proposal - The proposal to write the answer for.
|
11
|
+
# initial_state - The proposal state before the current process.
|
12
|
+
def initialize(proposal, initial_state)
|
13
|
+
@proposal = proposal
|
14
|
+
@initial_state = initial_state.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
# Executes the command. Broadcasts these events:
|
18
|
+
#
|
19
|
+
# - :noop when the answer is not published or the state didn't changed.
|
20
|
+
# - :ok when everything is valid.
|
21
|
+
#
|
22
|
+
# Returns nothing.
|
23
|
+
def call
|
24
|
+
if proposal.published_state? && state_changed?
|
25
|
+
transaction do
|
26
|
+
increment_score
|
27
|
+
notify_followers
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
broadcast(:ok)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :proposal, :initial_state
|
37
|
+
|
38
|
+
def state_changed?
|
39
|
+
initial_state != proposal.state.to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
def notify_followers
|
43
|
+
if proposal.accepted?
|
44
|
+
publish_event(
|
45
|
+
"decidim.events.proposals.proposal_accepted",
|
46
|
+
Decidim::Proposals::AcceptedProposalEvent
|
47
|
+
)
|
48
|
+
elsif proposal.rejected?
|
49
|
+
publish_event(
|
50
|
+
"decidim.events.proposals.proposal_rejected",
|
51
|
+
Decidim::Proposals::RejectedProposalEvent
|
52
|
+
)
|
53
|
+
elsif proposal.evaluating?
|
54
|
+
publish_event(
|
55
|
+
"decidim.events.proposals.proposal_evaluating",
|
56
|
+
Decidim::Proposals::EvaluatingProposalEvent
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def publish_event(event, event_class)
|
62
|
+
Decidim::EventsManager.publish(
|
63
|
+
event: event,
|
64
|
+
event_class: event_class,
|
65
|
+
resource: proposal,
|
66
|
+
affected_users: proposal.notifiable_identities,
|
67
|
+
followers: proposal.followers - proposal.notifiable_identities
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
def increment_score
|
72
|
+
if proposal.accepted?
|
73
|
+
proposal.coauthorships.find_each do |coauthorship|
|
74
|
+
Decidim::Gamification.increment_score(coauthorship.user_group || coauthorship.author, :accepted_proposals)
|
75
|
+
end
|
76
|
+
elsif initial_state == "accepted"
|
77
|
+
proposal.coauthorships.find_each do |coauthorship|
|
78
|
+
Decidim::Gamification.decrement_score(coauthorship.user_group || coauthorship.author, :accepted_proposals)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|