decidim-action_delegator 0.8.1 → 0.9.0
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/README.md +104 -58
- data/Rakefile +2 -2
- data/app/commands/decidim/action_delegator/admin/create_delegation.rb +1 -3
- data/app/commands/decidim/action_delegator/admin/create_setting.rb +5 -2
- data/app/commands/decidim/action_delegator/admin/update_setting.rb +4 -2
- data/app/controllers/concerns/decidim/action_delegator/devise/sessions_controller_override.rb +1 -1
- data/app/controllers/concerns/decidim/action_delegator/election_per_question_votes_controller_override.rb +65 -0
- data/app/controllers/concerns/decidim/action_delegator/election_votes_controller_override.rb +38 -0
- data/app/controllers/concerns/decidim/action_delegator/votes_controller_methods.rb +46 -0
- data/app/controllers/decidim/action_delegator/admin/application_controller.rb +11 -5
- data/app/controllers/decidim/action_delegator/admin/delegations_controller.rb +3 -11
- data/app/controllers/decidim/action_delegator/admin/invite_participants_controller.rb +0 -8
- data/app/controllers/decidim/action_delegator/admin/manage_delegations_controller.rb +13 -21
- data/app/controllers/decidim/action_delegator/admin/manage_participants_controller.rb +11 -20
- data/app/controllers/decidim/action_delegator/admin/participants_controller.rb +1 -9
- data/app/controllers/decidim/action_delegator/admin/permissions_controller.rb +1 -24
- data/app/controllers/decidim/action_delegator/admin/ponderations_controller.rb +0 -8
- data/app/controllers/decidim/action_delegator/admin/settings_controller.rb +12 -12
- data/app/controllers/decidim/action_delegator/application_controller.rb +3 -3
- data/app/controllers/decidim/action_delegator/elections/admin/results_controller.rb +58 -0
- data/app/controllers/decidim/action_delegator/elections/results_controller.rb +36 -0
- data/app/controllers/decidim/action_delegator/user_delegations_controller.rb +1 -1
- data/app/controllers/decidim/action_delegator/verifications/delegations_verifier/authorizations_controller.rb +14 -18
- data/app/forms/decidim/action_delegator/admin/action_delegator_census_form.rb +44 -0
- data/app/forms/decidim/action_delegator/admin/csv_import_form.rb +17 -0
- data/app/forms/decidim/action_delegator/admin/delegation_form.rb +6 -2
- data/app/forms/decidim/action_delegator/admin/ponderation_form.rb +2 -1
- data/app/forms/decidim/action_delegator/admin/setting_form.rb +16 -10
- data/app/forms/decidim/action_delegator/censuses/internal_users_form.rb +32 -0
- data/app/forms/decidim/action_delegator/verifications/delegations_verifier_form.rb +41 -25
- data/app/helpers/decidim/action_delegator/admin/{delegation_helper.rb → settings_helper.rb} +3 -16
- data/app/helpers/decidim/action_delegator/settings_helper.rb +124 -0
- data/app/jobs/decidim/action_delegator/admin/invite_participants_job.rb +1 -1
- data/app/jobs/decidim/action_delegator/send_sms_job.rb +2 -2
- data/app/jobs/decidim/action_delegator/twilio_send_sms_job.rb +2 -2
- data/app/models/decidim/action_delegator/delegation.rb +35 -9
- data/app/models/decidim/action_delegator/participant.rb +15 -9
- data/app/models/decidim/action_delegator/ponderation.rb +0 -2
- data/app/models/decidim/action_delegator/setting.rb +14 -32
- data/app/overrides/decidim/elections/admin/dashboard/_results/_add_results_contents.html.erb.deface +10 -0
- data/app/overrides/decidim/elections/admin/dashboard/_results/_add_results_tabs.html.erb.deface +3 -0
- data/app/overrides/decidim/elections/elections/_election_aside/add_delegation_buttons.html.erb.deface +3 -0
- data/app/overrides/decidim/elections/elections/_vote_results/replace_results_div.html.erb.deface +8 -0
- data/app/overrides/decidim/elections/per_question_votes/show/add_delegation_hidden_input.html.erb.deface +3 -0
- data/app/overrides/decidim/elections/per_question_votes/show/add_delegation_id_to_links.html.erb.deface +3 -0
- data/app/overrides/decidim/elections/per_question_votes/waiting/add_delegation_buttons.html.erb.deface +3 -0
- data/app/overrides/decidim/elections/votes/receipt/add_delegation_buttons.html.erb.deface +3 -0
- data/app/packs/entrypoints/decidim_action_delegator_elections.js +1 -0
- data/app/packs/src/decidim/action_delegator/elections_live_results.js +160 -0
- data/app/permissions/decidim/action_delegator/admin/permissions.rb +29 -0
- data/app/permissions/decidim/action_delegator/permissions.rb +6 -30
- data/app/presenters/decidim/action_delegator/setting_presenter.rb +33 -0
- data/app/queries/decidim/action_delegator/action_delegator_census_users.rb +51 -0
- data/app/queries/decidim/action_delegator/authorized_resources.rb +28 -0
- data/app/queries/decidim/action_delegator/election_settings.rb +23 -0
- data/app/queries/decidim/action_delegator/{delegated_votes_versions.rb → elections_delegated_votes_versions.rb} +8 -8
- data/app/queries/decidim/action_delegator/elections_question_responses_by_type.rb +33 -0
- data/app/queries/decidim/action_delegator/elections_question_weighted_responses.rb +28 -0
- data/app/queries/decidim/action_delegator/elections_votes_with_ponderations.rb +62 -0
- data/app/services/decidim/action_delegator/delegations_csv_importer.rb +3 -3
- data/app/services/decidim/action_delegator/participants_csv_importer.rb +1 -1
- data/app/services/decidim/action_delegator/sms_gateway.rb +2 -2
- data/app/views/decidim/action_delegator/admin/censuses/_action_delegator_census_form.html.erb +44 -0
- data/app/views/decidim/action_delegator/admin/censuses/_action_delegator_census_options_form.html.erb +25 -0
- data/app/views/decidim/action_delegator/admin/delegations/index.html.erb +12 -13
- data/app/views/decidim/action_delegator/admin/delegations/new.html.erb +29 -27
- data/app/views/decidim/action_delegator/admin/manage_delegations/new.html.erb +36 -24
- data/app/views/decidim/action_delegator/admin/manage_participants/new.html.erb +47 -33
- data/app/views/decidim/action_delegator/admin/participants/_form.html.erb +14 -8
- data/app/views/decidim/action_delegator/admin/participants/edit.html.erb +11 -13
- data/app/views/decidim/action_delegator/admin/participants/index.html.erb +20 -25
- data/app/views/decidim/action_delegator/admin/participants/new.html.erb +11 -13
- data/app/views/decidim/action_delegator/admin/ponderations/_form.html.erb +13 -7
- data/app/views/decidim/action_delegator/admin/ponderations/edit.html.erb +11 -13
- data/app/views/decidim/action_delegator/admin/ponderations/index.html.erb +8 -11
- data/app/views/decidim/action_delegator/admin/ponderations/new.html.erb +11 -13
- data/app/views/decidim/action_delegator/admin/settings/_form.html.erb +26 -12
- data/app/views/decidim/action_delegator/admin/settings/_participants_sync_check.html.erb +1 -1
- data/app/views/decidim/action_delegator/admin/settings/_setting_checks.html.erb +11 -16
- data/app/views/decidim/action_delegator/admin/settings/edit.html.erb +11 -12
- data/app/views/decidim/action_delegator/admin/settings/index.html.erb +22 -19
- data/app/views/decidim/action_delegator/admin/settings/new.html.erb +11 -12
- data/app/views/decidim/action_delegator/admin/shared/_tabs_menu.html.erb +15 -0
- data/app/views/decidim/action_delegator/censuses/_internal_users_form.html.erb +61 -0
- data/app/views/decidim/action_delegator/elections/_delegation_buttons.html.erb +10 -0
- data/app/views/decidim/action_delegator/elections/_normal_election_buttons.html.erb +13 -0
- data/app/views/decidim/action_delegator/elections/_per_question_buttons.html.erb +9 -0
- data/app/views/decidim/action_delegator/elections/_per_question_waiting_buttons.html.erb +19 -0
- data/app/views/decidim/action_delegator/elections/_vote_results.html.erb +10 -0
- data/app/views/decidim/action_delegator/elections/_vote_results_question.html.erb +13 -0
- data/app/views/decidim/action_delegator/elections/admin/dashboard/_by_type_and_weight.html.erb +45 -0
- data/app/views/decidim/action_delegator/elections/admin/dashboard/_results_tabs.html.erb +5 -0
- data/app/views/decidim/action_delegator/elections/admin/dashboard/_results_type_info.html.erb +4 -0
- data/app/views/decidim/action_delegator/elections/admin/dashboard/_sum_of_weights.html.erb +43 -0
- data/app/views/decidim/action_delegator/elections/admin/dashboard/_totals.html.erb +27 -0
- data/app/views/decidim/action_delegator/user_delegations/index.html.erb +13 -14
- data/app/views/decidim/action_delegator/verifications/delegations_verifier/authorizations/edit.html.erb +19 -29
- data/app/views/decidim/action_delegator/verifications/delegations_verifier/authorizations/new.html.erb +42 -40
- data/config/assets.rb +3 -35
- data/config/i18n-tasks.yml +27 -5
- data/config/locales/ca.yml +70 -56
- data/config/locales/cs.yml +161 -145
- data/config/locales/en.yml +110 -67
- data/config/locales/es.yml +70 -56
- data/db/migrate/20200824113801_create_settings.rb +1 -1
- data/db/migrate/20250729104037_add_title_to_action_delegator_settings.rb +31 -0
- data/lib/decidim/action_delegator/admin_engine.rb +72 -45
- data/lib/decidim/action_delegator/common_rake.rb +13 -0
- data/lib/decidim/action_delegator/engine.rb +49 -19
- data/lib/decidim/action_delegator/test/delegation_examples.rb +144 -0
- data/lib/decidim/action_delegator/test/factories.rb +11 -6
- data/lib/decidim/action_delegator/verifications/delegations_authorizer.rb +80 -47
- data/lib/decidim/action_delegator/version.rb +3 -3
- data/lib/decidim/action_delegator.rb +8 -26
- data/lib/tasks/migrate_consultations.rake +382 -0
- data/lib/tasks/upgrade_tasks.rake +5 -0
- data/package.json +10 -27
- metadata +72 -112
- data/app/commands/concerns/decidim/action_delegator/consultations/multiple_vote_question_override.rb +0 -31
- data/app/commands/concerns/decidim/action_delegator/consultations/vote_question_override.rb +0 -44
- data/app/commands/decidim/action_delegator/admin/fix_resource_permissions.rb +0 -46
- data/app/commands/decidim/action_delegator/vote_delegation.rb +0 -28
- data/app/controllers/concerns/decidim/action_delegator/consultations/consultations_controller_override.rb +0 -16
- data/app/controllers/concerns/decidim/action_delegator/consultations/question_multiple_votes_controller_override.rb +0 -29
- data/app/controllers/concerns/decidim/action_delegator/consultations/question_votes_controller_override.rb +0 -57
- data/app/controllers/concerns/decidim/action_delegator/consultations/questions_controller_override.rb +0 -16
- data/app/controllers/concerns/decidim/action_delegator/needs_consultation_styles.rb +0 -24
- data/app/controllers/decidim/action_delegator/admin/consultations/exports_controller.rb +0 -27
- data/app/controllers/decidim/action_delegator/admin/consultations_controller.rb +0 -47
- data/app/controllers/decidim/action_delegator/admin/exports/_sum_of_weights_controller.rb +0 -15
- data/app/forms/concerns/decidim/action_delegator/consultations/vote_form_override.rb +0 -15
- data/app/helpers/decidim/action_delegator/delegation_helper.rb +0 -13
- data/app/jobs/decidim/action_delegator/export_consultation_results_job.rb +0 -51
- data/app/models/concerns/decidim/action_delegator/consultations/question_override.rb +0 -18
- data/app/models/concerns/decidim/action_delegator/consultations/vote_override.rb +0 -15
- data/app/models/decidim/action_delegator/unversioned_vote.rb +0 -19
- data/app/models/decidim/action_delegator/whodunnit_vote.rb +0 -28
- data/app/overrides/decidim/consultations/admin/consultations/results/add_ongoing_warning.html.erb.deface +0 -3
- data/app/overrides/decidim/consultations/consultations/_question/add_delegation_link.html.erb.deface +0 -3
- data/app/overrides/decidim/consultations/consultations/_regular_questions/prevent_empty_questions.html.erb.deface +0 -10
- data/app/overrides/decidim/consultations/consultations/_regular_questions/remove_highlighted_scopes.html.erb.deface +0 -5
- data/app/overrides/decidim/consultations/question_multiple_votes/_form/add_delegation_notice.html.erb.deface +0 -8
- data/app/overrides/decidim/consultations/questions/_vote_button/add_delegations_link.html.erb.deface +0 -3
- data/app/overrides/decidim/consultations/questions/_vote_button/add_modal.html.erb.deface +0 -3
- data/app/overrides/decidim/consultations/questions/_vote_button/add_modal_javascript.html.erb.deface +0 -4
- data/app/overrides/decidim/consultations/questions/_vote_button/replace_delegation_to_multivote_link.html.erb.deface +0 -8
- data/app/overrides/decidim/consultations/questions/_vote_modal/add_delegation_callout.html.erb.deface +0 -3
- data/app/overrides/decidim/consultations/questions/_vote_modal_confirm/add_delegation_callout.html.erb.deface +0 -3
- data/app/overrides/decidim/consultations/questions/_vote_modal_confirm/add_hidden_field.html.erb.deface +0 -3
- data/app/overrides/layouts/decidim/admin/remove_deprecation.rb +0 -10
- data/app/packs/entrypoints/decidim_action_delegator.scss +0 -1
- data/app/packs/entrypoints/decidim_action_delegator_questions.js +0 -5
- data/app/packs/src/decidim/action_delegator/questions.js +0 -33
- data/app/packs/stylesheets/decidim/action_delegator/questions.scss +0 -26
- data/app/permissions/concerns/decidim/action_delegator/consultations/permissions_override.rb +0 -35
- data/app/presenters/decidim/action_delegator/question_with_totals.rb +0 -24
- data/app/queries/decidim/action_delegator/consultation_delegations.rb +0 -25
- data/app/queries/decidim/action_delegator/delegates_votes_by_consultation.rb +0 -24
- data/app/queries/decidim/action_delegator/delegates_votes_by_question.rb +0 -26
- data/app/queries/decidim/action_delegator/delegation_votes.rb +0 -30
- data/app/queries/decidim/action_delegator/grantee_delegations.rb +0 -24
- data/app/queries/decidim/action_delegator/organization_delegations.rb +0 -26
- data/app/queries/decidim/action_delegator/organization_settings.rb +0 -31
- data/app/queries/decidim/action_delegator/responses.rb +0 -24
- data/app/queries/decidim/action_delegator/responses_by_membership.rb +0 -58
- data/app/queries/decidim/action_delegator/scrutiny.rb +0 -87
- data/app/queries/decidim/action_delegator/setting_delegations.rb +0 -19
- data/app/queries/decidim/action_delegator/sum_of_membership_weight.rb +0 -44
- data/app/queries/decidim/action_delegator/sum_of_weights.rb +0 -25
- data/app/queries/decidim/action_delegator/type_and_weight.rb +0 -26
- data/app/queries/decidim/action_delegator/voted_with_ponderations.rb +0 -30
- data/app/queries/decidim/action_delegator/votes_count_aggregation.rb +0 -34
- data/app/serializers/decidim/action_delegator/consultation_results_serializer.rb +0 -19
- data/app/views/decidim/action_delegator/admin/consultations/_ongoing_consultation_warning.html.erb +0 -3
- data/app/views/decidim/action_delegator/admin/consultations/results.html.erb +0 -65
- data/app/views/decidim/action_delegator/admin/consultations/weighted_results.html.erb +0 -66
- data/app/views/decidim/action_delegator/consultations/_link_to_question.html.erb +0 -11
- data/app/views/decidim/action_delegator/consultations/questions/_callout.html.erb +0 -5
- data/app/views/decidim/action_delegator/consultations/questions/_delegations_modal.html.erb +0 -34
- data/app/views/decidim/action_delegator/consultations/questions/_link_to_delegations.html.erb +0 -11
- data/app/views/decidim/action_delegator/consultations/questions/_vote_delegated_active.html.erb +0 -32
- data/app/views/decidim/action_delegator/consultations/questions/_vote_delegated_finished.html.erb +0 -9
- data/app/views/decidim/action_delegator/consultations/questions/_vote_delegated_upcoming.html.erb +0 -8
- data/app/views/decidim/consultations/question_votes/update_vote_button.js.erb +0 -82
- data/lib/tasks/import_direct_verification.rake +0 -30
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
module Admin
|
6
|
-
module Consultations
|
7
|
-
class ExportsController < ActionDelegator::Admin::ApplicationController
|
8
|
-
include NeedsPermission
|
9
|
-
include Decidim::Consultations::NeedsConsultation
|
10
|
-
|
11
|
-
def create
|
12
|
-
enforce_permission_to :export_consultation_results, :consultation, consultation: current_consultation
|
13
|
-
|
14
|
-
ExportConsultationResultsJob.perform_later(current_user, current_consultation, type)
|
15
|
-
|
16
|
-
flash[:notice] = t("decidim.admin.exports.notice")
|
17
|
-
redirect_back(fallback_location: decidim_admin_consultations.results_consultation_path(current_consultation))
|
18
|
-
end
|
19
|
-
|
20
|
-
def type
|
21
|
-
"type_and_weight"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
module Admin
|
6
|
-
class ConsultationsController < Decidim::Consultations::Admin::ConsultationsController
|
7
|
-
layout "decidim/admin/consultation"
|
8
|
-
|
9
|
-
helper_method :questions, :total_delegates, :responses_by_membership, :responses_by_weight
|
10
|
-
|
11
|
-
def results
|
12
|
-
enforce_permission_to :read, :consultation, consultation: current_consultation
|
13
|
-
end
|
14
|
-
|
15
|
-
def weighted_results
|
16
|
-
enforce_permission_to :read, :consultation, consultation: current_consultation
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def permission_class_chain
|
22
|
-
Decidim.permissions_registry.chain_for(ActionDelegator::Admin::ApplicationController)
|
23
|
-
end
|
24
|
-
|
25
|
-
def questions
|
26
|
-
@questions ||= Scrutiny.new(current_consultation).questions
|
27
|
-
end
|
28
|
-
|
29
|
-
def total_delegates
|
30
|
-
@total_delegates ||= DelegatesVotesByConsultation.new(current_consultation).query
|
31
|
-
end
|
32
|
-
|
33
|
-
def responses_by_membership
|
34
|
-
ResponsesByMembership.new(published_questions_responses).query.group_by(&:decidim_consultations_questions_id)
|
35
|
-
end
|
36
|
-
|
37
|
-
def responses_by_weight
|
38
|
-
SumOfWeights.new(current_consultation).query.group_by(&:question_id)
|
39
|
-
end
|
40
|
-
|
41
|
-
def published_questions_responses
|
42
|
-
VotedWithPonderations.new(Responses.new(current_consultation).query).query
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
module Consultations
|
6
|
-
module VoteFormOverride
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
attribute :decidim_consultations_delegation_id, Integer
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
module DelegationHelper
|
6
|
-
def has_any_delegate_vote?(question)
|
7
|
-
Decidim::ActionDelegator::GranteeDelegations.for(question.consultation, current_user).detect do |delegation|
|
8
|
-
question.voted_by?(delegation.granter)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
class ExportConsultationResultsJob < ApplicationJob
|
6
|
-
queue_as :default
|
7
|
-
|
8
|
-
def perform(user, consultation, results_type)
|
9
|
-
@consultation = consultation
|
10
|
-
@results_type = results_type.to_sym
|
11
|
-
|
12
|
-
export_data = Decidim::Exporters
|
13
|
-
.find_exporter("CSV")
|
14
|
-
.new(collection, serializer)
|
15
|
-
.export
|
16
|
-
|
17
|
-
Decidim::ExportMailer.export(user, filename, export_data).deliver_now
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
attr_reader :consultation, :results_type
|
23
|
-
|
24
|
-
def collection
|
25
|
-
query_class.new(consultation).query
|
26
|
-
end
|
27
|
-
|
28
|
-
def query_class
|
29
|
-
case results_type
|
30
|
-
when :sum_of_weights
|
31
|
-
SumOfWeights
|
32
|
-
when :type_and_weight
|
33
|
-
TypeAndWeight
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def serializer
|
38
|
-
case results_type
|
39
|
-
when :sum_of_weights
|
40
|
-
SumOfWeightsSerializer
|
41
|
-
when :type_and_weight
|
42
|
-
ConsultationResultsSerializer
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def filename
|
47
|
-
I18n.t("decidim.admin.consultations.results.export_filename")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
module Consultations
|
6
|
-
module QuestionOverride
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
# if results can be shown to admins
|
11
|
-
def publishable_results?
|
12
|
-
(ActionDelegator.admin_preview_results || consultation.finished?) && sorted_results.any?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
class UnversionedVote < SimpleDelegator
|
6
|
-
def save
|
7
|
-
PaperTrail.request(enabled: false) do
|
8
|
-
super
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def save!
|
13
|
-
PaperTrail.request(enabled: false) do
|
14
|
-
super
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
class WhodunnitVote < DelegateClass(Decidim::Consultations::Vote)
|
6
|
-
def initialize(vote, user)
|
7
|
-
@user = user
|
8
|
-
super(vote)
|
9
|
-
end
|
10
|
-
|
11
|
-
def save
|
12
|
-
PaperTrail.request(whodunnit: user.id) do
|
13
|
-
super
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def save!
|
18
|
-
PaperTrail.request(whodunnit: user.id) do
|
19
|
-
super
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
attr_reader :user
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<!-- replace 'erb[silent]:contains("if consultation.questions.any?")' -->
|
2
|
-
|
3
|
-
<%
|
4
|
-
show_questions = if Decidim::ActionDelegator.remove_duplicated_highlighted_questions
|
5
|
-
consultation.questions.count > consultation.highlighted_questions.count
|
6
|
-
else
|
7
|
-
consultation.questions.any?
|
8
|
-
end
|
9
|
-
%>
|
10
|
-
<% if show_questions %>
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<!-- replace 'h3.heading6' -->
|
2
|
-
|
3
|
-
<% next if questions.blank? %>
|
4
|
-
<% next if Decidim::ActionDelegator.remove_duplicated_highlighted_questions && current_consultation.highlighted_scope == questions.first.scope %>
|
5
|
-
<h3 class="heading6"><%= translated_attribute questions&.first&.scope&.name %></h3>
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<!-- insert_before ".card__content.multiple_votes_form" -->
|
2
|
-
|
3
|
-
<% if delegation %>
|
4
|
-
<div class="delegation-callout callout warning">
|
5
|
-
<p><%= t "action_delegator.delegations_modal.callout", scope: "decidim" %> <strong><%= delegation.granter.name %></strong></p>
|
6
|
-
</div>
|
7
|
-
<%= hidden_field_tag :decidim_consultations_delegation_id, delegation.id %>
|
8
|
-
<% end %>
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<!-- replace_contents "erb[silent]:contains('if question.multiple?')"
|
2
|
-
closing_selector "erb[silent]:contains('else')" -->
|
3
|
-
|
4
|
-
<%= link_to decidim_consultations.question_question_multiple_votes_path(question, delegation: 0),
|
5
|
-
class: "card__button button expanded",
|
6
|
-
id: "multivote_button" do %>
|
7
|
-
<div class="vote-button-caption"><%= t "questions.vote_button.vote", scope: "decidim" %></div>
|
8
|
-
<% end %>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Deface::Override.new(virtual_path: "layouts/decidim/admin/consultations",
|
4
|
-
name: "remove_deprecation_warning",
|
5
|
-
remove: ".callout.warning",
|
6
|
-
disabled: !Decidim::ActionDelegator.remove_consultation_deprecation_warning)
|
7
|
-
Deface::Override.new(virtual_path: "layouts/decidim/admin/consultation",
|
8
|
-
name: "remove_deprecation_warning",
|
9
|
-
remove: ".callout.warning",
|
10
|
-
disabled: !Decidim::ActionDelegator.remove_consultation_deprecation_warning)
|
@@ -1 +0,0 @@
|
|
1
|
-
@import "stylesheets/decidim/action_delegator/questions.scss"
|
@@ -1,33 +0,0 @@
|
|
1
|
-
$(() => {
|
2
|
-
const
|
3
|
-
delegationCallouts = $(".delegation-callout"),
|
4
|
-
delegationCalloutsMessage = $(".delegation-callout-message"),
|
5
|
-
delegationDialog = $("#delegations-modal"),
|
6
|
-
delegationField = $("#decidim_consultations_delegation_id"),
|
7
|
-
delegationUnVoteButtons = $(".delegation_unvote_button"),
|
8
|
-
delegationVoteButtons = $(".delegation-vote-button"),
|
9
|
-
delegationsButton = $("#delegations-button"),
|
10
|
-
voteButton = $("#vote_button"),
|
11
|
-
voteDialog = $("#question-vote-modal");
|
12
|
-
|
13
|
-
delegationsButton.click(() => {
|
14
|
-
delegationDialog.foundation("open");
|
15
|
-
});
|
16
|
-
|
17
|
-
delegationVoteButtons.click((evt) => {
|
18
|
-
delegationDialog.foundation("close");
|
19
|
-
voteDialog.foundation("open");
|
20
|
-
delegationField.val($(evt.currentTarget).data("delegation-id"));
|
21
|
-
delegationCalloutsMessage.text($(evt.currentTarget).data("delegation-granter-name"));
|
22
|
-
delegationCallouts.removeClass("is-hidden");
|
23
|
-
});
|
24
|
-
|
25
|
-
delegationUnVoteButtons.click(() => {
|
26
|
-
delegationDialog.foundation("close");
|
27
|
-
delegationCallouts.addClass("is-hidden");
|
28
|
-
});
|
29
|
-
|
30
|
-
voteButton.click(() => {
|
31
|
-
delegationCallouts.addClass("is-hidden");
|
32
|
-
});
|
33
|
-
});
|
@@ -1,26 +0,0 @@
|
|
1
|
-
.delegations-notice {
|
2
|
-
a {
|
3
|
-
display: block;
|
4
|
-
color: white;
|
5
|
-
background: rgba(0, 0, 0, .5);
|
6
|
-
line-height: 1;
|
7
|
-
text-align: center;
|
8
|
-
padding: .5em;
|
9
|
-
}
|
10
|
-
}
|
11
|
-
|
12
|
-
.question-vote-cabin {
|
13
|
-
.delegations-notice {
|
14
|
-
a {
|
15
|
-
color: var(--secondary);
|
16
|
-
font-weight: 600;
|
17
|
-
background: transparent;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
|
-
#delegations-modal {
|
23
|
-
.vote-button-caption {
|
24
|
-
font-weight: bold;
|
25
|
-
}
|
26
|
-
}
|
data/app/permissions/concerns/decidim/action_delegator/consultations/permissions_override.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
module Consultations
|
6
|
-
module PermissionsOverride
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
private
|
11
|
-
|
12
|
-
# Overrides Decidim::Consultations::Permissions to account for delegation votes
|
13
|
-
def allowed_public_action?
|
14
|
-
return unless permission_action.scope == :public
|
15
|
-
return unless permission_action.subject == :question
|
16
|
-
|
17
|
-
# check if question has been limited by admins first
|
18
|
-
return unless authorized? :vote
|
19
|
-
|
20
|
-
case permission_action.action
|
21
|
-
when :vote
|
22
|
-
toggle_allow(question.can_be_voted_by?(user) || can_be_delegated?(user))
|
23
|
-
when :unvote
|
24
|
-
toggle_allow(question.can_be_unvoted_by?(user))
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def can_be_delegated?(user)
|
29
|
-
Delegation.granted_to?(user, question.consultation)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
class QuestionWithTotals < SimpleDelegator
|
6
|
-
def initialize(question, questions_by_id)
|
7
|
-
super(question)
|
8
|
-
@questions_by_id = questions_by_id
|
9
|
-
end
|
10
|
-
|
11
|
-
def total_delegates
|
12
|
-
questions_by_id[id].total_delegates
|
13
|
-
end
|
14
|
-
|
15
|
-
def total_participants
|
16
|
-
questions_by_id[id].total_participants
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
attr_reader :questions_by_id
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
class ConsultationDelegations < Decidim::Query
|
6
|
-
def self.for(consultation)
|
7
|
-
new(consultation).query
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize(consultation)
|
11
|
-
@consultation = consultation
|
12
|
-
end
|
13
|
-
|
14
|
-
def query
|
15
|
-
Delegation
|
16
|
-
.joins(setting: :consultation)
|
17
|
-
.where(decidim_consultations: { id: consultation.id })
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
attr_reader :consultation
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
class DelegatesVotesByConsultation < Decidim::Query
|
6
|
-
def initialize(consultation, relation = DelegationVotes)
|
7
|
-
@consultation = consultation
|
8
|
-
@relation = relation
|
9
|
-
end
|
10
|
-
|
11
|
-
def query
|
12
|
-
relation.new.query.merge(consultation_delegations).count
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
attr_reader :consultation, :relation
|
18
|
-
|
19
|
-
def consultation_delegations
|
20
|
-
ConsultationDelegations.for(consultation)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
class DelegatesVotesByQuestion < Decidim::Query
|
6
|
-
def initialize(question)
|
7
|
-
@question = question
|
8
|
-
end
|
9
|
-
|
10
|
-
def query
|
11
|
-
DelegationVotes.new.query
|
12
|
-
.merge(question.votes)
|
13
|
-
.merge(consultation_delegations)
|
14
|
-
.distinct.count(:granter_id)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :question
|
20
|
-
|
21
|
-
def consultation_delegations
|
22
|
-
ConsultationDelegations.for(question.consultation)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
# This query object replaces the ActiveRecord association we would have between the Vote and
|
6
|
-
# Delegation models. Unfortunately we can't use custom foreign keys on both ends of the
|
7
|
-
# association so this aims to replace `delegation.votes`.
|
8
|
-
class DelegationVotes < Decidim::Query
|
9
|
-
def query
|
10
|
-
Delegation.joins(
|
11
|
-
delegations.join(votes).on(vote_author_eq_granter).join_sources
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def votes
|
18
|
-
Decidim::Consultations::Vote.arel_table
|
19
|
-
end
|
20
|
-
|
21
|
-
def delegations
|
22
|
-
Delegation.arel_table
|
23
|
-
end
|
24
|
-
|
25
|
-
def vote_author_eq_granter
|
26
|
-
votes[:decidim_author_id].eq(delegations[:granter_id])
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
class GranteeDelegations
|
6
|
-
def self.for(consultation, user)
|
7
|
-
new(consultation, user).query
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize(consultation, user)
|
11
|
-
@consultation = consultation
|
12
|
-
@user = user
|
13
|
-
end
|
14
|
-
|
15
|
-
def query
|
16
|
-
ConsultationDelegations.for(consultation).where(grantee_id: user.id)
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
attr_reader :consultation, :user
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
class OrganizationDelegations < Decidim::Query
|
6
|
-
def initialize(organization)
|
7
|
-
@organization = organization
|
8
|
-
end
|
9
|
-
|
10
|
-
def query
|
11
|
-
Delegation
|
12
|
-
.joins(setting: :consultation)
|
13
|
-
.merge(organization_consultations)
|
14
|
-
.includes(:grantee, :granter)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :organization
|
20
|
-
|
21
|
-
def organization_consultations
|
22
|
-
Decidim::Consultations::OrganizationConsultations.new(organization).query
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|