decidim-action_delegator 0.8.2 → 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.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +104 -58
  3. data/Rakefile +2 -2
  4. data/app/commands/decidim/action_delegator/admin/create_delegation.rb +1 -3
  5. data/app/commands/decidim/action_delegator/admin/create_setting.rb +5 -2
  6. data/app/commands/decidim/action_delegator/admin/update_setting.rb +4 -2
  7. data/app/controllers/concerns/decidim/action_delegator/devise/sessions_controller_override.rb +1 -1
  8. data/app/controllers/concerns/decidim/action_delegator/election_per_question_votes_controller_override.rb +65 -0
  9. data/app/controllers/concerns/decidim/action_delegator/election_votes_controller_override.rb +38 -0
  10. data/app/controllers/concerns/decidim/action_delegator/votes_controller_methods.rb +46 -0
  11. data/app/controllers/decidim/action_delegator/admin/application_controller.rb +11 -5
  12. data/app/controllers/decidim/action_delegator/admin/delegations_controller.rb +2 -10
  13. data/app/controllers/decidim/action_delegator/admin/invite_participants_controller.rb +0 -8
  14. data/app/controllers/decidim/action_delegator/admin/manage_delegations_controller.rb +13 -20
  15. data/app/controllers/decidim/action_delegator/admin/manage_participants_controller.rb +11 -19
  16. data/app/controllers/decidim/action_delegator/admin/participants_controller.rb +1 -9
  17. data/app/controllers/decidim/action_delegator/admin/permissions_controller.rb +1 -24
  18. data/app/controllers/decidim/action_delegator/admin/ponderations_controller.rb +0 -8
  19. data/app/controllers/decidim/action_delegator/admin/settings_controller.rb +12 -12
  20. data/app/controllers/decidim/action_delegator/application_controller.rb +3 -3
  21. data/app/controllers/decidim/action_delegator/elections/admin/results_controller.rb +58 -0
  22. data/app/controllers/decidim/action_delegator/elections/results_controller.rb +36 -0
  23. data/app/controllers/decidim/action_delegator/user_delegations_controller.rb +1 -1
  24. data/app/controllers/decidim/action_delegator/verifications/delegations_verifier/authorizations_controller.rb +14 -18
  25. data/app/forms/decidim/action_delegator/admin/action_delegator_census_form.rb +44 -0
  26. data/app/forms/decidim/action_delegator/admin/csv_import_form.rb +17 -0
  27. data/app/forms/decidim/action_delegator/admin/ponderation_form.rb +2 -1
  28. data/app/forms/decidim/action_delegator/admin/setting_form.rb +16 -10
  29. data/app/forms/decidim/action_delegator/censuses/internal_users_form.rb +32 -0
  30. data/app/forms/decidim/action_delegator/verifications/delegations_verifier_form.rb +41 -25
  31. data/app/helpers/decidim/action_delegator/admin/{delegation_helper.rb → settings_helper.rb} +3 -16
  32. data/app/helpers/decidim/action_delegator/settings_helper.rb +124 -0
  33. data/app/jobs/decidim/action_delegator/admin/invite_participants_job.rb +1 -1
  34. data/app/jobs/decidim/action_delegator/send_sms_job.rb +2 -2
  35. data/app/jobs/decidim/action_delegator/twilio_send_sms_job.rb +2 -2
  36. data/app/models/decidim/action_delegator/delegation.rb +15 -14
  37. data/app/models/decidim/action_delegator/participant.rb +7 -10
  38. data/app/models/decidim/action_delegator/ponderation.rb +0 -2
  39. data/app/models/decidim/action_delegator/setting.rb +14 -32
  40. data/app/overrides/decidim/elections/admin/dashboard/_results/_add_results_contents.html.erb.deface +10 -0
  41. data/app/overrides/decidim/elections/admin/dashboard/_results/_add_results_tabs.html.erb.deface +3 -0
  42. data/app/overrides/decidim/elections/elections/_election_aside/add_delegation_buttons.html.erb.deface +3 -0
  43. data/app/overrides/decidim/elections/elections/_vote_results/replace_results_div.html.erb.deface +8 -0
  44. data/app/overrides/decidim/elections/per_question_votes/show/add_delegation_hidden_input.html.erb.deface +3 -0
  45. data/app/overrides/decidim/elections/per_question_votes/show/add_delegation_id_to_links.html.erb.deface +3 -0
  46. data/app/overrides/decidim/elections/per_question_votes/waiting/add_delegation_buttons.html.erb.deface +3 -0
  47. data/app/overrides/decidim/elections/votes/receipt/add_delegation_buttons.html.erb.deface +3 -0
  48. data/app/packs/entrypoints/decidim_action_delegator_elections.js +1 -0
  49. data/app/packs/src/decidim/action_delegator/elections_live_results.js +160 -0
  50. data/app/permissions/decidim/action_delegator/admin/permissions.rb +29 -0
  51. data/app/permissions/decidim/action_delegator/permissions.rb +6 -30
  52. data/app/presenters/decidim/action_delegator/setting_presenter.rb +33 -0
  53. data/app/queries/decidim/action_delegator/action_delegator_census_users.rb +51 -0
  54. data/app/queries/decidim/action_delegator/authorized_resources.rb +28 -0
  55. data/app/queries/decidim/action_delegator/election_settings.rb +23 -0
  56. data/app/queries/decidim/action_delegator/{delegated_votes_versions.rb → elections_delegated_votes_versions.rb} +8 -8
  57. data/app/queries/decidim/action_delegator/elections_question_responses_by_type.rb +33 -0
  58. data/app/queries/decidim/action_delegator/elections_question_weighted_responses.rb +28 -0
  59. data/app/queries/decidim/action_delegator/elections_votes_with_ponderations.rb +62 -0
  60. data/app/services/decidim/action_delegator/participants_csv_importer.rb +1 -1
  61. data/app/services/decidim/action_delegator/sms_gateway.rb +2 -2
  62. data/app/views/decidim/action_delegator/admin/censuses/_action_delegator_census_form.html.erb +44 -0
  63. data/app/views/decidim/action_delegator/admin/censuses/_action_delegator_census_options_form.html.erb +25 -0
  64. data/app/views/decidim/action_delegator/admin/delegations/index.html.erb +12 -13
  65. data/app/views/decidim/action_delegator/admin/delegations/new.html.erb +29 -27
  66. data/app/views/decidim/action_delegator/admin/manage_delegations/new.html.erb +36 -24
  67. data/app/views/decidim/action_delegator/admin/manage_participants/new.html.erb +47 -33
  68. data/app/views/decidim/action_delegator/admin/participants/_form.html.erb +14 -8
  69. data/app/views/decidim/action_delegator/admin/participants/edit.html.erb +11 -13
  70. data/app/views/decidim/action_delegator/admin/participants/index.html.erb +20 -25
  71. data/app/views/decidim/action_delegator/admin/participants/new.html.erb +11 -13
  72. data/app/views/decidim/action_delegator/admin/ponderations/_form.html.erb +13 -7
  73. data/app/views/decidim/action_delegator/admin/ponderations/edit.html.erb +11 -13
  74. data/app/views/decidim/action_delegator/admin/ponderations/index.html.erb +8 -11
  75. data/app/views/decidim/action_delegator/admin/ponderations/new.html.erb +11 -13
  76. data/app/views/decidim/action_delegator/admin/settings/_form.html.erb +26 -12
  77. data/app/views/decidim/action_delegator/admin/settings/_participants_sync_check.html.erb +1 -1
  78. data/app/views/decidim/action_delegator/admin/settings/_setting_checks.html.erb +11 -16
  79. data/app/views/decidim/action_delegator/admin/settings/edit.html.erb +11 -12
  80. data/app/views/decidim/action_delegator/admin/settings/index.html.erb +22 -19
  81. data/app/views/decidim/action_delegator/admin/settings/new.html.erb +11 -12
  82. data/app/views/decidim/action_delegator/admin/shared/_tabs_menu.html.erb +15 -0
  83. data/app/views/decidim/action_delegator/censuses/_internal_users_form.html.erb +61 -0
  84. data/app/views/decidim/action_delegator/elections/_delegation_buttons.html.erb +10 -0
  85. data/app/views/decidim/action_delegator/elections/_normal_election_buttons.html.erb +13 -0
  86. data/app/views/decidim/action_delegator/elections/_per_question_buttons.html.erb +9 -0
  87. data/app/views/decidim/action_delegator/elections/_per_question_waiting_buttons.html.erb +19 -0
  88. data/app/views/decidim/action_delegator/elections/_vote_results.html.erb +10 -0
  89. data/app/views/decidim/action_delegator/elections/_vote_results_question.html.erb +13 -0
  90. data/app/views/decidim/action_delegator/elections/admin/dashboard/_by_type_and_weight.html.erb +45 -0
  91. data/app/views/decidim/action_delegator/elections/admin/dashboard/_results_tabs.html.erb +5 -0
  92. data/app/views/decidim/action_delegator/elections/admin/dashboard/_results_type_info.html.erb +4 -0
  93. data/app/views/decidim/action_delegator/elections/admin/dashboard/_sum_of_weights.html.erb +43 -0
  94. data/app/views/decidim/action_delegator/elections/admin/dashboard/_totals.html.erb +27 -0
  95. data/app/views/decidim/action_delegator/user_delegations/index.html.erb +13 -14
  96. data/app/views/decidim/action_delegator/verifications/delegations_verifier/authorizations/edit.html.erb +19 -29
  97. data/app/views/decidim/action_delegator/verifications/delegations_verifier/authorizations/new.html.erb +42 -40
  98. data/config/assets.rb +3 -36
  99. data/config/i18n-tasks.yml +27 -5
  100. data/config/locales/ca.yml +103 -146
  101. data/config/locales/cs.yml +161 -145
  102. data/config/locales/en.yml +110 -75
  103. data/config/locales/es.yml +108 -154
  104. data/db/migrate/20200824113801_create_settings.rb +1 -1
  105. data/db/migrate/20250729104037_add_title_to_action_delegator_settings.rb +31 -0
  106. data/lib/decidim/action_delegator/admin_engine.rb +72 -45
  107. data/lib/decidim/action_delegator/common_rake.rb +13 -0
  108. data/lib/decidim/action_delegator/engine.rb +48 -19
  109. data/lib/decidim/action_delegator/test/delegation_examples.rb +144 -0
  110. data/lib/decidim/action_delegator/test/factories.rb +11 -6
  111. data/lib/decidim/action_delegator/verifications/delegations_authorizer.rb +80 -47
  112. data/lib/decidim/action_delegator/version.rb +3 -3
  113. data/lib/decidim/action_delegator.rb +8 -26
  114. data/lib/tasks/migrate_consultations.rake +382 -0
  115. data/lib/tasks/upgrade_tasks.rake +5 -0
  116. data/package.json +10 -27
  117. metadata +72 -122
  118. data/app/commands/concerns/decidim/action_delegator/consultations/multiple_vote_question_override.rb +0 -31
  119. data/app/commands/concerns/decidim/action_delegator/consultations/vote_question_override.rb +0 -44
  120. data/app/commands/decidim/action_delegator/admin/fix_resource_permissions.rb +0 -46
  121. data/app/commands/decidim/action_delegator/vote_delegation.rb +0 -28
  122. data/app/controllers/concerns/decidim/action_delegator/consultations/consultations_controller_override.rb +0 -16
  123. data/app/controllers/concerns/decidim/action_delegator/consultations/question_multiple_votes_controller_override.rb +0 -29
  124. data/app/controllers/concerns/decidim/action_delegator/consultations/question_votes_controller_override.rb +0 -57
  125. data/app/controllers/concerns/decidim/action_delegator/consultations/questions_controller_override.rb +0 -16
  126. data/app/controllers/concerns/decidim/action_delegator/needs_consultation_styles.rb +0 -24
  127. data/app/controllers/decidim/action_delegator/admin/consultations/exports_controller.rb +0 -27
  128. data/app/controllers/decidim/action_delegator/admin/consultations_controller.rb +0 -47
  129. data/app/controllers/decidim/action_delegator/admin/exports/_sum_of_weights_controller.rb +0 -15
  130. data/app/controllers/decidim/action_delegator/questions_summary_controller.rb +0 -14
  131. data/app/forms/concerns/decidim/action_delegator/consultations/vote_form_override.rb +0 -15
  132. data/app/helpers/decidim/action_delegator/delegation_helper.rb +0 -13
  133. data/app/jobs/decidim/action_delegator/export_consultation_results_job.rb +0 -51
  134. data/app/models/concerns/decidim/action_delegator/consultations/question_override.rb +0 -36
  135. data/app/models/concerns/decidim/action_delegator/consultations/vote_override.rb +0 -15
  136. data/app/models/decidim/action_delegator/unversioned_vote.rb +0 -19
  137. data/app/models/decidim/action_delegator/whodunnit_vote.rb +0 -28
  138. data/app/overrides/decidim/consultations/admin/consultations/results/add_ongoing_warning.html.erb.deface +0 -3
  139. data/app/overrides/decidim/consultations/consultations/_question/add_delegation_link.html.erb.deface +0 -3
  140. data/app/overrides/decidim/consultations/consultations/_question/replace_vote_info.html.erb.deface +0 -4
  141. data/app/overrides/decidim/consultations/consultations/_regular_questions/prevent_empty_questions.html.erb.deface +0 -10
  142. data/app/overrides/decidim/consultations/consultations/_regular_questions/remove_highlighted_scopes.html.erb.deface +0 -5
  143. data/app/overrides/decidim/consultations/question_multiple_votes/_form/add_delegation_notice.html.erb.deface +0 -8
  144. data/app/overrides/decidim/consultations/questions/_results/replace_results.html.erb.deface +0 -3
  145. data/app/overrides/decidim/consultations/questions/_vote_button/add_delegations_link.html.erb.deface +0 -3
  146. data/app/overrides/decidim/consultations/questions/_vote_button/add_modal.html.erb.deface +0 -3
  147. data/app/overrides/decidim/consultations/questions/_vote_button/add_modal_javascript.html.erb.deface +0 -3
  148. data/app/overrides/decidim/consultations/questions/_vote_button/replace_delegation_to_multivote_link.html.erb.deface +0 -8
  149. data/app/overrides/decidim/consultations/questions/_vote_modal/add_delegation_callout.html.erb.deface +0 -3
  150. data/app/overrides/decidim/consultations/questions/_vote_modal_confirm/add_delegation_callout.html.erb.deface +0 -3
  151. data/app/overrides/decidim/consultations/questions/_vote_modal_confirm/add_hidden_field.html.erb.deface +0 -3
  152. data/app/overrides/layouts/decidim/_consultation_header/add_consultation_callout.html.erb.deface +0 -9
  153. data/app/overrides/layouts/decidim/_question_header/add_consultation_callout.html.erb.deface +0 -9
  154. data/app/overrides/layouts/decidim/admin/remove_deprecation.rb +0 -10
  155. data/app/packs/entrypoints/decidim_action_delegator.scss +0 -1
  156. data/app/packs/entrypoints/decidim_action_delegator_questions.js +0 -5
  157. data/app/packs/entrypoints/decidim_action_delegator_questions_summary.js +0 -1
  158. data/app/packs/src/decidim/action_delegator/questions.js +0 -33
  159. data/app/packs/src/decidim/action_delegator/summary.js +0 -24
  160. data/app/packs/stylesheets/decidim/action_delegator/questions.scss +0 -26
  161. data/app/permissions/concerns/decidim/action_delegator/consultations/permissions_override.rb +0 -35
  162. data/app/presenters/decidim/action_delegator/question_with_totals.rb +0 -24
  163. data/app/queries/decidim/action_delegator/consultation_delegations.rb +0 -25
  164. data/app/queries/decidim/action_delegator/delegates_votes_by_consultation.rb +0 -24
  165. data/app/queries/decidim/action_delegator/delegates_votes_by_question.rb +0 -26
  166. data/app/queries/decidim/action_delegator/delegation_votes.rb +0 -30
  167. data/app/queries/decidim/action_delegator/grantee_delegations.rb +0 -24
  168. data/app/queries/decidim/action_delegator/organization_delegations.rb +0 -26
  169. data/app/queries/decidim/action_delegator/organization_settings.rb +0 -31
  170. data/app/queries/decidim/action_delegator/responses.rb +0 -24
  171. data/app/queries/decidim/action_delegator/responses_by_membership.rb +0 -58
  172. data/app/queries/decidim/action_delegator/scrutiny.rb +0 -87
  173. data/app/queries/decidim/action_delegator/setting_delegations.rb +0 -19
  174. data/app/queries/decidim/action_delegator/sum_of_membership_weight.rb +0 -44
  175. data/app/queries/decidim/action_delegator/sum_of_weights.rb +0 -25
  176. data/app/queries/decidim/action_delegator/type_and_weight.rb +0 -26
  177. data/app/queries/decidim/action_delegator/voted_with_ponderations.rb +0 -30
  178. data/app/queries/decidim/action_delegator/votes_count_aggregation.rb +0 -34
  179. data/app/serializers/decidim/action_delegator/consultation_results_serializer.rb +0 -19
  180. data/app/views/decidim/action_delegator/admin/consultations/_ongoing_consultation_warning.html.erb +0 -3
  181. data/app/views/decidim/action_delegator/admin/consultations/results.html.erb +0 -65
  182. data/app/views/decidim/action_delegator/admin/consultations/weighted_results.html.erb +0 -66
  183. data/app/views/decidim/action_delegator/consultations/_link_to_question.html.erb +0 -11
  184. data/app/views/decidim/action_delegator/consultations/_link_with_results.html.erb +0 -11
  185. data/app/views/decidim/action_delegator/consultations/questions/_callout.html.erb +0 -5
  186. data/app/views/decidim/action_delegator/consultations/questions/_delegations_modal.html.erb +0 -34
  187. data/app/views/decidim/action_delegator/consultations/questions/_link_to_delegations.html.erb +0 -15
  188. data/app/views/decidim/action_delegator/consultations/questions/_vote_delegated_active.html.erb +0 -32
  189. data/app/views/decidim/action_delegator/consultations/questions/_vote_delegated_finished.html.erb +0 -9
  190. data/app/views/decidim/action_delegator/consultations/questions/_vote_delegated_upcoming.html.erb +0 -8
  191. data/app/views/decidim/action_delegator/consultations/questions/_weight_results.html.erb +0 -8
  192. data/app/views/decidim/consultations/question_votes/_callout.html.erb +0 -47
  193. data/app/views/decidim/consultations/question_votes/update_vote_button.js.erb +0 -82
  194. 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 Admin
