decidim-proposals 0.30.2 → 0.31.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/cells/decidim/proposals/collaborative_draft_metadata_cell.rb +1 -1
- data/app/cells/decidim/proposals/proposal_g_cell.rb +4 -4
- data/app/cells/decidim/proposals/proposal_l_cell.rb +4 -4
- data/app/cells/decidim/proposals/proposal_metadata_cell.rb +2 -2
- data/app/commands/decidim/proposals/admin/{assign_proposals_to_valuator.rb → assign_proposals_to_evaluator.rb} +16 -16
- data/app/commands/decidim/proposals/admin/create_proposal.rb +1 -2
- data/app/commands/decidim/proposals/admin/create_proposal_note.rb +4 -4
- data/app/commands/decidim/proposals/admin/merge_proposals.rb +60 -13
- data/app/commands/decidim/proposals/admin/notify_proposal_answer.rb +2 -2
- data/app/commands/decidim/proposals/admin/proposal_notes_methods.rb +5 -5
- data/app/commands/decidim/proposals/admin/reply_proposal_note.rb +1 -1
- data/app/commands/decidim/proposals/admin/{unassign_proposals_from_valuator.rb → unassign_proposals_from_evaluator.rb} +7 -7
- data/app/commands/decidim/proposals/admin/update_proposal.rb +1 -2
- data/app/commands/decidim/proposals/create_collaborative_draft.rb +3 -8
- data/app/commands/decidim/proposals/create_proposal.rb +4 -17
- data/app/commands/decidim/proposals/publish_collaborative_draft.rb +2 -2
- data/app/commands/decidim/proposals/publish_proposal.rb +1 -5
- data/app/commands/decidim/proposals/update_collaborative_draft.rb +2 -4
- data/app/commands/decidim/proposals/update_proposal.rb +5 -18
- data/app/controllers/concerns/decidim/proposals/admin/filterable.rb +6 -6
- data/app/controllers/concerns/decidim/proposals/orderable.rb +3 -3
- data/app/controllers/decidim/proposals/admin/evaluation_assignments_controller.rb +55 -0
- data/app/controllers/decidim/proposals/admin/participatory_texts_controller.rb +6 -6
- data/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +1 -1
- data/app/controllers/decidim/proposals/admin/proposal_states_controller.rb +2 -2
- data/app/controllers/decidim/proposals/admin/proposals_controller.rb +2 -2
- data/app/controllers/decidim/proposals/admin/proposals_imports_controller.rb +1 -1
- data/app/controllers/decidim/proposals/admin/proposals_merges_controller.rb +12 -3
- data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +2 -3
- data/app/controllers/decidim/proposals/proposals_controller.rb +5 -6
- data/app/events/decidim/proposals/admin/{proposal_assigned_to_valuator_event.rb → proposal_assigned_to_evaluator_event.rb} +1 -1
- data/app/events/decidim/proposals/{endorsing_enabled_event.rb → liking_enabled_event.rb} +1 -1
- data/app/events/decidim/proposals/merged_proposal_event.rb +9 -0
- data/app/events/decidim/proposals/proposal_liked_event.rb +33 -0
- data/app/forms/decidim/proposals/admin/evaluation_assignment_form.rb +38 -0
- data/app/forms/decidim/proposals/admin/proposal_base_form.rb +1 -27
- data/app/forms/decidim/proposals/admin/proposals_fork_form.rb +1 -1
- data/app/forms/decidim/proposals/admin/proposals_merge_form.rb +58 -2
- data/app/forms/decidim/proposals/collaborative_draft_form.rb +1 -5
- data/app/forms/decidim/proposals/proposal_form.rb +0 -29
- data/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb +8 -8
- data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +6 -6
- data/app/helpers/decidim/proposals/admin/proposals_helper.rb +2 -17
- data/app/helpers/decidim/proposals/application_helper.rb +3 -6
- data/app/jobs/decidim/proposals/settings_change_job.rb +6 -6
- data/app/models/decidim/proposals/collaborative_draft.rb +1 -1
- data/app/models/decidim/proposals/{valuation_assignment.rb → evaluation_assignment.rb} +7 -7
- data/app/models/decidim/proposals/proposal.rb +22 -32
- data/app/packs/entrypoints/decidim_proposals_admin.js +1 -0
- data/app/packs/src/decidim/proposals/add_proposal.js +1 -1
- data/app/packs/src/decidim/proposals/admin/proposals.js +22 -11
- data/app/packs/src/decidim/proposals/admin/proposals_form.js +1 -1
- data/app/packs/src/decidim/proposals/admin/proposals_merge.js +92 -0
- data/app/packs/src/decidim/proposals/choose_proposals.js +1 -1
- data/app/packs/src/decidim/proposals/exit_handler.js +1 -1
- data/app/packs/src/decidim/proposals/utils.js +1 -1
- data/app/packs/stylesheets/decidim/proposals/proposals.scss +29 -1
- data/app/permissions/decidim/proposals/admin/permissions.rb +20 -20
- data/app/presenters/decidim/proposals/admin_log/{valuation_assignment_presenter.rb → evaluation_assignment_presenter.rb} +7 -7
- data/app/presenters/decidim/proposals/admin_log/proposal_presenter.rb +15 -0
- data/app/presenters/decidim/proposals/admin_log/value_types/{valuator_role_user_presenter.rb → evaluator_role_user_presenter.rb} +2 -2
- data/app/presenters/decidim/proposals/admin_log/value_types/proposal_title_body_presenter.rb +1 -1
- data/app/presenters/decidim/proposals/collaborative_draft_presenter.rb +1 -6
- data/app/presenters/decidim/proposals/log/{valuation_assignment_presenter.rb → evaluation_assignment_presenter.rb} +1 -1
- data/app/presenters/decidim/proposals/proposal_presenter.rb +9 -13
- data/app/services/decidim/proposals/diff_renderer.rb +0 -1
- data/app/services/decidim/proposals/proposal_builder.rb +5 -10
- data/app/views/decidim/proposals/admin/participatory_texts/_article-preview.html.erb +1 -1
- data/app/views/decidim/proposals/admin/participatory_texts/index.html.erb +1 -2
- 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 +1 -1
- data/app/views/decidim/proposals/admin/proposal_states/index.html.erb +42 -12
- data/app/views/decidim/proposals/admin/proposals/_actions.html.erb +87 -21
- data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +9 -13
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +2 -24
- data/app/views/decidim/proposals/admin/proposals/_likes.html.erb +25 -0
- data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +13 -12
- data/app/views/decidim/proposals/admin/proposals/_proposals-thead.html.erb +1 -1
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_assign_to_evaluator.html.erb +19 -0
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_dropdown.html.erb +45 -49
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/{_valuators_picker.html.erb → _evaluators_picker.html.erb} +4 -4
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_merge.html.erb +7 -14
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_unassign_from_evaluator.html.erb +19 -0
- data/app/views/decidim/proposals/admin/proposals/index.html.erb +9 -5
- data/app/views/decidim/proposals/admin/proposals/manage_trash.html.erb +2 -1
- data/app/views/decidim/proposals/admin/proposals/show.html.erb +17 -17
- data/app/views/decidim/proposals/admin/proposals_merges/_form.html.erb +49 -0
- data/app/views/decidim/proposals/admin/proposals_merges/new.html.erb +14 -0
- data/app/views/decidim/proposals/collaborative_drafts/_collaborative_actions.html.erb +2 -2
- data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +1 -21
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/_actions.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +1 -21
- data/app/views/decidim/proposals/proposals/_proposal_actions.html.erb +4 -4
- data/app/views/decidim/proposals/proposals/_proposal_aside.html.erb +2 -2
- data/app/views/decidim/proposals/proposals/_proposal_voting_rules.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/participatory_texts/_view_index.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/preview.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/show.html.erb +2 -2
- data/config/assets.rb +2 -2
- data/config/locales/ar.yml +0 -65
- data/config/locales/bg.yml +0 -71
- data/config/locales/bs-BA.yml +0 -25
- data/config/locales/ca-IT.yml +64 -72
- data/config/locales/ca.yml +64 -72
- data/config/locales/cs.yml +52 -81
- data/config/locales/de.yml +66 -73
- data/config/locales/el.yml +0 -66
- data/config/locales/en.yml +69 -77
- data/config/locales/es-MX.yml +68 -76
- data/config/locales/es-PY.yml +68 -76
- data/config/locales/es.yml +68 -76
- data/config/locales/eu.yml +66 -74
- data/config/locales/fi-plain.yml +67 -75
- data/config/locales/fi.yml +67 -75
- data/config/locales/fr-CA.yml +49 -74
- data/config/locales/fr.yml +49 -74
- data/config/locales/ga-IE.yml +0 -22
- data/config/locales/gl.yml +0 -47
- data/config/locales/hu.yml +0 -64
- data/config/locales/id-ID.yml +0 -34
- data/config/locales/is-IS.yml +0 -14
- data/config/locales/it.yml +0 -58
- data/config/locales/ja.yml +68 -76
- data/config/locales/lb.yml +0 -3
- data/config/locales/lt.yml +0 -68
- data/config/locales/lv.yml +0 -62
- data/config/locales/nl.yml +0 -63
- data/config/locales/no.yml +0 -42
- data/config/locales/pl.yml +0 -73
- data/config/locales/pt-BR.yml +0 -59
- data/config/locales/pt.yml +0 -60
- data/config/locales/ro-RO.yml +45 -64
- data/config/locales/ru.yml +0 -15
- data/config/locales/sk.yml +0 -60
- data/config/locales/sr-CS.yml +0 -25
- data/config/locales/sv.yml +58 -76
- data/config/locales/tr-TR.yml +0 -58
- data/config/locales/uk.yml +0 -15
- data/config/locales/zh-CN.yml +0 -57
- data/config/locales/zh-TW.yml +0 -65
- data/db/migrate/20240110203500_add_withdrawn_at_field_to_proposals.rb +1 -1
- data/db/migrate/20240110203504_create_default_proposal_states.rb +1 -1
- data/db/migrate/20250121110014_rename_proposal_valuation_assignments_to_evaluation_assignments.rb +15 -0
- data/db/migrate/20250121110904_rename_valuation_assignments_count_to_evaluation_assignments_count.rb +16 -0
- data/db/migrate/20250211141313_rename_valuator_columns.rb +8 -0
- data/db/migrate/20250515132351_rename_proposals_endorsements_count_to_likes.rb +7 -0
- data/decidim-proposals.gemspec +1 -1
- data/lib/decidim/api/mutations/answer_proposal_attributes.rb +17 -0
- data/lib/decidim/api/mutations/proposal_answer_type.rb +57 -0
- data/lib/decidim/api/mutations/proposal_mutation_type.rb +14 -0
- data/lib/decidim/api/mutations/proposals_mutation_type.rb +23 -0
- data/lib/decidim/api/proposal_input_sort.rb +1 -1
- data/lib/decidim/api/proposal_state_type.rb +16 -0
- data/lib/decidim/api/proposal_type.rb +59 -9
- data/lib/decidim/proposals/admin_engine.rb +3 -3
- data/lib/decidim/proposals/admin_filter.rb +3 -3
- data/lib/decidim/proposals/api.rb +5 -0
- data/lib/decidim/proposals/component.rb +44 -24
- data/lib/decidim/proposals/engine.rb +18 -83
- data/lib/decidim/proposals/evaluable.rb +22 -0
- data/lib/decidim/proposals/import/proposal_creator.rb +1 -1
- data/lib/decidim/proposals/proposal_serializer.rb +9 -11
- data/lib/decidim/proposals/seeds.rb +16 -27
- data/lib/decidim/proposals/test/factories.rb +21 -53
- data/lib/decidim/proposals/version.rb +1 -1
- data/lib/decidim/proposals.rb +3 -3
- data/lib/tasks/proposals/upgrade/decidim_proposals_upgrade_tasks.rake +11 -11
- metadata +57 -47
- data/app/commands/decidim/proposals/hashtags_methods.rb +0 -36
- data/app/controllers/decidim/proposals/admin/valuation_assignments_controller.rb +0 -55
- data/app/events/decidim/proposals/proposal_endorsed_event.rb +0 -33
- data/app/forms/decidim/proposals/admin/proposals_file_import_form.rb +0 -31
- data/app/forms/decidim/proposals/admin/valuation_assignment_form.rb +0 -38
- data/app/queries/decidim/proposals/metrics/accepted_proposals_metric_manage.rb +0 -32
- data/app/queries/decidim/proposals/metrics/endorsements_metric_manage.rb +0 -58
- data/app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb +0 -58
- data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +0 -74
- data/app/queries/decidim/proposals/metrics/proposals_metric_manage.rb +0 -48
- data/app/queries/decidim/proposals/metrics/votes_metric_manage.rb +0 -52
- data/app/views/decidim/proposals/admin/imports/_proposals_fields.html.erb +0 -11
- data/app/views/decidim/proposals/admin/proposals/_endorsers.html.erb +0 -25
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_assign_to_valuator.html.erb +0 -19
- data/app/views/decidim/proposals/admin/proposals/bulk_actions/_unassign_from_valuator.html.erb +0 -19
- data/lib/decidim/proposals/valuatable.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b283ade8fd7d63eac2fe92aa69a580208c0c427cf28e2b71f8b472e0266389c8
|
4
|
+
data.tar.gz: b391777fac9fcf5614ab9c06e3228d2780e9148c35f24d4224fc2c2d2d6845a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 851785384ef2cbbbcd3beaacc0cdb7a15f1e81480554b9bb7dae36bcfc442ac65b18bf9a6023097b26c49ef2d847b025f26b1ed988311dbe09122f41fe87ecd5
|
7
|
+
data.tar.gz: 7d01c9e12ccc3dd7c2a736d2786c122e9fbf0077a306fd266a3dc73b2f9efa07b039e692f32f456164b4cb2762356f8879f3ba3f1495448859be2ba7b5f17dbe
|
@@ -55,13 +55,13 @@ module Decidim
|
|
55
55
|
hash << model.cache_key_with_version
|
56
56
|
hash << model.proposal_votes_count
|
57
57
|
hash << options[:show_voting] ? 0 : 1
|
58
|
-
hash << model.
|
58
|
+
hash << model.likes_count
|
59
59
|
hash << model.comments_count
|
60
|
-
hash << Digest::
|
61
|
-
hash << Digest::
|
60
|
+
hash << Digest::SHA256.hexdigest(model.component.cache_key_with_version)
|
61
|
+
hash << Digest::SHA256.hexdigest(resource_image_url) if resource_image_url
|
62
62
|
hash << 0 # render space
|
63
63
|
hash << model.follows_count
|
64
|
-
hash << Digest::
|
64
|
+
hash << Digest::SHA256.hexdigest(model.authors.map(&:cache_key_with_version).to_s)
|
65
65
|
hash << (model.must_render_translation?(model.organization) ? 1 : 0) if model.respond_to?(:must_render_translation?)
|
66
66
|
hash << model.component.participatory_space.active_step.id if model.component.participatory_space.try(:active_step)
|
67
67
|
hash << (current_user&.id || 0)
|
@@ -37,13 +37,13 @@ module Decidim
|
|
37
37
|
hash << model.cache_key_with_version
|
38
38
|
hash << model.proposal_votes_count
|
39
39
|
hash << options[:show_voting] ? 0 : 1
|
40
|
-
hash << model.
|
40
|
+
hash << model.likes_count
|
41
41
|
hash << model.comments_count
|
42
|
-
hash << Digest::
|
43
|
-
hash << Digest::
|
42
|
+
hash << Digest::SHA256.hexdigest(model.component.cache_key_with_version)
|
43
|
+
hash << Digest::SHA256.hexdigest(resource_image_url) if resource_image_url
|
44
44
|
hash << render_space? ? 1 : 0
|
45
45
|
hash << model.follows_count
|
46
|
-
hash << Digest::
|
46
|
+
hash << Digest::SHA256.hexdigest(model.authors.map(&:cache_key_with_version).to_s)
|
47
47
|
hash << (model.must_render_translation?(model.organization) ? 1 : 0) if model.respond_to?(:must_render_translation?)
|
48
48
|
hash << model.component.participatory_space.active_step.id if model.component.participatory_space.try(:active_step)
|
49
49
|
hash << (current_user&.id || 0)
|
@@ -44,11 +44,11 @@ module Decidim
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def proposal_items
|
47
|
-
[coauthors_item] + taxonomy_items + [comments_count_item,
|
47
|
+
[coauthors_item] + taxonomy_items + [comments_count_item, likes_count_item, state_item, emendation_item]
|
48
48
|
end
|
49
49
|
|
50
50
|
def items_for_map
|
51
|
-
[coauthors_item_for_map, comments_count_item,
|
51
|
+
[coauthors_item_for_map, comments_count_item, likes_count_item, state_item, emendation_item].compact_blank.map do |item|
|
52
52
|
{
|
53
53
|
text: item[:text].to_s.html_safe,
|
54
54
|
icon: item[:icon].present? ? icon(item[:icon]).html_safe : nil
|
@@ -4,8 +4,8 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic to assign proposals to a given
|
7
|
-
#
|
8
|
-
class
|
7
|
+
# evaluator.
|
8
|
+
class AssignProposalsToEvaluator < Decidim::Command
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# form - A form object with the params.
|
@@ -35,38 +35,38 @@ module Decidim
|
|
35
35
|
def assign_proposals
|
36
36
|
transaction do
|
37
37
|
form.proposals.flat_map do |proposal|
|
38
|
-
form.
|
39
|
-
find_assignment(proposal,
|
40
|
-
|
38
|
+
form.evaluator_roles.each do |evaluator_role|
|
39
|
+
find_assignment(proposal, evaluator_role) || assign_proposal(proposal, evaluator_role)
|
40
|
+
notify_evaluator(proposal, evaluator_role)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
def find_assignment(proposal,
|
47
|
-
Decidim::Proposals::
|
46
|
+
def find_assignment(proposal, evaluator_role)
|
47
|
+
Decidim::Proposals::EvaluationAssignment.find_by(
|
48
48
|
proposal:,
|
49
|
-
|
49
|
+
evaluator_role:
|
50
50
|
)
|
51
51
|
end
|
52
52
|
|
53
|
-
def assign_proposal(proposal,
|
53
|
+
def assign_proposal(proposal, evaluator_role)
|
54
54
|
Decidim.traceability.create!(
|
55
|
-
Decidim::Proposals::
|
55
|
+
Decidim::Proposals::EvaluationAssignment,
|
56
56
|
form.current_user,
|
57
57
|
proposal:,
|
58
|
-
|
58
|
+
evaluator_role:
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
63
|
-
return unless
|
62
|
+
def notify_evaluator(proposal, evaluator_role)
|
63
|
+
return unless evaluator_role.user.email_on_assigned_proposals?
|
64
64
|
|
65
65
|
data = {
|
66
|
-
event: "decidim.events.proposals.admin.
|
67
|
-
event_class: Decidim::Proposals::Admin::
|
66
|
+
event: "decidim.events.proposals.admin.proposal_assigned_to_evaluator",
|
67
|
+
event_class: Decidim::Proposals::Admin::ProposalAssignedToEvaluatorEvent,
|
68
68
|
resource: proposal,
|
69
|
-
affected_users: [
|
69
|
+
affected_users: [evaluator_role.user]
|
70
70
|
}
|
71
71
|
|
72
72
|
Decidim::EventsManager.publish(**data)
|
@@ -6,7 +6,6 @@ module Decidim
|
|
6
6
|
# A command with all the business logic when a user creates a new proposal.
|
7
7
|
class CreateProposal < Decidim::Command
|
8
8
|
include ::Decidim::MultipleAttachmentsMethods
|
9
|
-
include HashtagsMethods
|
10
9
|
|
11
10
|
# Public: Initializes the command.
|
12
11
|
#
|
@@ -57,7 +56,7 @@ module Decidim
|
|
57
56
|
end
|
58
57
|
|
59
58
|
def attributes
|
60
|
-
parsed_title = Decidim::ContentProcessor.
|
59
|
+
parsed_title = Decidim::ContentProcessor.parse(form.title, current_organization: form.current_organization).rewrite
|
61
60
|
parsed_body = Decidim::ContentProcessor.parse(form.body, current_organization: form.current_organization).rewrite
|
62
61
|
{
|
63
62
|
title: parsed_title,
|
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
|
28
28
|
create_proposal_note
|
29
29
|
notify_mentioned
|
30
|
-
|
30
|
+
notify_not_mentioned_evaluators
|
31
31
|
|
32
32
|
broadcast(:ok, proposal_note)
|
33
33
|
end
|
@@ -52,11 +52,11 @@ module Decidim
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def notify_mentioned
|
55
|
-
notify_creation(
|
55
|
+
notify_creation(mentioned_admins_or_evaluators, "decidim.events.proposals.admin.proposal_note_mentioned")
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
59
|
-
notify_creation(
|
58
|
+
def notify_not_mentioned_evaluators
|
59
|
+
notify_creation(proposal_evaluators - mentioned_admins_or_evaluators, "decidim.events.proposals.admin.proposal_note_created")
|
60
60
|
end
|
61
61
|
|
62
62
|
def notify_creation(affected_users, event)
|
@@ -6,6 +6,7 @@ module Decidim
|
|
6
6
|
# A command with all the business logic when an admin merges proposals from
|
7
7
|
# one component to another.
|
8
8
|
class MergeProposals < Decidim::Command
|
9
|
+
include ::Decidim::MultipleAttachmentsMethods
|
9
10
|
# Public: Initializes the command.
|
10
11
|
#
|
11
12
|
# form - A form object with the params.
|
@@ -22,25 +23,38 @@ module Decidim
|
|
22
23
|
def call
|
23
24
|
return broadcast(:invalid) unless form.valid?
|
24
25
|
|
25
|
-
|
26
|
+
if process_attachments?
|
27
|
+
build_attachments
|
28
|
+
return broadcast(:invalid) if attachments_invalid?
|
29
|
+
end
|
30
|
+
|
31
|
+
transaction do
|
32
|
+
merged_proposals
|
33
|
+
end
|
34
|
+
|
35
|
+
broadcast(:ok, @merge_proposal)
|
26
36
|
end
|
27
37
|
|
28
38
|
private
|
29
39
|
|
30
|
-
attr_reader :form
|
40
|
+
attr_reader :form, :attachment
|
31
41
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
42
|
+
def merged_proposals
|
43
|
+
@merged_proposal = create_new_proposal
|
44
|
+
merge_authors
|
45
|
+
@merged_proposal.link_resources(proposals_to_link, "merged_from_component")
|
46
|
+
proposals_mark_as_withdrawn if form.same_component?
|
47
|
+
@attached_to = @merged_proposal
|
48
|
+
create_attachments(first_weight: first_attachment_weight) if process_attachments?
|
49
|
+
link_author_meeting if form.created_in_meeting?
|
50
|
+
notify_author
|
39
51
|
end
|
40
52
|
|
41
|
-
def
|
42
|
-
|
53
|
+
def proposals_mark_as_withdrawn
|
54
|
+
form.proposals.each(&:withdraw!)
|
55
|
+
end
|
43
56
|
|
57
|
+
def proposals_to_link
|
44
58
|
form.proposals
|
45
59
|
end
|
46
60
|
|
@@ -55,14 +69,47 @@ module Decidim
|
|
55
69
|
|
56
70
|
Decidim::Proposals::ProposalBuilder.copy(
|
57
71
|
original_proposal,
|
58
|
-
author: form.current_organization,
|
72
|
+
author: form.created_in_meeting ? form.author : form.current_organization,
|
59
73
|
action_user: form.current_user,
|
60
74
|
extra_attributes: {
|
61
|
-
component: form.target_component
|
75
|
+
component: form.target_component,
|
76
|
+
title: form.title,
|
77
|
+
body: form.body,
|
78
|
+
address: form.address,
|
79
|
+
latitude: form.latitude,
|
80
|
+
longitude: form.longitude,
|
81
|
+
created_in_meeting: form.created_in_meeting
|
62
82
|
},
|
63
83
|
skip_link: true
|
64
84
|
)
|
65
85
|
end
|
86
|
+
|
87
|
+
def merge_authors
|
88
|
+
authors = form.proposals.flat_map(&:authors).sort_by { |author| author.is_a?(Decidim::Meetings::Meeting) ? 0 : 1 }
|
89
|
+
|
90
|
+
authors.each { |author| @merged_proposal.add_coauthor(author) unless @merged_proposal.authors.include?(author) }
|
91
|
+
end
|
92
|
+
|
93
|
+
def notify_author
|
94
|
+
return unless @merged_proposal.coauthorships.any?
|
95
|
+
|
96
|
+
Decidim::EventsManager.publish(
|
97
|
+
event: "decidim.events.proposals.proposal_merged",
|
98
|
+
event_class: Decidim::Proposals::MergedProposalEvent,
|
99
|
+
resource: @merged_proposal,
|
100
|
+
affected_users: @merged_proposal.notifiable_identities
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
def first_attachment_weight
|
105
|
+
return 1 if @merged_proposal.photos.count.zero?
|
106
|
+
|
107
|
+
@merged_proposal.photos.count
|
108
|
+
end
|
109
|
+
|
110
|
+
def link_author_meeting
|
111
|
+
@merged_proposal.link_resources(form.author, "proposals_from_meeting")
|
112
|
+
end
|
66
113
|
end
|
67
114
|
end
|
68
115
|
end
|
@@ -56,11 +56,11 @@ module Decidim
|
|
56
56
|
def increment_score
|
57
57
|
if proposal.accepted?
|
58
58
|
proposal.coauthorships.find_each do |coauthorship|
|
59
|
-
Decidim::Gamification.increment_score(coauthorship.
|
59
|
+
Decidim::Gamification.increment_score(coauthorship.author, :accepted_proposals)
|
60
60
|
end
|
61
61
|
elsif initial_state == "accepted"
|
62
62
|
proposal.coauthorships.find_each do |coauthorship|
|
63
|
-
Decidim::Gamification.decrement_score(coauthorship.
|
63
|
+
Decidim::Gamification.decrement_score(coauthorship.author, :accepted_proposals)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -19,9 +19,9 @@ module Decidim
|
|
19
19
|
@rewritten_body ||= parsed_body.rewrite
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
@
|
24
|
-
assignment.
|
22
|
+
def proposal_evaluators
|
23
|
+
@proposal_evaluators ||= Decidim::Proposals::EvaluationAssignment.where(proposal:).filter_map do |assignment|
|
24
|
+
assignment.evaluator unless assignment.evaluator == form.current_user
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -35,11 +35,11 @@ module Decidim
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def mentioned_admins_or_evaluators
|
39
39
|
mentioned_users.select do |user|
|
40
40
|
admins.exists?(user.id) ||
|
41
41
|
space_admins.include?(user) ||
|
42
|
-
|
42
|
+
proposal_evaluators.include?(user)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -4,8 +4,8 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic to unassign proposals from a given
|
7
|
-
#
|
8
|
-
class
|
7
|
+
# evaluator.
|
8
|
+
class UnassignProposalsFromEvaluator < Decidim::Command
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# form - A form object with the params.
|
@@ -33,18 +33,18 @@ module Decidim
|
|
33
33
|
def unassign_proposals
|
34
34
|
transaction do
|
35
35
|
form.proposals.flat_map do |proposal|
|
36
|
-
form.
|
37
|
-
assignment = find_assignment(proposal,
|
36
|
+
form.evaluator_roles.each do |evaluator_role|
|
37
|
+
assignment = find_assignment(proposal, evaluator_role)
|
38
38
|
unassign(assignment) if assignment
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def find_assignment(proposal,
|
45
|
-
Decidim::Proposals::
|
44
|
+
def find_assignment(proposal, evaluator_role)
|
45
|
+
Decidim::Proposals::EvaluationAssignment.find_by(
|
46
46
|
proposal:,
|
47
|
-
|
47
|
+
evaluator_role:
|
48
48
|
)
|
49
49
|
end
|
50
50
|
|
@@ -6,7 +6,6 @@ module Decidim
|
|
6
6
|
# A command with all the business logic when a user updates a proposal.
|
7
7
|
class UpdateProposal < Decidim::Command
|
8
8
|
include ::Decidim::MultipleAttachmentsMethods
|
9
|
-
include HashtagsMethods
|
10
9
|
|
11
10
|
# Public: Initializes the command.
|
12
11
|
#
|
@@ -53,7 +52,7 @@ module Decidim
|
|
53
52
|
end
|
54
53
|
|
55
54
|
def update_proposal
|
56
|
-
parsed_title = Decidim::ContentProcessor.
|
55
|
+
parsed_title = Decidim::ContentProcessor.parse(form.title, current_organization: form.current_organization).rewrite
|
57
56
|
parsed_body = Decidim::ContentProcessor.parse(form.body, current_organization: form.current_organization).rewrite
|
58
57
|
Decidim.traceability.update!(
|
59
58
|
proposal,
|
@@ -5,7 +5,6 @@ module Decidim
|
|
5
5
|
# A command with all the business logic when a user creates a new collaborative draft.
|
6
6
|
class CreateCollaborativeDraft < Decidim::Command
|
7
7
|
include ::Decidim::MultipleAttachmentsMethods
|
8
|
-
include HashtagsMethods
|
9
8
|
|
10
9
|
# Public: Initializes the command.
|
11
10
|
#
|
@@ -61,8 +60,8 @@ module Decidim
|
|
61
60
|
visibility: "public-only"
|
62
61
|
) do
|
63
62
|
draft = CollaborativeDraft.new(
|
64
|
-
title:
|
65
|
-
body:
|
63
|
+
title: Decidim::ContentProcessor.parse(form.title, current_organization: form.current_organization).rewrite,
|
64
|
+
body: Decidim::ContentProcessor.parse_with_processor(:inline_images, form.body, current_organization: form.current_organization).rewrite,
|
66
65
|
taxonomizations: form.taxonomizations,
|
67
66
|
component: form.component,
|
68
67
|
address: form.address,
|
@@ -70,7 +69,7 @@ module Decidim
|
|
70
69
|
longitude: form.longitude,
|
71
70
|
state: "open"
|
72
71
|
)
|
73
|
-
draft.coauthorships.build(author: @current_user
|
72
|
+
draft.coauthorships.build(author: @current_user)
|
74
73
|
draft.save!
|
75
74
|
draft
|
76
75
|
end
|
@@ -78,10 +77,6 @@ module Decidim
|
|
78
77
|
@attached_to = @collaborative_draft
|
79
78
|
end
|
80
79
|
|
81
|
-
def user_group
|
82
|
-
@user_group ||= Decidim::UserGroup.find_by(organization:, id: form.user_group_id)
|
83
|
-
end
|
84
|
-
|
85
80
|
def organization
|
86
81
|
@organization ||= @current_user.organization
|
87
82
|
end
|
@@ -5,7 +5,6 @@ module Decidim
|
|
5
5
|
# A command with all the business logic when a user creates a new proposal.
|
6
6
|
class CreateProposal < Decidim::Command
|
7
7
|
include ::Decidim::MultipleAttachmentsMethods
|
8
|
-
include HashtagsMethods
|
9
8
|
|
10
9
|
# Public: Initializes the command.
|
11
10
|
#
|
@@ -74,10 +73,10 @@ module Decidim
|
|
74
73
|
) do
|
75
74
|
proposal = Proposal.new(
|
76
75
|
title: {
|
77
|
-
I18n.locale =>
|
76
|
+
I18n.locale => Decidim::ContentProcessor.parse(form.title, current_organization: form.current_organization).rewrite
|
78
77
|
},
|
79
78
|
body: {
|
80
|
-
I18n.locale =>
|
79
|
+
I18n.locale => Decidim::ContentProcessor.parse_with_processor(:inline_images, form.body, current_organization: form.current_organization).rewrite
|
81
80
|
},
|
82
81
|
component: form.component
|
83
82
|
)
|
@@ -85,7 +84,7 @@ module Decidim
|
|
85
84
|
proposal.taxonomizations = form.taxonomizations if form.taxonomizations.present?
|
86
85
|
proposal.documents = form.documents if form.documents.present?
|
87
86
|
proposal.address = form.address if form.has_address? && !form.geocoded?
|
88
|
-
proposal.add_coauthor(@current_user
|
87
|
+
proposal.add_coauthor(@current_user)
|
89
88
|
proposal.save!
|
90
89
|
@attached_to = proposal
|
91
90
|
proposal
|
@@ -100,15 +99,7 @@ module Decidim
|
|
100
99
|
|
101
100
|
return false if proposal_limit.zero?
|
102
101
|
|
103
|
-
|
104
|
-
user_group_proposals.count >= proposal_limit
|
105
|
-
else
|
106
|
-
current_user_proposals.count >= proposal_limit
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def user_group
|
111
|
-
@user_group ||= Decidim::UserGroup.find_by(organization:, id: form.user_group_id)
|
102
|
+
current_user_proposals.count >= proposal_limit
|
112
103
|
end
|
113
104
|
|
114
105
|
def organization
|
@@ -119,10 +110,6 @@ module Decidim
|
|
119
110
|
Proposal.not_withdrawn.from_author(@current_user).where(component: form.current_component)
|
120
111
|
end
|
121
112
|
|
122
|
-
def user_group_proposals
|
123
|
-
Proposal.not_withdrawn.from_user_group(@user_group).where(component: form.current_component)
|
124
|
-
end
|
125
|
-
|
126
113
|
def first_attachment_weight
|
127
114
|
return 1 if proposal.photos.count.zero?
|
128
115
|
|
@@ -56,8 +56,8 @@ module Decidim
|
|
56
56
|
def proposal_attributes
|
57
57
|
fields = {}
|
58
58
|
|
59
|
-
parsed_title = Decidim::ContentProcessor.
|
60
|
-
parsed_body = Decidim::ContentProcessor.parse_with_processor(:
|
59
|
+
parsed_title = Decidim::ContentProcessor.parse(@collaborative_draft.title, current_organization: @collaborative_draft.organization).rewrite
|
60
|
+
parsed_body = Decidim::ContentProcessor.parse_with_processor(:inline_images, @collaborative_draft.body, current_organization: @collaborative_draft.organization).rewrite
|
61
61
|
|
62
62
|
fields[:title] = { I18n.locale => parsed_title }
|
63
63
|
fields[:body] = { I18n.locale => parsed_body }
|
@@ -93,11 +93,7 @@ module Decidim
|
|
93
93
|
|
94
94
|
def increment_scores
|
95
95
|
@proposal.coauthorships.find_each do |coauthorship|
|
96
|
-
|
97
|
-
Decidim::Gamification.increment_score(coauthorship.user_group, :proposals)
|
98
|
-
else
|
99
|
-
Decidim::Gamification.increment_score(coauthorship.author, :proposals)
|
100
|
-
end
|
96
|
+
Decidim::Gamification.increment_score(coauthorship.author, :proposals)
|
101
97
|
end
|
102
98
|
end
|
103
99
|
end
|
@@ -4,8 +4,6 @@ module Decidim
|
|
4
4
|
module Proposals
|
5
5
|
# A command with all the business logic when a user updates a collaborative_draft.
|
6
6
|
class UpdateCollaborativeDraft < Decidim::Command
|
7
|
-
include HashtagsMethods
|
8
|
-
|
9
7
|
# Public: Initializes the command.
|
10
8
|
#
|
11
9
|
# form - A form object with the params.
|
@@ -59,8 +57,8 @@ module Decidim
|
|
59
57
|
|
60
58
|
def attributes
|
61
59
|
{
|
62
|
-
title:
|
63
|
-
body:
|
60
|
+
title: Decidim::ContentProcessor.parse(form.title, current_organization: form.current_organization).rewrite,
|
61
|
+
body: Decidim::ContentProcessor.parse_with_processor(:inline_images, form.body, current_organization: form.current_organization).rewrite,
|
64
62
|
taxonomizations: form.taxonomizations,
|
65
63
|
address: form.address,
|
66
64
|
latitude: form.latitude,
|
@@ -5,7 +5,6 @@ module Decidim
|
|
5
5
|
# A command with all the business logic when a user updates a proposal.
|
6
6
|
class UpdateProposal < Decidim::Command
|
7
7
|
include ::Decidim::MultipleAttachmentsMethods
|
8
|
-
include HashtagsMethods
|
9
8
|
|
10
9
|
# Public: Initializes the command.
|
11
10
|
#
|
@@ -75,7 +74,7 @@ module Decidim
|
|
75
74
|
PaperTrail.request(enabled: false) do
|
76
75
|
@proposal.update(attributes)
|
77
76
|
@proposal.coauthorships.clear
|
78
|
-
@proposal.add_coauthor(current_user
|
77
|
+
@proposal.add_coauthor(current_user)
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
@@ -87,16 +86,16 @@ module Decidim
|
|
87
86
|
visibility: "public-only"
|
88
87
|
)
|
89
88
|
@proposal.coauthorships.clear
|
90
|
-
@proposal.add_coauthor(current_user
|
89
|
+
@proposal.add_coauthor(current_user)
|
91
90
|
end
|
92
91
|
|
93
92
|
def attributes
|
94
93
|
{
|
95
94
|
title: {
|
96
|
-
I18n.locale =>
|
95
|
+
I18n.locale => Decidim::ContentProcessor.parse(form.title, current_organization: form.current_organization).rewrite
|
97
96
|
},
|
98
97
|
body: {
|
99
|
-
I18n.locale =>
|
98
|
+
I18n.locale => Decidim::ContentProcessor.parse_with_processor(:inline_images, form.body, current_organization: form.current_organization).rewrite
|
100
99
|
},
|
101
100
|
taxonomizations: form.taxonomizations,
|
102
101
|
address: form.address,
|
@@ -110,11 +109,7 @@ module Decidim
|
|
110
109
|
|
111
110
|
return false if proposal_limit.zero?
|
112
111
|
|
113
|
-
|
114
|
-
user_group_proposals.count >= proposal_limit
|
115
|
-
else
|
116
|
-
current_user_proposals.count >= proposal_limit
|
117
|
-
end
|
112
|
+
current_user_proposals.count >= proposal_limit
|
118
113
|
end
|
119
114
|
|
120
115
|
def first_attachment_weight
|
@@ -123,10 +118,6 @@ module Decidim
|
|
123
118
|
proposal.photos.count
|
124
119
|
end
|
125
120
|
|
126
|
-
def user_group
|
127
|
-
@user_group ||= Decidim::UserGroup.find_by(organization:, id: form.user_group_id)
|
128
|
-
end
|
129
|
-
|
130
121
|
def organization
|
131
122
|
@organization ||= current_user.organization
|
132
123
|
end
|
@@ -134,10 +125,6 @@ module Decidim
|
|
134
125
|
def current_user_proposals
|
135
126
|
Proposal.from_author(current_user).where(component: form.current_component).published.where.not(id: proposal.id).not_withdrawn
|
136
127
|
end
|
137
|
-
|
138
|
-
def user_group_proposals
|
139
|
-
Proposal.from_user_group(user_group).where(component: form.current_component).published.where.not(id: proposal.id).not_withdrawn
|
140
|
-
end
|
141
128
|
end
|
142
129
|
end
|
143
130
|
end
|
@@ -27,9 +27,9 @@ module Decidim
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def accessible_proposals_collection
|
30
|
-
return collection if current_participatory_space.user_roles(:
|
30
|
+
return collection if current_participatory_space.user_roles(:evaluator).where(user: current_user).empty?
|
31
31
|
|
32
|
-
collection.
|
32
|
+
collection.with_evaluation_assigned_to(current_user, current_participatory_space)
|
33
33
|
end
|
34
34
|
|
35
35
|
def search_field_predicate
|
@@ -50,12 +50,12 @@ module Decidim
|
|
50
50
|
ProposalState.where(component: current_component).pluck(:token) + ["withdrawn"]
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
54
|
-
current_participatory_space.user_roles(:
|
53
|
+
def evaluator_role_ids
|
54
|
+
current_participatory_space.user_roles(:evaluator).order_by_name.pluck(:id)
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
58
|
-
user_role = current_participatory_space.user_roles(:
|
57
|
+
def translated_evaluator_role_ids_has(evaluator_role_id)
|
58
|
+
user_role = current_participatory_space.user_roles(:evaluator).find_by(id: evaluator_role_id)
|
59
59
|
user_role&.user&.name
|
60
60
|
end
|
61
61
|
end
|