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
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
# A module with all the hash tags common methods for proposals
|
6
|
-
# and collaborative draft commands.
|
7
|
-
module HashtagsMethods
|
8
|
-
private
|
9
|
-
|
10
|
-
def title_with_hashtags
|
11
|
-
@title_with_hashtags ||= Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
|
12
|
-
end
|
13
|
-
|
14
|
-
def body_with_hashtags
|
15
|
-
@body_with_hashtags ||= begin
|
16
|
-
ret = Decidim::ContentProcessor.parse(form.body, current_organization: form.current_organization).rewrite.strip
|
17
|
-
ret += "\n\n#{body_extra_hashtags.strip}" unless body_extra_hashtags.empty?
|
18
|
-
ret
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def body_extra_hashtags
|
23
|
-
@body_extra_hashtags ||= if form.respond_to?(:extra_hashtags)
|
24
|
-
Decidim::ContentProcessor.parse_with_processor(
|
25
|
-
:hashtag,
|
26
|
-
form.extra_hashtags.map { |hashtag| "##{hashtag}" }.join(" "),
|
27
|
-
current_organization: form.current_organization,
|
28
|
-
extra_hashtags: true
|
29
|
-
).rewrite
|
30
|
-
else
|
31
|
-
""
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
module Admin
|
6
|
-
class ValuationAssignmentsController < Admin::ApplicationController
|
7
|
-
def create
|
8
|
-
@form = form(Admin::ValuationAssignmentForm).from_params(params)
|
9
|
-
|
10
|
-
@form.proposals.each do |proposal|
|
11
|
-
enforce_permission_to :assign_to_valuator, :proposals, proposal:
|
12
|
-
end
|
13
|
-
|
14
|
-
Admin::AssignProposalsToValuator.call(@form) do
|
15
|
-
on(:ok) do |_proposal|
|
16
|
-
flash[:notice] = I18n.t("valuation_assignments.create.success", scope: "decidim.proposals.admin")
|
17
|
-
redirect_to EngineRouter.admin_proxy(current_component).root_path
|
18
|
-
end
|
19
|
-
|
20
|
-
on(:invalid) do
|
21
|
-
flash.now[:alert] = I18n.t("valuation_assignments.create.invalid", scope: "decidim.proposals.admin")
|
22
|
-
redirect_to EngineRouter.admin_proxy(current_component).root_path
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def destroy
|
28
|
-
@form = form(Admin::ValuationAssignmentForm).from_params(params)
|
29
|
-
|
30
|
-
@form.valuator_roles.each do |valuator_role|
|
31
|
-
enforce_permission_to :unassign_from_valuator, :proposals, valuator: valuator_role.user
|
32
|
-
end
|
33
|
-
|
34
|
-
Admin::UnassignProposalsFromValuator.call(@form) do
|
35
|
-
on(:ok) do |_proposal|
|
36
|
-
flash.keep[:notice] = I18n.t("valuation_assignments.delete.success", scope: "decidim.proposals.admin")
|
37
|
-
redirect_back fallback_location: EngineRouter.admin_proxy(current_component).root_path
|
38
|
-
end
|
39
|
-
|
40
|
-
on(:invalid) do
|
41
|
-
flash.keep[:alert] = I18n.t("valuation_assignments.delete.invalid", scope: "decidim.proposals.admin")
|
42
|
-
redirect_back fallback_location: EngineRouter.admin_proxy(current_component).root_path
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def skip_manage_component_permission
|
50
|
-
true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
class ProposalEndorsedEvent < Decidim::Events::SimpleEvent
|
6
|
-
i18n_attributes :endorser_nickname, :endorser_name, :endorser_path, :nickname
|
7
|
-
|
8
|
-
delegate :nickname, :name, to: :endorser, prefix: true
|
9
|
-
|
10
|
-
def nickname
|
11
|
-
endorser_nickname
|
12
|
-
end
|
13
|
-
|
14
|
-
def endorser_path
|
15
|
-
endorser.profile_path
|
16
|
-
end
|
17
|
-
|
18
|
-
def resource_text
|
19
|
-
resource.body
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def endorser
|
25
|
-
@endorser ||= Decidim::UserPresenter.new(endorser_user)
|
26
|
-
end
|
27
|
-
|
28
|
-
def endorser_user
|
29
|
-
@endorser_user ||= Decidim::User.find_by(id: extra[:endorser_id])
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
module Admin
|
6
|
-
# A form object to be used when admin users want to import proposals from
|
7
|
-
# a file.
|
8
|
-
class ProposalsFileImportForm < Decidim::Admin::ImportForm
|
9
|
-
attribute :user_group_id, Integer
|
10
|
-
|
11
|
-
def user_groups
|
12
|
-
Decidim::UserGroups::ManageableUserGroups.for(current_user).verified
|
13
|
-
end
|
14
|
-
|
15
|
-
protected
|
16
|
-
|
17
|
-
def user_group
|
18
|
-
@user_group ||= Decidim::UserGroup.find_by(
|
19
|
-
organization: current_organization,
|
20
|
-
id: user_group_id.to_i
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
def importer_context
|
25
|
-
context[:user_group] = user_group
|
26
|
-
context
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
module Admin
|
6
|
-
class ValuationAssignmentForm < Decidim::Form
|
7
|
-
attribute :id, Integer
|
8
|
-
attribute :proposal_ids, Array
|
9
|
-
attribute :valuator_role_ids, Array
|
10
|
-
|
11
|
-
validates :valuator_roles, :proposals, :current_component, presence: true
|
12
|
-
validate :same_participatory_space
|
13
|
-
|
14
|
-
def proposals
|
15
|
-
@proposals ||= Decidim::Proposals::Proposal.where(component: current_component, id: proposal_ids).uniq
|
16
|
-
end
|
17
|
-
|
18
|
-
def valuator_roles
|
19
|
-
@valuator_roles ||= current_component.participatory_space
|
20
|
-
.user_roles(:valuator)
|
21
|
-
.order_by_name
|
22
|
-
.where(id: valuator_role_ids)
|
23
|
-
end
|
24
|
-
|
25
|
-
def same_participatory_space
|
26
|
-
return if valuator_roles.empty? || !current_component
|
27
|
-
|
28
|
-
valuator_roles.each do |valuator_role|
|
29
|
-
if current_component.participatory_space != valuator_role.participatory_space
|
30
|
-
errors.add(:id, :invalid)
|
31
|
-
break
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
module Metrics
|
6
|
-
class AcceptedProposalsMetricManage < Decidim::Proposals::Metrics::ProposalsMetricManage
|
7
|
-
def metric_name
|
8
|
-
"accepted_proposals"
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def query
|
14
|
-
return @query if @query
|
15
|
-
|
16
|
-
spaces = Decidim.participatory_space_manifests.flat_map do |manifest|
|
17
|
-
manifest.participatory_spaces.call(@organization).public_spaces
|
18
|
-
end
|
19
|
-
@query = Decidim::Proposals::Proposal.where(component: visible_components_from_spaces(spaces)).joins(:component)
|
20
|
-
.left_outer_joins(:category)
|
21
|
-
@query = @query.where(decidim_proposals_proposals: { created_at: ..end_time }).accepted
|
22
|
-
@query = @query.group("decidim_categorizations.id", :participatory_space_type, :participatory_space_id)
|
23
|
-
@query
|
24
|
-
end
|
25
|
-
|
26
|
-
def quantity
|
27
|
-
@quantity ||= query.where(decidim_proposals_proposals: { created_at: start_time.. }).count
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
module Metrics
|
6
|
-
class EndorsementsMetricManage < Decidim::MetricManage
|
7
|
-
def metric_name
|
8
|
-
"endorsements"
|
9
|
-
end
|
10
|
-
|
11
|
-
def save
|
12
|
-
cumulative.each do |key, cumulative_value|
|
13
|
-
next if cumulative_value.zero?
|
14
|
-
|
15
|
-
quantity_value = quantity[key] || 0
|
16
|
-
taxonomy_id, space_type, space_id, proposal_id = key
|
17
|
-
record = Decidim::Metric.find_or_initialize_by(day: @day.to_s, metric_type: @metric_name,
|
18
|
-
organization: @organization, decidim_taxonomy_id: taxonomy_id,
|
19
|
-
participatory_space_type: space_type, participatory_space_id: space_id,
|
20
|
-
related_object_type: "Decidim::Proposals::Proposal", related_object_id: proposal_id)
|
21
|
-
record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
|
22
|
-
record.save!
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def query
|
29
|
-
return @query if @query
|
30
|
-
|
31
|
-
components = Decidim::Component.where(participatory_space: retrieve_participatory_spaces).published
|
32
|
-
proposals = Decidim::Proposals::Proposal.where(component: components).not_withdrawn
|
33
|
-
join_components = "INNER JOIN decidim_components ON decidim_components.manifest_name = 'proposals' AND proposals.decidim_component_id = decidim_components.id"
|
34
|
-
join_taxonomies = <<~EOJOINCATS
|
35
|
-
LEFT OUTER JOIN decidim_taxonomizations
|
36
|
-
ON (proposals.id = decidim_taxonomizations.taxonomizable_id
|
37
|
-
AND decidim_taxonomizations.taxonomizable_type = 'Decidim::Proposals::Proposal')
|
38
|
-
EOJOINCATS
|
39
|
-
@query = Decidim::Endorsement.joins("INNER JOIN decidim_proposals_proposals proposals ON resource_id = proposals.id")
|
40
|
-
.joins(join_components)
|
41
|
-
.joins(join_taxonomies)
|
42
|
-
.where(resource_id: proposals.pluck(:id))
|
43
|
-
.where(resource_type: Decidim::Proposals::Proposal.name)
|
44
|
-
@query = @query.where(decidim_endorsements: { created_at: ..end_time })
|
45
|
-
@query = @query.group("decidim_taxonomizations.taxonomy_id",
|
46
|
-
:participatory_space_type,
|
47
|
-
:participatory_space_id,
|
48
|
-
:resource_id)
|
49
|
-
@query
|
50
|
-
end
|
51
|
-
|
52
|
-
def quantity
|
53
|
-
@quantity ||= query.where(decidim_endorsements: { created_at: start_time.. }).count
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
module Metrics
|
6
|
-
# Searches for unique Users following the next objects
|
7
|
-
# - Proposals
|
8
|
-
# - CollaborativeDrafts
|
9
|
-
class ProposalFollowersMetricMeasure < Decidim::MetricMeasure
|
10
|
-
def valid?
|
11
|
-
super && @resource.is_a?(Decidim::Component)
|
12
|
-
end
|
13
|
-
|
14
|
-
def calculate
|
15
|
-
cumulative_users = []
|
16
|
-
cumulative_users |= retrieve_proposals_followers.pluck(:decidim_user_id)
|
17
|
-
cumulative_users |= retrieve_drafts_followers.pluck(:decidim_user_id)
|
18
|
-
|
19
|
-
quantity_users = []
|
20
|
-
quantity_users |= retrieve_proposals_followers(from_start: true).pluck(:decidim_user_id)
|
21
|
-
quantity_users |= retrieve_drafts_followers(from_start: true).pluck(:decidim_user_id)
|
22
|
-
|
23
|
-
{
|
24
|
-
cumulative_users: cumulative_users.uniq,
|
25
|
-
quantity_users: quantity_users.uniq
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def retrieve_proposals_followers(from_start: false)
|
32
|
-
@proposals_followers ||= Decidim::Follow.where(followable: retrieve_proposals).joins(:user)
|
33
|
-
.where(decidim_follows: { created_at: ..end_time })
|
34
|
-
|
35
|
-
return @proposals_followers.where(decidim_follows: { created_at: start_time.. }) if from_start
|
36
|
-
|
37
|
-
@proposals_followers
|
38
|
-
end
|
39
|
-
|
40
|
-
def retrieve_drafts_followers(from_start: false)
|
41
|
-
@drafts_followers ||= Decidim::Follow.where(followable: retrieve_collaborative_drafts).joins(:user)
|
42
|
-
.where(decidim_follows: { created_at: ..end_time })
|
43
|
-
return @drafts_followers.where(decidim_follows: { created_at: start_time.. }) if from_start
|
44
|
-
|
45
|
-
@drafts_followers
|
46
|
-
end
|
47
|
-
|
48
|
-
def retrieve_proposals
|
49
|
-
Decidim::Proposals::Proposal.where(component: @resource).not_withdrawn
|
50
|
-
end
|
51
|
-
|
52
|
-
def retrieve_collaborative_drafts
|
53
|
-
Decidim::Proposals::CollaborativeDraft.where(component: @resource).except_withdrawn
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
module Metrics
|
6
|
-
# Searches for Participants in the following actions
|
7
|
-
# - Create a proposal (Proposals)
|
8
|
-
# - Vote to a proposal (Proposals)
|
9
|
-
# - Endorse (Proposals)
|
10
|
-
class ProposalParticipantsMetricMeasure < Decidim::MetricMeasure
|
11
|
-
def valid?
|
12
|
-
super && @resource.is_a?(Decidim::Component)
|
13
|
-
end
|
14
|
-
|
15
|
-
def calculate
|
16
|
-
cumulative_users = []
|
17
|
-
cumulative_users |= retrieve_votes.pluck(:decidim_author_id)
|
18
|
-
cumulative_users |= retrieve_endorsements.pluck(:decidim_author_id)
|
19
|
-
cumulative_users |= retrieve_proposals.pluck("decidim_coauthorships.decidim_author_id") # To avoid ambiguousness must be called this way
|
20
|
-
|
21
|
-
quantity_users = []
|
22
|
-
quantity_users |= retrieve_votes(from_start: true).pluck(:decidim_author_id)
|
23
|
-
quantity_users |= retrieve_endorsements(from_start: true).pluck(:decidim_author_id)
|
24
|
-
quantity_users |= retrieve_proposals(from_start: true).pluck("decidim_coauthorships.decidim_author_id") # To avoid ambiguousness must be called this way
|
25
|
-
|
26
|
-
{
|
27
|
-
cumulative_users: cumulative_users.uniq,
|
28
|
-
quantity_users: quantity_users.uniq
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def retrieve_proposals(from_start: false)
|
35
|
-
@proposals ||= Decidim::Proposals::Proposal.where(component: @resource).joins(:coauthorships)
|
36
|
-
.includes(:votes, :endorsements)
|
37
|
-
.where(decidim_coauthorships: {
|
38
|
-
decidim_author_type: [
|
39
|
-
"Decidim::UserBaseEntity",
|
40
|
-
"Decidim::Organization",
|
41
|
-
"Decidim::Meetings::Meeting"
|
42
|
-
]
|
43
|
-
})
|
44
|
-
.where(decidim_proposals_proposals: { published_at: ..end_time })
|
45
|
-
.not_withdrawn
|
46
|
-
|
47
|
-
return @proposals.where(decidim_proposals_proposals: { published_at: start_time.. }) if from_start
|
48
|
-
|
49
|
-
@proposals
|
50
|
-
end
|
51
|
-
|
52
|
-
def retrieve_votes(from_start: false)
|
53
|
-
@votes ||= Decidim::Proposals::ProposalVote.joins(:proposal).where(proposal: retrieve_proposals).joins(:author)
|
54
|
-
.where(decidim_proposals_proposal_votes: { created_at: ..end_time })
|
55
|
-
|
56
|
-
return @votes.where(decidim_proposals_proposal_votes: { created_at: start_time.. }) if from_start
|
57
|
-
|
58
|
-
@votes
|
59
|
-
end
|
60
|
-
|
61
|
-
def retrieve_endorsements(from_start: false)
|
62
|
-
@endorsements ||= Decidim::Endorsement.joins("INNER JOIN decidim_proposals_proposals proposals ON resource_id = proposals.id")
|
63
|
-
.where(resource: retrieve_proposals)
|
64
|
-
.where(decidim_endorsements: { created_at: ..end_time })
|
65
|
-
.where(decidim_author_type: "Decidim::UserBaseEntity")
|
66
|
-
|
67
|
-
return @endorsements.where(decidim_endorsements: { created_at: start_time.. }) if from_start
|
68
|
-
|
69
|
-
@endorsements
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
module Metrics
|
6
|
-
class ProposalsMetricManage < Decidim::MetricManage
|
7
|
-
def metric_name
|
8
|
-
"proposals"
|
9
|
-
end
|
10
|
-
|
11
|
-
def save
|
12
|
-
cumulative.each do |key, cumulative_value|
|
13
|
-
next if cumulative_value.zero?
|
14
|
-
|
15
|
-
quantity_value = quantity[key] || 0
|
16
|
-
taxonomy_id, space_type, space_id = key
|
17
|
-
record = Decidim::Metric.find_or_initialize_by(day: @day.to_s, metric_type: @metric_name,
|
18
|
-
organization: @organization, decidim_taxonomy_id: taxonomy_id,
|
19
|
-
participatory_space_type: space_type, participatory_space_id: space_id)
|
20
|
-
record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
|
21
|
-
record.save!
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def query
|
28
|
-
return @query if @query
|
29
|
-
|
30
|
-
spaces = Decidim.participatory_space_manifests.flat_map do |manifest|
|
31
|
-
manifest.participatory_spaces.call(@organization)
|
32
|
-
end
|
33
|
-
@query = Decidim::Proposals::Proposal.where(component: visible_components_from_spaces(spaces)).joins(:component)
|
34
|
-
.left_outer_joins(:taxonomizations)
|
35
|
-
@query = @query.where(decidim_proposals_proposals: { published_at: ..end_time }).not_withdrawn.not_hidden
|
36
|
-
@query = @query.group("decidim_taxonomizations.taxonomy_id",
|
37
|
-
:participatory_space_type,
|
38
|
-
:participatory_space_id)
|
39
|
-
@query
|
40
|
-
end
|
41
|
-
|
42
|
-
def quantity
|
43
|
-
@quantity ||= query.where(decidim_proposals_proposals: { published_at: start_time.. }).count
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
module Metrics
|
6
|
-
class VotesMetricManage < Decidim::MetricManage
|
7
|
-
def metric_name
|
8
|
-
"votes"
|
9
|
-
end
|
10
|
-
|
11
|
-
def save
|
12
|
-
cumulative.each do |key, cumulative_value|
|
13
|
-
next if cumulative_value.zero?
|
14
|
-
|
15
|
-
quantity_value = quantity[key] || 0
|
16
|
-
taxonomy_id, space_type, space_id, proposal_id = key
|
17
|
-
record = Decidim::Metric.find_or_initialize_by(day: @day.to_s, metric_type: @metric_name,
|
18
|
-
organization: @organization, decidim_taxonomy_id: taxonomy_id,
|
19
|
-
participatory_space_type: space_type, participatory_space_id: space_id,
|
20
|
-
related_object_type: "Decidim::Proposals::Proposal", related_object_id: proposal_id)
|
21
|
-
record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
|
22
|
-
record.save!
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def query
|
29
|
-
return @query if @query
|
30
|
-
|
31
|
-
spaces = Decidim.participatory_space_manifests.flat_map do |manifest|
|
32
|
-
manifest.participatory_spaces.call(@organization).public_spaces
|
33
|
-
end
|
34
|
-
proposal_ids = Decidim::Proposals::Proposal.where(component: visible_components_from_spaces(spaces)).not_withdrawn.not_hidden.pluck(:id)
|
35
|
-
@query = Decidim::Proposals::ProposalVote.joins(proposal: :component)
|
36
|
-
.left_outer_joins(proposal: :taxonomizations)
|
37
|
-
.where(proposal: proposal_ids)
|
38
|
-
@query = @query.where(decidim_proposals_proposal_votes: { created_at: ..end_time })
|
39
|
-
@query = @query.group("decidim_taxonomizations.taxonomy_id",
|
40
|
-
:participatory_space_type,
|
41
|
-
:participatory_space_id,
|
42
|
-
:decidim_proposal_id)
|
43
|
-
@query
|
44
|
-
end
|
45
|
-
|
46
|
-
def quantity
|
47
|
-
@quantity ||= query.where(decidim_proposals_proposal_votes: { created_at: start_time.. }).count
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
<% if current_organization.user_groups_enabled? && form.object.user_groups.any? %>
|
2
|
-
<div>
|
3
|
-
<%= form.select(
|
4
|
-
:user_group_id,
|
5
|
-
form.object.user_groups.map { |g| [g.name, g.id] },
|
6
|
-
selected: form.object.user_group_id.presence,
|
7
|
-
include_blank: current_user.name,
|
8
|
-
label: true
|
9
|
-
) %>
|
10
|
-
</div>
|
11
|
-
<% end %>
|
@@ -1,25 +0,0 @@
|
|
1
|
-
<div class="card-section">
|
2
|
-
<div class="row column">
|
3
|
-
<span class="component__show-title"><%= t "endorsers", scope: "decidim.proposals.admin.proposals.show" %></span>
|
4
|
-
<ul id="proposal-endorsers-list">
|
5
|
-
<% presented_endorsers.first(5).each do |presented_endorser| %>
|
6
|
-
<li>
|
7
|
-
<%= link_to_if(
|
8
|
-
presented_endorser.profile_path.present?,
|
9
|
-
presented_endorser.name,
|
10
|
-
presented_endorser.profile_path,
|
11
|
-
target: :blank
|
12
|
-
) %>
|
13
|
-
</li>
|
14
|
-
<% end %>
|
15
|
-
<% if presented_endorsers.count > 5 %>
|
16
|
-
<li>
|
17
|
-
<%= link_to(
|
18
|
-
t("n_more_endorsers", scope: "decidim.proposals.admin.proposals.show", count: presented_endorsers.count - 5),
|
19
|
-
resource_locator(proposal).path
|
20
|
-
) %>
|
21
|
-
</li>
|
22
|
-
<% end %>
|
23
|
-
</ul>
|
24
|
-
</div>
|
25
|
-
</div>
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<div id="js-assign-proposals-to-valuator-actions" class="item_show__header__action-options js-bulk-action-form hide">
|
2
|
-
<%= form_tag(valuation_assignment_path, method: :post, id: "js-form-assign-proposals-to-valuator", class: "form form-defaults w-full") do %>
|
3
|
-
<div class="hide">
|
4
|
-
<% proposals.each do |proposal| %>
|
5
|
-
<%= check_box_tag "proposal_ids[]", proposal.id, false, class: "js-check-all-proposal js-proposal-id-#{proposal.id}" %>
|
6
|
-
<% end %>
|
7
|
-
</div>
|
8
|
-
|
9
|
-
<label class="w-full font-semibold" for="assign_valuator_role_ids">
|
10
|
-
<%= t("decidim.proposals.admin.proposals.index.assign_to_valuator") %>
|
11
|
-
<%= render partial: "decidim/proposals/admin/proposals/bulk_actions/valuators_picker", locals: { participatory_space: current_participatory_space, select_id: "assign_valuator_role_ids" } %>
|
12
|
-
</label>
|
13
|
-
|
14
|
-
<div class="flex justify-end gap-x-4 mt-2">
|
15
|
-
<%= submit_tag(t("decidim.proposals.admin.proposals.index.assign_to_valuator_button"), id: "js-submit-assign-proposals-to-valuator", class: "button button__sm button__secondary small button--simple float-left") %>
|
16
|
-
<button class="button button__sm button__secondary js-cancel-bulk-action" type="button"><%= t("decidim.proposals.admin.proposals.index.cancel") %></button>
|
17
|
-
</div>
|
18
|
-
<% end %>
|
19
|
-
</div>
|
data/app/views/decidim/proposals/admin/proposals/bulk_actions/_unassign_from_valuator.html.erb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
<div id="js-unassign-proposals-from-valuator-actions" class="item_show__header__action-options js-bulk-action-form hide">
|
2
|
-
<%= form_tag(valuation_assignment_path, method: :delete, id: "js-form-unassign-proposals-from-valuator", class: "form form-defaults w-full") do %>
|
3
|
-
<div class="hide">
|
4
|
-
<% proposals.each do |proposal| %>
|
5
|
-
<%= check_box_tag "proposal_ids[]", proposal.id, false, class: "js-check-all-proposal js-proposal-id-#{proposal.id}" %>
|
6
|
-
<% end %>
|
7
|
-
</div>
|
8
|
-
|
9
|
-
<label class="w-full font-semibold" for="unassign_valuator_role_ids">
|
10
|
-
<%= t("decidim.proposals.admin.proposals.index.unassign_from_valuator") %>
|
11
|
-
<%= render partial: "decidim/proposals/admin/proposals/bulk_actions/valuators_picker", locals: { participatory_space: current_participatory_space, select_id: "unassign_valuator_role_ids" } %>
|
12
|
-
</label>
|
13
|
-
|
14
|
-
<div class="flex justify-end gap-x-4 mt-2">
|
15
|
-
<%= submit_tag(t("decidim.proposals.admin.proposals.index.unassign_from_valuator_button"), id: "js-submit-unassign-proposals-from-valuator", class: "button button__sm button__secondary small button--simple float-left") %>
|
16
|
-
<button class="button button__sm button__secondary js-cancel-bulk-action" type="button"><%= t("decidim.proposals.admin.proposals.index.cancel") %></button>
|
17
|
-
</div>
|
18
|
-
<% end %>
|
19
|
-
</div>
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Proposals
|
5
|
-
# A set of methods and features related to proposal valuations.
|
6
|
-
module Valuatable
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
include Decidim::Comments::Commentable
|
9
|
-
|
10
|
-
included do
|
11
|
-
has_many :valuation_assignments, foreign_key: "decidim_proposal_id", dependent: :destroy,
|
12
|
-
counter_cache: :valuation_assignments_count, class_name: "Decidim::Proposals::ValuationAssignment"
|
13
|
-
|
14
|
-
def valuators
|
15
|
-
valuator_role_ids = valuation_assignments.where(proposal: self).pluck(:valuator_role_id)
|
16
|
-
user_ids = participatory_space.user_roles(:valuator).where(id: valuator_role_ids).pluck(:decidim_user_id)
|
17
|
-
participatory_space.organization.users.where(id: user_ids)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|