6
- module Exports
7
- class SumOfWeightsController < Admin::Consultations::ExportsController
8
- def type
9
- "sum_of_weights"
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module ActionDelegator
5
- # This controller handles user profile actions for this module
6
- class QuestionsSummaryController < ActionDelegator::ApplicationController
7
- include Decidim::Consultations::NeedsConsultation
8
-
9
- def show
10
- render partial: "decidim/consultations/question_votes/callout", locals: { consultation: current_consultation }
11
- end
12
- end
13
- end
14
- 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,36 +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
-
15
- def weighted_responses
16
- @weighted_responses ||= Decidim::ActionDelegator::SumOfWeights.new(consultation).query.group_by(&:question_id)
17
- end
18
-
19
- def total_weighted_votes
20
- @total_weighted_votes ||= weighted_responses[id].sum(&:votes_count)
21
- end
22
-
23
- def most_weighted_voted_response
24
- weighted_responses[id].max_by(&:votes_count)
25
- end
26
-
27
- def responses_sorted_by_weighted_votes
28
- @responses_sorted_by_weighted_votes ||= weighted_responses.transform_values do |responses|
29
- responses.sort_by { |response| -response.votes_count }
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module ActionDelegator
5
- module Consultations
6
- module VoteOverride
7
- extend ActiveSupport::Concern
8
-
9
- included do
10
- has_paper_trail
11
- end
12
- end
13
- end
14
- end
15
- 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,3 +0,0 @@
1
- <!-- insert_before '.table-list' -->
2
-
3
- <%= render "decidim/action_delegator/admin/consultations/ongoing_consultation_warning", consultation: current_consultation %>
@@ -1,3 +0,0 @@
1
- <!-- insert_after "erb[loud]:contains('display_take_part_button_for(question)')" -->
2
-
3
- <%= render partial: "decidim/action_delegator/consultations/link_to_question", locals: { question: question } %>
@@ -1,4 +0,0 @@
1
- <!-- replace_contents "erb[silent]:contains('if question.results_published?')"
2
- closing_selector "erb[silent]:contains('else')" -->
3
-
4
- <%= render partial: "decidim/action_delegator/consultations/link_with_results", locals: { question: question } %>
@@ -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,3 +0,0 @@
1
- <!-- replace_contents ".card--list" -->
2
-
3
- <%= render partial: "decidim/action_delegator/consultations/questions/weight_results", locals: { response: response, question: question } %>
@@ -1,3 +0,0 @@
1
- <!-- insert_before "erb[silent]:contains('elsif question.consultation.active?')" -->
2
-
3
- <%= render partial: "decidim/action_delegator/consultations/questions/link_to_delegations", locals: { question: question } %>
@@ -1,3 +0,0 @@
1
- <!-- insert_before "erb[silent]:contains('content_for :js_content')" -->
2
-
3
- <%= render partial: "decidim/action_delegator/consultations/questions/delegations_modal", locals: { question: question } %>
@@ -1,3 +0,0 @@
1
- <!-- insert_before "erb[loud]:contains('javascript_pack_tag')" -->
2
-
3
- <%= javascript_pack_tag "decidim_action_delegator_questions" %>
@@ -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,3 +0,0 @@
1
- <!-- insert_after ".reveal__header" -->
2
-
3
- <%= render partial: "decidim/action_delegator/consultations/questions/callout", locals: { consultation: question.consultation } %>
@@ -1,3 +0,0 @@
1
- <!-- insert_after ".reveal__header" -->
2
-
3
- <%= render partial: "decidim/action_delegator/consultations/questions/callout", locals: { consultation: question.consultation } %>
@@ -1,3 +0,0 @@
1
- <!-- insert_after "erb[loud]:contains('form.hidden_field :decidim_consultations_response_id')" -->
2
-
3
- <%= hidden_field_tag :decidim_consultations_delegation_id, nil, id: "decidim_consultations_delegation_id" %>
@@ -1,9 +0,0 @@
1
- <!-- insert_after '.consultations-home-banner' -->
2
-
3
- <% if user_signed_in? %>
4
- <div id="user-answers-summary" class="row" style="padding:0 1rem;margint-top:-1rem" data-summary-path="<%= decidim_action_delegator.questions_summary_path(current_consultation) %>">
5
- <%= render "decidim/consultations/question_votes/callout", consultation: current_consultation %>
6
-
7
- <%= javascript_pack_tag "decidim_action_delegator_questions_summary" %>
8
- </div>
9
- <% end %>
@@ -1,9 +0,0 @@
1
- <!-- insert_before 'h2' -->
2
-
3
- <% if user_signed_in? %>
4
- <div id="user-answers-summary" data-summary-path="<%= decidim_action_delegator.questions_summary_path(current_question.consultation) %>">
5
- <%= render "decidim/consultations/question_votes/callout", consultation: current_question.consultation %>
6
-
7
- <%= javascript_pack_tag "decidim_action_delegator_questions_summary" %>
8
- </div>
9
- <% 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,5 +0,0 @@
1
- import "src/decidim/action_delegator/questions.js";
2
-
3
- require.context("../images", true)
4
-
5
- import "entrypoints/decidim_action_delegator.scss";
@@ -1 +0,0 @@
1
- import "src/decidim/action_delegator/summary.js";
@@ -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,24 +0,0 @@
1
- $(() => {
2
- const $usersAnswers = $("#user-answers-summary");
3
- const path = $usersAnswers.data("summaryPath");
4
- let $button = $("#consultations-questions-summary-button");
5
- let $modal = $("#consultations-questions-summary-modal");
6
- const $div = $(".question-vote-cabin").parent();
7
- const openModal = (evt) => {
8
- evt.preventDefault();
9
- $modal.foundation("open");
10
- };
11
-
12
- $button.on("click", openModal);
13
-
14
- $div.bind("DOMSubtreeModified", function() {
15
- // console.log("tree changed", path);
16
- $usersAnswers.load(path, () => {
17
- $button = $usersAnswers.find("#consultations-questions-summary-button");
18
- $modal = $usersAnswers.find("#consultations-questions-summary-modal");
19
- // console.log("usersanswer loaded")
20
- $usersAnswers.foundation();
21
- $button.on("click", openModal);
22
- });
23
- });
24
- });
@@ -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
- button {
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
- }
@@ -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