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
@@ -9,9 +9,6 @@ module Decidim
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def save
|
12
|
-
return @registry if @registry
|
13
|
-
|
14
|
-
@registry = []
|
15
12
|
cumulative.each do |key, cumulative_value|
|
16
13
|
next if cumulative_value.zero?
|
17
14
|
|
@@ -21,10 +18,8 @@ module Decidim
|
|
21
18
|
organization: @organization, decidim_category_id: category_id,
|
22
19
|
participatory_space_type: space_type, participatory_space_id: space_id)
|
23
20
|
record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
|
24
|
-
|
21
|
+
record.save!
|
25
22
|
end
|
26
|
-
@registry.each(&:save!)
|
27
|
-
@registry
|
28
23
|
end
|
29
24
|
|
30
25
|
private
|
@@ -35,8 +30,7 @@ module Decidim
|
|
35
30
|
spaces = Decidim.participatory_space_manifests.flat_map do |manifest|
|
36
31
|
manifest.participatory_spaces.call(@organization)
|
37
32
|
end
|
38
|
-
|
39
|
-
@query = Decidim::Proposals::Proposal.where(component: components).joins(:component)
|
33
|
+
@query = Decidim::Proposals::Proposal.where(component: visible_component_ids_from_spaces(spaces)).joins(:component)
|
40
34
|
.left_outer_joins(:category)
|
41
35
|
@query = @query.where("decidim_proposals_proposals.published_at <= ?", end_time).except_withdrawn.not_hidden
|
42
36
|
@query = @query.group("decidim_categorizations.decidim_category_id",
|
@@ -9,9 +9,6 @@ module Decidim
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def save
|
12
|
-
return @registry if @registry
|
13
|
-
|
14
|
-
@registry = []
|
15
12
|
cumulative.each do |key, cumulative_value|
|
16
13
|
next if cumulative_value.zero?
|
17
14
|
|
@@ -22,10 +19,8 @@ module Decidim
|
|
22
19
|
participatory_space_type: space_type, participatory_space_id: space_id,
|
23
20
|
related_object_type: "Decidim::Proposals::Proposal", related_object_id: proposal_id)
|
24
21
|
record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
|
25
|
-
|
22
|
+
record.save!
|
26
23
|
end
|
27
|
-
@registry.each(&:save!)
|
28
|
-
@registry
|
29
24
|
end
|
30
25
|
|
31
26
|
private
|
@@ -36,11 +31,10 @@ module Decidim
|
|
36
31
|
spaces = Decidim.participatory_space_manifests.flat_map do |manifest|
|
37
32
|
manifest.participatory_spaces.call(@organization).public_spaces
|
38
33
|
end
|
39
|
-
|
40
|
-
proposals = Decidim::Proposals::Proposal.where(component: components).except_withdrawn.not_hidden
|
34
|
+
proposal_ids = Decidim::Proposals::Proposal.where(component: visible_component_ids_from_spaces(spaces.pluck(:id))).except_withdrawn.not_hidden.pluck(:id)
|
41
35
|
@query = Decidim::Proposals::ProposalVote.joins(proposal: :component)
|
42
36
|
.left_outer_joins(proposal: :category)
|
43
|
-
.where(proposal:
|
37
|
+
.where(proposal: proposal_ids)
|
44
38
|
@query = @query.where("decidim_proposals_proposal_votes.created_at <= ?", end_time)
|
45
39
|
@query = @query.group("decidim_categorizations.id",
|
46
40
|
:participatory_space_type,
|
@@ -30,8 +30,8 @@ module Decidim
|
|
30
30
|
.published
|
31
31
|
.where(
|
32
32
|
"GREATEST(#{title_similarity}, #{body_similarity}) >= ?",
|
33
|
-
@proposal.title,
|
34
|
-
@proposal.body,
|
33
|
+
translated_attribute(@proposal.title),
|
34
|
+
translated_attribute(@proposal.body),
|
35
35
|
Decidim::Proposals.similarity_threshold
|
36
36
|
)
|
37
37
|
.limit(Decidim::Proposals.similarity_limit)
|
@@ -40,11 +40,11 @@ module Decidim
|
|
40
40
|
private
|
41
41
|
|
42
42
|
def title_similarity
|
43
|
-
"similarity(title, ?)"
|
43
|
+
"similarity(title::text, ?)"
|
44
44
|
end
|
45
45
|
|
46
46
|
def body_similarity
|
47
|
-
"similarity(body, ?)"
|
47
|
+
"similarity(body::text, ?)"
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -5,6 +5,8 @@ module Decidim
|
|
5
5
|
# A service to encapsualte all the logic when searching and filtering
|
6
6
|
# collaborative drafts in a participatory process.
|
7
7
|
class CollaborativeDraftSearch < ResourceSearch
|
8
|
+
text_search_fields :title, :body
|
9
|
+
|
8
10
|
# Public: Initializes the service.
|
9
11
|
# component - A Decidim::Component to get the drafts from.
|
10
12
|
# page - The page number to paginate the results.
|
@@ -14,6 +16,9 @@ module Decidim
|
|
14
16
|
end
|
15
17
|
|
16
18
|
# Handle the search_text filter
|
19
|
+
#
|
20
|
+
# We can't use the search from `ResourceFilter` since these fields aren't
|
21
|
+
# translated.
|
17
22
|
def search_search_text
|
18
23
|
query
|
19
24
|
.where("title ILIKE ?", "%#{search_text}%")
|
@@ -22,16 +27,9 @@ module Decidim
|
|
22
27
|
|
23
28
|
# Handle the state filter
|
24
29
|
def search_state
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
when "withdrawn"
|
29
|
-
query.withdrawn
|
30
|
-
when "published"
|
31
|
-
query.published
|
32
|
-
else
|
33
|
-
query
|
34
|
-
end
|
30
|
+
return query if state.member?("all")
|
31
|
+
|
32
|
+
apply_scopes(%w(open withdrawn published), state)
|
35
33
|
end
|
36
34
|
|
37
35
|
# Filters drafts by the name of the classes they are linked to. By default,
|
@@ -8,8 +8,8 @@ module Decidim
|
|
8
8
|
# Lists which attributes will be diffable and how they should be rendered.
|
9
9
|
def attribute_types
|
10
10
|
{
|
11
|
-
title: :
|
12
|
-
body: :
|
11
|
+
title: :i18n,
|
12
|
+
body: :i18n,
|
13
13
|
decidim_category_id: :category,
|
14
14
|
decidim_scope_id: :scope,
|
15
15
|
address: :string,
|
@@ -21,14 +21,18 @@ module Decidim
|
|
21
21
|
|
22
22
|
# Parses the values before parsing the changeset.
|
23
23
|
def parse_changeset(attribute, values, type, diff)
|
24
|
+
return parse_scope_changeset(attribute, values, type, diff) if type == :scope
|
25
|
+
|
24
26
|
values = parse_values(attribute, values)
|
27
|
+
old_value = values[0]
|
28
|
+
new_value = values[1]
|
25
29
|
|
26
30
|
diff.update(
|
27
31
|
attribute => {
|
28
32
|
type: type,
|
29
33
|
label: I18n.t(attribute, scope: i18n_scope),
|
30
|
-
old_value:
|
31
|
-
new_value:
|
34
|
+
old_value: old_value,
|
35
|
+
new_value: new_value
|
32
36
|
}
|
33
37
|
)
|
34
38
|
end
|
@@ -38,7 +42,15 @@ module Decidim
|
|
38
42
|
# Returns and Array of two Strings.
|
39
43
|
def parse_values(attribute, values)
|
40
44
|
values = [amended_previous_value(attribute), values[1]] if proposal&.emendation?
|
41
|
-
|
45
|
+
if attribute == :body
|
46
|
+
values = values.map do |value|
|
47
|
+
if value.is_a?(Hash)
|
48
|
+
value.values.map { |subvalue| normalize_line_endings(subvalue) }
|
49
|
+
else
|
50
|
+
normalize_line_endings(value)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
42
54
|
values
|
43
55
|
end
|
44
56
|
|
@@ -68,7 +68,7 @@ module Decidim
|
|
68
68
|
"decidim_component_id",
|
69
69
|
"reference",
|
70
70
|
"proposal_votes_count",
|
71
|
-
"
|
71
|
+
"endorsements_count",
|
72
72
|
"proposal_notes_count"
|
73
73
|
).merge(
|
74
74
|
"category" => original_proposal.category
|
@@ -102,8 +102,14 @@ module Decidim
|
|
102
102
|
|
103
103
|
def copy_attachments(original_proposal, proposal)
|
104
104
|
original_proposal.attachments.each do |attachment|
|
105
|
-
new_attachment = Decidim::Attachment.new(
|
106
|
-
|
105
|
+
new_attachment = Decidim::Attachment.new(
|
106
|
+
{
|
107
|
+
# Attached to needs to be always defined before the file is set
|
108
|
+
attached_to: proposal
|
109
|
+
}.merge(
|
110
|
+
attachment.attributes.slice("content_type", "description", "file", "file_size", "title", "weight")
|
111
|
+
)
|
112
|
+
)
|
107
113
|
|
108
114
|
if File.exist?(attachment.file.file.path)
|
109
115
|
new_attachment.file = File.open(attachment.file.file.path)
|
@@ -5,50 +5,15 @@ module Decidim
|
|
5
5
|
# A service to encapsualte all the logic when searching and filtering
|
6
6
|
# proposals in a participatory process.
|
7
7
|
class ProposalSearch < ResourceSearch
|
8
|
+
text_search_fields :title, :body
|
9
|
+
|
8
10
|
# Public: Initializes the service.
|
9
11
|
# component - A Decidim::Component to get the proposals from.
|
10
12
|
# page - The page number to paginate the results.
|
11
13
|
# per_page - The number of proposals to return per page.
|
12
14
|
def initialize(options = {})
|
13
|
-
|
14
|
-
|
15
|
-
super(Proposal.all, options)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Handle the search_text filter
|
19
|
-
def search_search_text
|
20
|
-
query
|
21
|
-
.where("title ILIKE ?", "%#{search_text}%")
|
22
|
-
.or(query.where("body ILIKE ?", "%#{search_text}%"))
|
23
|
-
end
|
24
|
-
|
25
|
-
# Handle the origin filter
|
26
|
-
def search_origin
|
27
|
-
case origin
|
28
|
-
when "official"
|
29
|
-
query
|
30
|
-
.where.not(coauthorships_count: 0)
|
31
|
-
.joins(:coauthorships)
|
32
|
-
.where(decidim_coauthorships: { decidim_author_type: "Decidim::Organization" })
|
33
|
-
when "citizens"
|
34
|
-
query
|
35
|
-
.where.not(coauthorships_count: 0)
|
36
|
-
.joins(:coauthorships)
|
37
|
-
.where.not(decidim_coauthorships: { decidim_author_type: "Decidim::Organization" })
|
38
|
-
when "user_group"
|
39
|
-
query
|
40
|
-
.where.not(coauthorships_count: 0)
|
41
|
-
.joins(:coauthorships)
|
42
|
-
.where(decidim_coauthorships: { decidim_author_type: "Decidim::UserBaseEntity" })
|
43
|
-
.where.not(decidim_coauthorships: { decidim_user_group_id: nil })
|
44
|
-
when "meeting"
|
45
|
-
query
|
46
|
-
.where.not(coauthorships_count: 0)
|
47
|
-
.joins(:coauthorships)
|
48
|
-
.where(decidim_coauthorships: { decidim_author_type: "Decidim::Meetings::Meeting" })
|
49
|
-
else # Assume 'all'
|
50
|
-
query
|
51
|
-
end
|
15
|
+
base = options[:state]&.member?("withdrawn") ? Proposal.withdrawn : Proposal.except_withdrawn
|
16
|
+
super(base, options)
|
52
17
|
end
|
53
18
|
|
54
19
|
# Handle the activity filter
|
@@ -57,13 +22,13 @@ module Decidim
|
|
57
22
|
when "voted"
|
58
23
|
query
|
59
24
|
.includes(:votes)
|
60
|
-
.where(decidim_proposals_proposal_votes: { decidim_author_id:
|
25
|
+
.where(decidim_proposals_proposal_votes: { decidim_author_id: user })
|
61
26
|
when "my_proposals"
|
62
27
|
query
|
63
28
|
.where.not(coauthorships_count: 0)
|
64
29
|
.joins(:coauthorships)
|
65
30
|
.where(decidim_coauthorships: { decidim_author_type: "Decidim::UserBaseEntity" })
|
66
|
-
.where(decidim_coauthorships: { decidim_author_id:
|
31
|
+
.where(decidim_coauthorships: { decidim_author_id: user })
|
67
32
|
else # Assume 'all'
|
68
33
|
query
|
69
34
|
end
|
@@ -71,20 +36,9 @@ module Decidim
|
|
71
36
|
|
72
37
|
# Handle the state filter
|
73
38
|
def search_state
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
when "rejected"
|
78
|
-
query.rejected
|
79
|
-
when "evaluating"
|
80
|
-
query.evaluating
|
81
|
-
when "withdrawn"
|
82
|
-
query.withdrawn
|
83
|
-
when "except_rejected"
|
84
|
-
query.except_rejected.except_withdrawn
|
85
|
-
else # Assume 'not_withdrawn'
|
86
|
-
query.except_withdrawn
|
87
|
-
end
|
39
|
+
return query if state.member? "withdrawn"
|
40
|
+
|
41
|
+
apply_scopes(%w(accepted rejected evaluating state_not_published), state)
|
88
42
|
end
|
89
43
|
|
90
44
|
# Handle the amendment type filter
|
@@ -93,9 +47,9 @@ module Decidim
|
|
93
47
|
when "proposals"
|
94
48
|
query.only_amendables
|
95
49
|
when "amendments"
|
96
|
-
query.only_visible_emendations_for(
|
50
|
+
query.only_visible_emendations_for(user, component)
|
97
51
|
else # Assume 'all'
|
98
|
-
query.amendables_and_visible_emendations_for(
|
52
|
+
query.amendables_and_visible_emendations_for(user, component)
|
99
53
|
end
|
100
54
|
end
|
101
55
|
|
@@ -121,18 +75,6 @@ module Decidim
|
|
121
75
|
|
122
76
|
query.where(id: from).or(query.where(id: to))
|
123
77
|
end
|
124
|
-
|
125
|
-
# We overwrite the `results` method to ensure we only return unique
|
126
|
-
# results. We can't use `#uniq` because it returns an Array and we're
|
127
|
-
# adding scopes in the controller, and `#distinct` doesn't work here
|
128
|
-
# because in the later scopes we're ordering by `RANDOM()` in a DB level,
|
129
|
-
# and `SELECT DISTINCT` doesn't work with `RANDOM()` sorting, so we need
|
130
|
-
# to perform two queries.
|
131
|
-
#
|
132
|
-
# The correct behaviour is backed by tests.
|
133
|
-
def results
|
134
|
-
Proposal.where(id: super.pluck(:id))
|
135
|
-
end
|
136
78
|
end
|
137
79
|
end
|
138
80
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
class ProposalInputFilter < Decidim::Core::BaseInputFilter
|
6
|
+
include Decidim::Core::HasPublishableInputFilter
|
7
|
+
|
8
|
+
graphql_name "ProposalFilter"
|
9
|
+
description "A type used for filtering proposals inside a participatory space.
|
10
|
+
|
11
|
+
A typical query would look like:
|
12
|
+
|
13
|
+
```
|
14
|
+
{
|
15
|
+
participatoryProcesses {
|
16
|
+
components {
|
17
|
+
...on Proposals {
|
18
|
+
proposals(filter:{ publishedBefore: \"2020-01-01\" }) {
|
19
|
+
id
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
```
|
26
|
+
"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Proposals
|
5
|
+
class ProposalInputSort < Decidim::Core::BaseInputSort
|
6
|
+
include Decidim::Core::HasPublishableInputSort
|
7
|
+
include Decidim::Core::HasEndorsableInputSort
|
8
|
+
|
9
|
+
graphql_name "ProposalSort"
|
10
|
+
description "A type used for sorting proposals"
|
11
|
+
|
12
|
+
argument :id, String, "Sort by ID, valid values are ASC or DESC", required: false
|
13
|
+
argument :vote_count,
|
14
|
+
type: String,
|
15
|
+
description: "Sort by number of votes, valid values are ASC or DESC. Will be ignored if votes are hidden",
|
16
|
+
required: false,
|
17
|
+
prepare: ->(value, _ctx) do
|
18
|
+
{ proposal_votes_count: value }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -8,33 +8,54 @@ module Decidim
|
|
8
8
|
|
9
9
|
interfaces [
|
10
10
|
-> { Decidim::Comments::CommentableInterface },
|
11
|
-
-> { Decidim::Core::
|
11
|
+
-> { Decidim::Core::CoauthorableInterface },
|
12
12
|
-> { Decidim::Core::CategorizableInterface },
|
13
13
|
-> { Decidim::Core::ScopableInterface },
|
14
|
-
-> { Decidim::Core::AttachableInterface }
|
14
|
+
-> { Decidim::Core::AttachableInterface },
|
15
|
+
-> { Decidim::Core::FingerprintInterface },
|
16
|
+
-> { Decidim::Core::AmendableInterface },
|
17
|
+
-> { Decidim::Core::AmendableEntityInterface },
|
18
|
+
-> { Decidim::Core::TraceableInterface },
|
19
|
+
-> { Decidim::Core::EndorsableInterface },
|
20
|
+
-> { Decidim::Core::TimestampsInterface }
|
15
21
|
]
|
16
22
|
|
17
23
|
field :id, !types.ID
|
18
|
-
field :title,
|
19
|
-
field :body,
|
20
|
-
field :state, types.String, "The state in which proposal is in"
|
24
|
+
field :title, Decidim::Core::TranslatedFieldType, "The title for this title"
|
25
|
+
field :body, Decidim::Core::TranslatedFieldType, "The description for this body"
|
21
26
|
field :address, types.String, "The physical address (location) of this proposal"
|
22
|
-
field :
|
27
|
+
field :coordinates, Decidim::Core::CoordinatesType, "Physical coordinates for this proposal" do
|
28
|
+
resolve ->(proposal, _args, _ctx) {
|
29
|
+
[proposal.latitude, proposal.longitude]
|
30
|
+
}
|
31
|
+
end
|
32
|
+
field :reference, types.String, "This proposal's unique reference"
|
33
|
+
field :state, types.String, "The answer status in which proposal is in"
|
34
|
+
field :answer, Decidim::Core::TranslatedFieldType, "The answer feedback for the status for this proposal"
|
35
|
+
|
36
|
+
field :answeredAt, Decidim::Core::DateTimeType do
|
37
|
+
description "The date and time this proposal was answered"
|
38
|
+
property :answered_at
|
39
|
+
end
|
23
40
|
|
24
41
|
field :publishedAt, Decidim::Core::DateTimeType do
|
25
42
|
description "The date and time this proposal was published"
|
26
43
|
property :published_at
|
27
44
|
end
|
28
45
|
|
29
|
-
field :
|
30
|
-
|
31
|
-
|
32
|
-
}
|
46
|
+
field :participatoryTextLevel, types.String do
|
47
|
+
description "If it is a participatory text, the level indicates the type of paragraph"
|
48
|
+
property :participatory_text_level
|
33
49
|
end
|
50
|
+
field :position, types.Int, "Position of this proposal in the participatory text"
|
34
51
|
|
35
|
-
field :
|
36
|
-
|
37
|
-
|
52
|
+
field :official, types.Boolean, "Whether this proposal is official or not", property: :official?
|
53
|
+
field :createdInMeeting, types.Boolean, "Whether this proposal comes from a meeting or not", property: :official_meeting?
|
54
|
+
field :meeting, Decidim::Meetings::MeetingType do
|
55
|
+
description "If the proposal comes from a meeting, the related meeting"
|
56
|
+
resolve ->(proposal, _, _) {
|
57
|
+
proposal.authors.first if proposal.official_meeting?
|
58
|
+
}
|
38
59
|
end
|
39
60
|
|
40
61
|
field :voteCount, types.Int do
|