decidim-action_delegator 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +97 -36
- data/app/commands/{decidim → concerns/decidim}/action_delegator/consultations/vote_question_override.rb +9 -1
- data/app/commands/decidim/action_delegator/admin/create_delegation.rb +5 -1
- data/app/commands/decidim/action_delegator/admin/create_participant.rb +41 -0
- data/app/commands/decidim/action_delegator/admin/create_ponderation.rb +38 -0
- data/app/commands/decidim/action_delegator/admin/create_setting.rb +49 -0
- data/app/commands/decidim/action_delegator/admin/fix_resource_permissions.rb +46 -0
- data/app/commands/decidim/action_delegator/admin/update_participant.rb +42 -0
- data/app/commands/decidim/action_delegator/admin/update_ponderation.rb +41 -0
- data/app/commands/decidim/action_delegator/admin/update_setting.rb +66 -0
- data/app/controllers/concerns/decidim/action_delegator/consultations/consultations_controller_override.rb +16 -0
- data/app/controllers/{decidim → concerns/decidim}/action_delegator/consultations/question_multiple_votes_controller_override.rb +2 -1
- data/app/controllers/{decidim → concerns/decidim}/action_delegator/consultations/question_votes_controller_override.rb +2 -0
- data/app/controllers/concerns/decidim/action_delegator/consultations/questions_controller_override.rb +16 -0
- data/app/controllers/concerns/decidim/action_delegator/needs_consultation_styles.rb +24 -0
- data/app/controllers/decidim/action_delegator/admin/consultations_controller.rb +22 -8
- data/app/controllers/decidim/action_delegator/admin/delegations_controller.rb +9 -9
- data/app/controllers/decidim/action_delegator/admin/invite_participants_controller.rb +84 -0
- data/app/controllers/decidim/action_delegator/admin/manage_delegations_controller.rb +48 -0
- data/app/controllers/decidim/action_delegator/admin/manage_participants_controller.rb +59 -0
- data/app/controllers/decidim/action_delegator/admin/participants_controller.rb +102 -0
- data/app/controllers/decidim/action_delegator/admin/permissions_controller.rb +40 -0
- data/app/controllers/decidim/action_delegator/admin/ponderations_controller.rb +101 -0
- data/app/controllers/decidim/action_delegator/admin/settings_controller.rb +51 -12
- data/app/controllers/decidim/action_delegator/verifications/delegations_verifier/authorizations_controller.rb +108 -0
- data/app/forms/decidim/action_delegator/admin/delegation_form.rb +23 -4
- data/app/forms/decidim/action_delegator/admin/invitation_participant_form.rb +10 -0
- data/app/forms/decidim/action_delegator/admin/participant_form.rb +44 -0
- data/app/forms/decidim/action_delegator/admin/ponderation_form.rb +28 -0
- data/app/forms/decidim/action_delegator/admin/setting_form.rb +28 -0
- data/app/forms/decidim/action_delegator/verifications/delegations_verifier_form.rb +131 -0
- data/app/helpers/decidim/action_delegator/admin/delegation_helper.rb +40 -3
- data/app/helpers/decidim/action_delegator/delegation_helper.rb +13 -0
- data/app/jobs/decidim/action_delegator/admin/import_csv_job.rb +27 -0
- data/app/jobs/decidim/action_delegator/admin/invite_participants_job.rb +39 -0
- data/app/jobs/decidim/action_delegator/sync_participants_job.rb +27 -0
- data/app/mailers/decidim/action_delegator/import_mailer.rb +31 -0
- data/app/models/decidim/action_delegator/delegation.rb +11 -0
- data/app/models/decidim/action_delegator/participant.rb +106 -0
- data/app/models/decidim/action_delegator/ponderation.rb +28 -0
- data/app/models/decidim/action_delegator/setting.rb +50 -1
- data/app/overrides/decidim/consultations/consultations/_question/add_delegation_link.html.erb.deface +3 -0
- data/app/overrides/decidim/consultations/consultations/_regular_questions/remove_highlighted_scopes.html.erb.deface +4 -0
- data/app/overrides/decidim/consultations/question_multiple_votes/_form/add_delegation_notice.html.erb.deface +8 -0
- data/app/overrides/decidim/consultations/questions/_vote_button/add_delegations_link.html.erb.deface +3 -0
- data/app/overrides/decidim/consultations/questions/_vote_button/add_modal.html.erb.deface +3 -0
- data/app/overrides/decidim/consultations/questions/_vote_button/replace_delegation_to_multivote_link.html.erb.deface +8 -0
- data/app/overrides/decidim/consultations/questions/_vote_modal/add_delegation_callout.html.erb.deface +3 -0
- data/app/overrides/decidim/consultations/questions/_vote_modal_confirm/add_delegation_callout.html.erb.deface +3 -0
- data/app/overrides/decidim/consultations/questions/_vote_modal_confirm/add_hidden_field.html.erb.deface +3 -0
- data/app/overrides/layouts/decidim/admin/remove_deprecation.rb +10 -0
- data/app/packs/entrypoints/decidim_action_delegator_questions.js +2 -0
- data/app/packs/src/decidim/action_delegator/questions.js +27 -0
- data/app/packs/stylesheets/decidim/action_delegator/questions.scss +4 -3
- data/app/permissions/concerns/decidim/action_delegator/consultations/permissions_override.rb +35 -0
- data/app/permissions/decidim/action_delegator/permissions.rb +6 -2
- data/app/queries/decidim/action_delegator/delegated_votes_versions.rb +5 -11
- data/app/queries/decidim/action_delegator/organization_settings.rb +6 -0
- data/app/queries/decidim/action_delegator/responses_by_membership.rb +3 -20
- data/app/queries/decidim/action_delegator/sum_of_membership_weight.rb +1 -5
- data/app/queries/decidim/action_delegator/sum_of_weights.rb +1 -1
- data/app/queries/decidim/action_delegator/type_and_weight.rb +1 -1
- data/app/queries/decidim/action_delegator/voted_with_ponderations.rb +30 -0
- data/app/services/decidim/action_delegator/csv_importer.rb +86 -0
- data/app/services/decidim/action_delegator/delegations_csv_importer.rb +54 -0
- data/app/services/decidim/action_delegator/participants_csv_importer.rb +131 -0
- data/app/views/decidim/action_delegator/admin/consultations/results.html.erb +3 -3
- data/app/views/decidim/action_delegator/admin/{results/sum_of_weights/index.html.erb → consultations/weighted_results.html.erb} +3 -3
- data/app/views/decidim/action_delegator/admin/delegations/index.html.erb +8 -3
- data/app/views/decidim/action_delegator/admin/delegations/new.html.erb +15 -12
- data/app/views/decidim/action_delegator/admin/manage_delegations/new.html.erb +25 -0
- data/app/views/decidim/action_delegator/admin/manage_participants/new.html.erb +33 -0
- data/app/views/decidim/action_delegator/admin/participants/_form.html.erb +9 -0
- data/app/views/decidim/action_delegator/admin/participants/_missing_registered_check.html.erb +17 -0
- data/app/views/decidim/action_delegator/admin/participants/edit.html.erb +21 -0
- data/app/views/decidim/action_delegator/admin/participants/index.html.erb +72 -0
- data/app/views/decidim/action_delegator/admin/participants/new.html.erb +21 -0
- data/app/views/decidim/action_delegator/admin/ponderations/_form.html.erb +8 -0
- data/app/views/decidim/action_delegator/admin/ponderations/edit.html.erb +21 -0
- data/app/views/decidim/action_delegator/admin/ponderations/index.html.erb +40 -0
- data/app/views/decidim/action_delegator/admin/ponderations/new.html.erb +21 -0
- data/app/views/decidim/action_delegator/admin/settings/_check_verifier.html.erb +5 -0
- data/app/views/decidim/action_delegator/admin/settings/_form.html.erb +16 -0
- data/app/views/decidim/action_delegator/admin/settings/_participants_email_check.html.erb +7 -0
- data/app/views/decidim/action_delegator/admin/settings/_participants_sync_check.html.erb +11 -0
- data/app/views/decidim/action_delegator/admin/settings/_setting_checks.html.erb +81 -0
- data/app/views/decidim/action_delegator/admin/settings/edit.html.erb +18 -0
- data/app/views/decidim/action_delegator/admin/settings/index.html.erb +25 -5
- data/app/views/decidim/action_delegator/admin/settings/new.html.erb +14 -26
- data/app/views/decidim/action_delegator/consultations/_link_to_question.html.erb +11 -0
- data/app/views/decidim/action_delegator/consultations/questions/_delegations_modal.html.erb +36 -0
- data/app/views/decidim/action_delegator/consultations/questions/_link_to_delegations.html.erb +11 -0
- data/app/views/decidim/action_delegator/consultations/questions/_vote_delegated_active.html.erb +32 -0
- data/app/views/decidim/action_delegator/consultations/questions/_vote_delegated_finished.html.erb +9 -0
- data/app/views/decidim/action_delegator/consultations/questions/_vote_delegated_upcoming.html.erb +8 -0
- data/app/views/decidim/action_delegator/import_mailer/import.html.erb +11 -0
- data/app/views/decidim/{verifications/sms/authorizations/new.html.erb → action_delegator/verifications/delegations_verifier/authorizations/edit.html.erb} +12 -7
- data/app/views/decidim/action_delegator/verifications/delegations_verifier/authorizations/new.html.erb +49 -0
- data/config/assets.rb +1 -3
- data/config/i18n-tasks.yml +8 -0
- data/config/locales/ca.yml +287 -23
- data/config/locales/cs.yml +286 -18
- data/config/locales/en.yml +331 -24
- data/config/locales/es.yml +288 -24
- data/db/migrate/20230323101247_create_decidim_action_delegator_ponderations.rb +12 -0
- data/db/migrate/20230323210000_create_decidim_action_delegator_participants.rb +13 -0
- data/db/migrate/20230323223752_add_decidim_action_delegator_verification_method.rb +7 -0
- data/db/migrate/20230412105710_add_decidim_action_delegator_participants_user_id.rb +7 -0
- data/lib/decidim/action_delegator/admin_engine.rb +68 -6
- data/lib/decidim/action_delegator/engine.rb +25 -15
- data/lib/decidim/action_delegator/test/factories.rb +22 -7
- data/lib/decidim/action_delegator/verifications/delegations_authorizer.rb +85 -0
- data/lib/decidim/action_delegator/verifications/delegations_verifier/engine.rb +25 -0
- data/lib/decidim/action_delegator/verifications/delegations_verifier.rb +12 -0
- data/lib/decidim/action_delegator/version.rb +3 -3
- data/lib/decidim/action_delegator.rb +41 -0
- data/lib/tasks/import_direct_verification.rake +30 -0
- data/package.json +57 -0
- metadata +115 -50
- data/app/controllers/decidim/action_delegator/admin/results/sum_of_weights_controller.rb +0 -37
- data/app/controllers/decidim/action_delegator/verifications/sms/authorizations_controller_override.rb +0 -38
- data/app/packs/entrypoints/decidim_action_delegator_admin_action_delegator_js.js +0 -1
- data/app/packs/entrypoints/decidim_action_delegator_questions_js.js +0 -1
- data/app/packs/src/decidim/action_delegator/admin/action_delegator.js.es6 +0 -3
- data/app/packs/src/decidim/action_delegator/questions.js.es6 +0 -26
- data/app/permissions/decidim/action_delegator/consultations_permissions_extension.rb +0 -27
- data/app/presenters/decidim/action_delegator/admin/consultation_presenter.rb +0 -15
- data/app/presenters/decidim/action_delegator/admin/setting_presenter.rb +0 -13
- data/app/queries/decidim/action_delegator/decrypted_authorizations.rb +0 -112
- data/app/queries/decidim/action_delegator/json_build_object_query.rb +0 -45
- data/app/queries/decidim/action_delegator/voted_with_direct_verification.rb +0 -53
- data/app/views/decidim/action_delegator/_delegations_modal.html.erb +0 -93
- data/app/views/decidim/action_delegator/_link_to_delegations.html.erb +0 -5
- data/app/views/decidim/action_delegator/_link_to_question.html.erb +0 -5
- data/app/views/decidim/consultations/consultations/_question.html.erb +0 -41
- data/app/views/decidim/consultations/consultations/show.html.erb +0 -14
- data/app/views/decidim/consultations/question_multiple_votes/_form.html.erb +0 -25
- data/app/views/decidim/consultations/questions/_vote_button.html.erb +0 -106
- data/app/views/decidim/consultations/questions/_vote_modal.html.erb +0 -30
- data/app/views/decidim/consultations/questions/_vote_modal_confirm.html.erb +0 -38
- data/app/views/layouts/decidim/action_delegator/admin/_users_sidebar.html.erb +0 -56
- data/app/views/layouts/decidim/action_delegator/admin/delegations.html.erb +0 -13
- data/app/views/layouts/decidim/admin/consultation.html.erb +0 -56
- data/app/views/layouts/decidim/admin/question.html.erb +0 -98
- data/app/views/layouts/decidim/admin/users.html.erb +0 -7
- data/config/initializers/doorkeeper.rb +0 -492
- data/lib/json_key.rb +0 -10
- /data/app/commands/{decidim → concerns/decidim}/action_delegator/consultations/multiple_vote_question_override.rb +0 -0
- /data/app/controllers/decidim/action_delegator/admin/exports/{sum_of_weights_controller.rb → _sum_of_weights_controller.rb} +0 -0
- /data/app/forms/{decidim → concerns/decidim}/action_delegator/consultations/vote_form_override.rb +0 -0
- /data/app/models/{decidim → concerns/decidim}/action_delegator/consultations/vote_override.rb +0 -0
- /data/app/views/decidim/action_delegator/{_callout.html.erb → consultations/questions/_callout.html.erb} +0 -0
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
module Verifications
|
6
|
-
module Sms
|
7
|
-
module AuthorizationsControllerOverride
|
8
|
-
extend ActiveSupport::Concern
|
9
|
-
|
10
|
-
included do
|
11
|
-
def new
|
12
|
-
enforce_permission_to :create, :authorization, authorization: authorization
|
13
|
-
|
14
|
-
flash.now[:error] = I18n.t("decidim.action_delegator.authorizations.new.missing_phone_error") unless direct_authorization && membership_phone
|
15
|
-
|
16
|
-
@form = Decidim::Verifications::Sms::MobilePhoneForm.new mobile_phone_number: membership_phone
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def direct_authorization
|
22
|
-
@direct_authorization ||= Decidim::Authorization.find_by(
|
23
|
-
user: current_user,
|
24
|
-
name: "direct_verifications"
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
def membership_phone
|
29
|
-
return nil unless direct_authorization
|
30
|
-
|
31
|
-
direct_authorization.metadata["membership_phone"]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
import "src/decidim/action_delegator/admin/action_delegator.js.es6";
|
@@ -1 +0,0 @@
|
|
1
|
-
import "src/decidim/action_delegator/questions.js.es6";
|
@@ -1,26 +0,0 @@
|
|
1
|
-
$(() => {
|
2
|
-
const voteButton = $("#vote_button"),
|
3
|
-
delegationsButton = $("#delegations-button"),
|
4
|
-
delegationCallouts = $(".delegation-callout"),
|
5
|
-
delegationCalloutsMessage = $(".delegation-callout-message"),
|
6
|
-
delegationDialog = $("#delegations-modal"),
|
7
|
-
delegationVoteButtons = $(".delegation-vote-button"),
|
8
|
-
delegationField = $("#decidim_consultations_delegation_id"),
|
9
|
-
voteDialog = $("#question-vote-modal");
|
10
|
-
|
11
|
-
delegationsButton.click(() => {
|
12
|
-
delegationDialog.foundation("open");
|
13
|
-
});
|
14
|
-
|
15
|
-
delegationVoteButtons.click((e) => {
|
16
|
-
delegationDialog.foundation("close");
|
17
|
-
voteDialog.foundation("open");
|
18
|
-
delegationField.val($(e.currentTarget).data("delegation-id"));
|
19
|
-
delegationCalloutsMessage.text($(e.currentTarget).data("delegation-granter-name"));
|
20
|
-
delegationCallouts.removeClass("is-hidden");
|
21
|
-
});
|
22
|
-
|
23
|
-
voteButton.click(() => {
|
24
|
-
delegationCallouts.addClass("is-hidden");
|
25
|
-
});
|
26
|
-
});
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
module ConsultationsPermissionsExtension
|
6
|
-
# Overrides Decidim::Consultations::Permissions to account for delegation votes
|
7
|
-
def allowed_public_action?
|
8
|
-
return unless permission_action.scope == :public
|
9
|
-
return unless permission_action.subject == :question
|
10
|
-
|
11
|
-
# check if question has been limited by admins first
|
12
|
-
return unless authorized? :vote
|
13
|
-
|
14
|
-
case permission_action.action
|
15
|
-
when :vote
|
16
|
-
toggle_allow(question.can_be_voted_by?(user) || can_be_delegated?(user))
|
17
|
-
when :unvote
|
18
|
-
toggle_allow(question.can_be_unvoted_by?(user))
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def can_be_delegated?(user)
|
23
|
-
Delegation.granted_to?(user, question.consultation)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
module Admin
|
6
|
-
class ConsultationPresenter < SimpleDelegator
|
7
|
-
include Decidim::TranslationsHelper
|
8
|
-
|
9
|
-
def translated_title
|
10
|
-
@translated_title ||= translated_attribute(title)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "json_key"
|
4
|
-
|
5
|
-
module Decidim
|
6
|
-
module ActionDelegator
|
7
|
-
class DecryptedAuthorizations < Rectify::Query
|
8
|
-
METADATA_FIELDS = %w(
|
9
|
-
membership_type
|
10
|
-
membership_weight
|
11
|
-
).freeze
|
12
|
-
|
13
|
-
def initialize(relation)
|
14
|
-
@relation = relation
|
15
|
-
end
|
16
|
-
|
17
|
-
def query
|
18
|
-
authorizations
|
19
|
-
.project(
|
20
|
-
authorizations[:id],
|
21
|
-
authorizations[:name],
|
22
|
-
authorizations[:decidim_user_id],
|
23
|
-
*decrypted_authorizations_metadata_fields
|
24
|
-
)
|
25
|
-
.where(authorizations[:id].in(authorization_ids))
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
attr_reader :relation
|
31
|
-
|
32
|
-
def authorizations
|
33
|
-
Decidim::Authorization.arel_table
|
34
|
-
end
|
35
|
-
|
36
|
-
def decrypted_authorizations_metadata_fields
|
37
|
-
METADATA_FIELDS.map do |field|
|
38
|
-
decrypted_authorizations_metadata_field(field)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def decrypted_authorizations_metadata_field(field)
|
43
|
-
JsonBuildObjectQuery.new(
|
44
|
-
metadata_field_by_authorization_id(field).flatten,
|
45
|
-
authorizations[:id],
|
46
|
-
field
|
47
|
-
).to_sql
|
48
|
-
end
|
49
|
-
|
50
|
-
def metadata_field_by_authorization_id(field)
|
51
|
-
decrypted_authorizations.map do |hash|
|
52
|
-
[
|
53
|
-
hash.fetch("id"),
|
54
|
-
hash.fetch(field)
|
55
|
-
]
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def decrypted_authorizations
|
60
|
-
@decrypted_authorizations ||=
|
61
|
-
sql_query_results(encrypted_authorizations).map do |hash|
|
62
|
-
hash.transform_values! do |value|
|
63
|
-
if value.nil?
|
64
|
-
Arel.sql("NULL")
|
65
|
-
else
|
66
|
-
value.is_a?(String) ? decrypt_and_parse(value) : value
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def sql_query_results(sql)
|
73
|
-
ActiveRecord::Base.connection.exec_query(sql).to_a
|
74
|
-
end
|
75
|
-
|
76
|
-
def encrypted_authorizations
|
77
|
-
Decidim::Authorization
|
78
|
-
.select(
|
79
|
-
:id,
|
80
|
-
*authorizations_metadata_fields
|
81
|
-
)
|
82
|
-
.where(id: authorization_ids)
|
83
|
-
.to_sql
|
84
|
-
end
|
85
|
-
|
86
|
-
def authorizations_metadata_fields
|
87
|
-
METADATA_FIELDS.map do |field|
|
88
|
-
authorizations_metadata_field(field).as(field)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def authorizations_metadata_field(field)
|
93
|
-
JSONKey.new(authorizations[:metadata], field)
|
94
|
-
end
|
95
|
-
|
96
|
-
def authorization_ids
|
97
|
-
@authorization_ids ||= relation.pluck("decidim_authorizations.id").compact
|
98
|
-
end
|
99
|
-
|
100
|
-
def decrypt_and_parse(value)
|
101
|
-
Arel.sql("'#{JSON.parse(decrypt_value(value))}'")
|
102
|
-
end
|
103
|
-
|
104
|
-
def decrypt_value(value)
|
105
|
-
Decidim::AttributeEncryptor.decrypt(value)
|
106
|
-
rescue ActiveSupport::MessageEncryptor::InvalidMessage, ActiveSupport::MessageVerifier::InvalidSignature
|
107
|
-
# Support for legacy unencrypted values.
|
108
|
-
value
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
class JsonBuildObjectQuery
|
6
|
-
def initialize(json_args, query_field, aliaz)
|
7
|
-
@json_args = json_args
|
8
|
-
@query_field = query_field
|
9
|
-
@aliaz = aliaz
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_sql
|
13
|
-
Arel::Nodes::InfixOperation.new(
|
14
|
-
"->>",
|
15
|
-
json_build_object(json_args),
|
16
|
-
cast(query_field, :text)
|
17
|
-
).as(aliaz).to_sql
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
attr_reader :json_args, :query_field, :aliaz
|
23
|
-
|
24
|
-
# Returns the equivalent of `JSON_BUILD_OBJECT (ARRAY)` in Arel
|
25
|
-
def json_build_object(array)
|
26
|
-
Arel::Nodes::NamedFunction.new(
|
27
|
-
"JSON_BUILD_OBJECT",
|
28
|
-
[array]
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Returns the equivalent of `CAST ((<exprs>) AS <type>)` in Arel
|
33
|
-
def cast(*exprs, type)
|
34
|
-
Arel::Nodes::NamedFunction.new(
|
35
|
-
"CAST",
|
36
|
-
[Arel::Nodes::As.new(Arel::Nodes::Grouping.new(exprs), Arel.sql(type.to_s.upcase))]
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
def coalesce(*exprs)
|
41
|
-
Arel::Nodes::NamedFunction.new("COALESCE", exprs)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module ActionDelegator
|
5
|
-
class VotedWithDirectVerification < Rectify::Query
|
6
|
-
def initialize(relation)
|
7
|
-
@relation = relation
|
8
|
-
end
|
9
|
-
|
10
|
-
def query
|
11
|
-
relation
|
12
|
-
.joins(:votes)
|
13
|
-
.joins(join_on_votes_author(decrypted_authorizations))
|
14
|
-
.where(direct_verification.or(no_authorization))
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :relation
|
20
|
-
|
21
|
-
def join_on_votes_author(arel_table)
|
22
|
-
join_on = votes.create_on(arel_table[:decidim_user_id].eq(votes[:decidim_author_id]))
|
23
|
-
arel_table.create_join(arel_table, join_on, Arel::Nodes::OuterJoin)
|
24
|
-
end
|
25
|
-
|
26
|
-
def votes
|
27
|
-
Decidim::Consultations::Vote.arel_table
|
28
|
-
end
|
29
|
-
|
30
|
-
def decrypted_authorizations
|
31
|
-
@decrypted_authorizations ||= DecryptedAuthorizations.new(subquery).query.as("decrypted_authorizations")
|
32
|
-
end
|
33
|
-
|
34
|
-
def subquery
|
35
|
-
relation
|
36
|
-
.joins(:votes)
|
37
|
-
.joins(join_on_votes_author(authorizations))
|
38
|
-
end
|
39
|
-
|
40
|
-
def authorizations
|
41
|
-
Decidim::Authorization.arel_table
|
42
|
-
end
|
43
|
-
|
44
|
-
def direct_verification
|
45
|
-
decrypted_authorizations[:name].eq("direct_verifications")
|
46
|
-
end
|
47
|
-
|
48
|
-
def no_authorization
|
49
|
-
decrypted_authorizations[:id].eq(nil)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
<div class="reveal" data-reveal id="delegations-modal">
|
2
|
-
<div class="reveal__header">
|
3
|
-
<h3 class="reveal__title">
|
4
|
-
<%= t "action_delegator.delegations_modal.title", scope: "decidim" %>
|
5
|
-
</h3>
|
6
|
-
<button class="close-button" data-close aria-label="Close modal" type="button">
|
7
|
-
<span aria-hidden="true">×</span>
|
8
|
-
</button>
|
9
|
-
</div>
|
10
|
-
|
11
|
-
<p><%= t "action_delegator.delegations_modal.contextual_help", scope: "decidim" %></p>
|
12
|
-
<div class="card card--secondary">
|
13
|
-
<div class="card__content">
|
14
|
-
|
15
|
-
<% signed_in? && Decidim::ActionDelegator::GranteeDelegations.for(question.consultation, current_user).each do |delegation| %>
|
16
|
-
<div class="row">
|
17
|
-
<div class="columns medium-5 medium-offset-1">
|
18
|
-
<%= delegation.granter.name %>
|
19
|
-
</div>
|
20
|
-
<div class="columns medium-5 medium-offset-1">
|
21
|
-
|
22
|
-
<%# Copied from decidim-consultation's _vote_button.html.erb %>
|
23
|
-
<% if question.consultation.upcoming? %>
|
24
|
-
<div class="button expanded disabled">
|
25
|
-
<div class="vote-button-caption"><%= t("questions.vote_button.vote", scope: "decidim") %></div>
|
26
|
-
<div>
|
27
|
-
<%= t "questions.vote_button.starting_from",
|
28
|
-
scope: "decidim",
|
29
|
-
date: l(question.start_voting_date) %>
|
30
|
-
</div>
|
31
|
-
</div>
|
32
|
-
<% elsif question.consultation.finished? && signed_in? && question.voted_by?(delegation.granter) %>
|
33
|
-
<%= button_to decidim_consultations.question_question_votes_path(question),
|
34
|
-
method: :delete,
|
35
|
-
remote: true,
|
36
|
-
data: { disable: true },
|
37
|
-
class: "button expanded success disabled delegation_unvote_button" do %>
|
38
|
-
<div class="vote-button-caption">
|
39
|
-
<%= t("questions.vote_button.already_voted", scope: "decidim") %>
|
40
|
-
</div>
|
41
|
-
<% end %>
|
42
|
-
<% elsif signed_in? && question.consultation.active? %>
|
43
|
-
<% if allowed_to? :unvote_delegation, :question, { question: question, delegation: delegation }, [Decidim::ActionDelegator::Permissions, Decidim::Admin::Permissions, Decidim::Permissions] %>
|
44
|
-
<%= button_to decidim_consultations.question_question_votes_path(question),
|
45
|
-
method: :delete,
|
46
|
-
remote: true,
|
47
|
-
data: { disable: true },
|
48
|
-
class: "button expanded success delegation_unvote_button" do %>
|
49
|
-
<%= hidden_field_tag "decidim_consultations_delegation_id", delegation.id, id: "decidim_consultations_delegation_id_delete_#{delegation.id}" %>
|
50
|
-
<div class="vote-button-caption"
|
51
|
-
data-original="<%= t("questions.vote_button.already_voted", scope: "decidim") %>"
|
52
|
-
data-replace="<%= t("questions.vote_button.already_voted_hover", scope: "decidim") %>">
|
53
|
-
<%= t("questions.vote_button.already_voted", scope: "decidim") %>
|
54
|
-
</div>
|
55
|
-
<% end %>
|
56
|
-
<% elsif allowed_to? :vote_delegation, :question, { question: question, delegation: delegation }, [Decidim::ActionDelegator::Permissions, Decidim::Admin::Permissions, Decidim::Permissions] %>
|
57
|
-
<% if question.multiple? %>
|
58
|
-
<%= link_to decidim_consultations.question_question_multiple_votes_path(question, delegation: delegation.id),
|
59
|
-
class: "button expanded",
|
60
|
-
id: "multivote_button" do %>
|
61
|
-
<div class="vote-button-caption"><%= t "questions.vote_button.vote", scope: "decidim" %></div>
|
62
|
-
<% end %>
|
63
|
-
<% else %>
|
64
|
-
|
65
|
-
<%# This link is slightly modified from _vote_button to add stuff needed by delegations %>
|
66
|
-
<%= link_to "#", class: "button expanded delegation-vote-button", data: { "delegation-id" => delegation.id, "delegation-granter-name" => delegation.granter.name } do %>
|
67
|
-
<div class="vote-button-caption"><%= t "questions.vote_button.vote", scope: "decidim" %></div>
|
68
|
-
<% end %>
|
69
|
-
|
70
|
-
<% end %>
|
71
|
-
<% else %>
|
72
|
-
<%= authorized_vote_modal_button(question, remote: true, class: "button expanded light button--sc") do %>
|
73
|
-
<%= t("questions.vote_button.verification_required", scope: "decidim") %>
|
74
|
-
<% end %>
|
75
|
-
<% end %>
|
76
|
-
<% elsif question.consultation.active? %>
|
77
|
-
<%= logged_button_to decidim_consultations.question_question_votes_path(question),
|
78
|
-
class: "button expanded",
|
79
|
-
data: { disable: true },
|
80
|
-
id: "vote_button" do %>
|
81
|
-
<div class="vote-button-caption">
|
82
|
-
<%= t("questions.vote_button.vote", scope: "decidim") %>
|
83
|
-
</div>
|
84
|
-
<% end %>
|
85
|
-
<% end %>
|
86
|
-
|
87
|
-
</div>
|
88
|
-
</div>
|
89
|
-
<% end %>
|
90
|
-
|
91
|
-
</div>
|
92
|
-
</div>
|
93
|
-
</div>
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<% if signed_in? && Decidim::ActionDelegator::Delegation.granted_to?(current_user, question.consultation) %>
|
2
|
-
<div class="delegations-notice flex--cc">
|
3
|
-
<%= link_to t("action_delegator.delegations.link", scope: "decidim"), decidim_consultations.question_path(question) %>
|
4
|
-
</div>
|
5
|
-
<% end %>
|
@@ -1,41 +0,0 @@
|
|
1
|
-
<div class="card consultations-card">
|
2
|
-
<div class="row collapse card--process__row">
|
3
|
-
<div class="columns mediumlarge-8 large-9 card--process__column">
|
4
|
-
<div class="card__content">
|
5
|
-
<%= link_to decidim_consultations.question_path(question), class: "card__link" do %>
|
6
|
-
<h2 class="heading5"><%= decidim_sanitize translated_attribute question.title %></h2>
|
7
|
-
<% end %>
|
8
|
-
<p><%= translated_attribute question.subtitle %></p>
|
9
|
-
</div>
|
10
|
-
</div>
|
11
|
-
|
12
|
-
<div class="columns mediumlarge-8 large-3 card--process__column">
|
13
|
-
<div class="card--full__image consultations-card__image"
|
14
|
-
style="background-image: url(<%= question.banner_image_url %>)">
|
15
|
-
<div class="card__content row collapse">
|
16
|
-
<div class="columns large-10 large-push-1">
|
17
|
-
<% if question.results_published? %>
|
18
|
-
<%= link_to decidim_consultations.question_path(question),
|
19
|
-
class: "button expanded button--sc" do %>
|
20
|
-
<%= t "consultations.question.view_results", scope: "decidim" %>
|
21
|
-
<% if question.most_voted_response.present? %>
|
22
|
-
<span class="button__info"><%= translated_attribute question.most_voted_response.title %></span>
|
23
|
-
<span class="button__info">
|
24
|
-
<%= question.most_voted_response.votes_count %>
|
25
|
-
<%= t "consultations.question.votes_out_of", scope: "decidim", count: question.most_voted_response.votes_count %>
|
26
|
-
<%= question.total_votes %>
|
27
|
-
</span>
|
28
|
-
<% end %>
|
29
|
-
<% end %>
|
30
|
-
<% else %>
|
31
|
-
<%= display_take_part_button_for(question) %>
|
32
|
-
|
33
|
-
<%= render partial: "decidim/action_delegator/link_to_question", locals: { question: question } %>
|
34
|
-
|
35
|
-
<% end %>
|
36
|
-
</div>
|
37
|
-
</div>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
</div>
|
41
|
-
</div>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
edit_link(
|
3
|
-
resource_locator(current_consultation).edit,
|
4
|
-
:update,
|
5
|
-
:consultation,
|
6
|
-
consultation: current_consultation
|
7
|
-
)
|
8
|
-
%>
|
9
|
-
|
10
|
-
<%= stylesheet_pack_tag "decidim_action_delegator_questions" %>
|
11
|
-
|
12
|
-
<%= render partial: "consultation_details", locals: { consultation: current_consultation } %>
|
13
|
-
<%= render partial: "highlighted_questions", locals: { consultation: current_consultation } %>
|
14
|
-
<%= render partial: "regular_questions", locals: { consultation: current_consultation } %>
|
@@ -1,25 +0,0 @@
|
|
1
|
-
<div class="card">
|
2
|
-
<% if group %>
|
3
|
-
<div class="card__top">
|
4
|
-
<div class="card__content">
|
5
|
-
<h5 class="card__title"><%= translated_attribute group.title %></h5>
|
6
|
-
</div>
|
7
|
-
</div>
|
8
|
-
<% end %>
|
9
|
-
|
10
|
-
<% if delegation %>
|
11
|
-
<div class="delegation-callout callout warning">
|
12
|
-
<p><%= t "action_delegator.delegations_modal.callout", scope: "decidim" %> <strong><%= delegation.granter.name %></strong></p>
|
13
|
-
</div>
|
14
|
-
<% end %>
|
15
|
-
|
16
|
-
<div class="card__content multiple_votes_form">
|
17
|
-
<% responses.each do |response| %>
|
18
|
-
<div>
|
19
|
-
<%= check_box_tag "responses[]", response.id, false, id: "vote_id_#{response.id}" %>
|
20
|
-
<%= form.label :id, translated_attribute(response.title), for: "vote_id_#{response.id}" %>
|
21
|
-
</div>
|
22
|
-
<% end %>
|
23
|
-
<%= hidden_field_tag :decidim_consultations_delegation_id, delegation.id if delegation %>
|
24
|
-
</div>
|
25
|
-
</div>
|
@@ -1,106 +0,0 @@
|
|
1
|
-
<%= stylesheet_pack_tag "decidim_action_delegator_questions" %>
|
2
|
-
<%= javascript_pack_tag "decidim_action_delegator_questions_js" %>
|
3
|
-
|
4
|
-
<div class="row column">
|
5
|
-
<div class="callout hide" id="vote-result-callout" data-closable data-title-ok="<%= t("question_votes.create.title_success", scope: "decidim.consultations") %>" data-message-ok="<%= t("question_votes.create.success", scope: "decidim.consultations") %>" data-title-ko="<%= t("question_votes.create.title_error", scope: "decidim.consultations") %>" data-message-ko="<%= t("question_votes.create.error", scope: "decidim.consultations") %>">
|
6
|
-
<h5 class="callout-title"></h5>
|
7
|
-
<p class="callout-message"></p>
|
8
|
-
<button class="close-button" aria-label="Dismiss alert" type="button" data-close>
|
9
|
-
<span aria-hidden="true">×</span>
|
10
|
-
</button>
|
11
|
-
</div>
|
12
|
-
</div>
|
13
|
-
|
14
|
-
<%# Check if controller has questions_helper %>
|
15
|
-
<% if defined? display_next_previous_button %>
|
16
|
-
<div class="row column question-vote-cabin">
|
17
|
-
<div class="columns mediumlarge-4 show-for-mediumlarge previous-question">
|
18
|
-
<%= display_next_previous_button(:previous, "float-left") %>
|
19
|
-
</div>
|
20
|
-
<div class="columns mediumlarge-4">
|
21
|
-
<% if question.consultation.upcoming? %>
|
22
|
-
<div class="card__button button expanded disabled">
|
23
|
-
<div class="vote-button-caption"><%= t("questions.vote_button.vote", scope: "decidim") %></div>
|
24
|
-
<div>
|
25
|
-
<%= t "questions.vote_button.starting_from",
|
26
|
-
scope: "decidim",
|
27
|
-
date: l(question.start_voting_date) %>
|
28
|
-
</div>
|
29
|
-
</div>
|
30
|
-
<% elsif question.consultation.finished? && signed_in? && question.voted_by?(current_user) %>
|
31
|
-
<%= button_to decidim_consultations.question_question_votes_path(question),
|
32
|
-
method: :delete,
|
33
|
-
remote: true,
|
34
|
-
data: { disable: true },
|
35
|
-
class: "card__button button expanded success disabled",
|
36
|
-
id: "unvote_button" do %>
|
37
|
-
<div class="vote-button-caption">
|
38
|
-
<%= t("questions.vote_button.already_voted", scope: "decidim") %>
|
39
|
-
</div>
|
40
|
-
<% end %>
|
41
|
-
<% elsif signed_in? && question.consultation.active? %>
|
42
|
-
<% if allowed_to? :unvote, :question, question: question %>
|
43
|
-
<%= button_to decidim_consultations.question_question_votes_path(question),
|
44
|
-
method: :delete,
|
45
|
-
remote: true,
|
46
|
-
data: { disable: true },
|
47
|
-
class: "card__button button expanded success",
|
48
|
-
id: "unvote_button" do %>
|
49
|
-
<div class="vote-button-caption"
|
50
|
-
data-original="<%= t("questions.vote_button.already_voted", scope: "decidim") %>"
|
51
|
-
data-replace="<%= t("questions.vote_button.already_voted_hover", scope: "decidim") %>">
|
52
|
-
<%= t("questions.vote_button.already_voted", scope: "decidim") %>
|
53
|
-
</div>
|
54
|
-
<% end %>
|
55
|
-
<% elsif allowed_to? :vote, :question, question: question %>
|
56
|
-
<% if question.multiple? %>
|
57
|
-
<%= link_to decidim_consultations.question_question_multiple_votes_path(question, delegation: 0),
|
58
|
-
class: "card__button button expanded",
|
59
|
-
id: "multivote_button" do %>
|
60
|
-
<div class="vote-button-caption"><%= t "questions.vote_button.vote", scope: "decidim" %></div>
|
61
|
-
<% end %>
|
62
|
-
<% else %>
|
63
|
-
<%= link_to "#", class: "card__button button expanded", id: "vote_button" do %>
|
64
|
-
<div class="vote-button-caption"><%= t "questions.vote_button.vote", scope: "decidim" %></div>
|
65
|
-
<% end %>
|
66
|
-
<% end %>
|
67
|
-
<% else %>
|
68
|
-
<%= authorized_vote_modal_button(question, remote: true, class: "button expanded light button--sc") do %>
|
69
|
-
<%= t("questions.vote_button.verification_required", scope: "decidim") %>
|
70
|
-
<% end %>
|
71
|
-
<% end %>
|
72
|
-
|
73
|
-
<%= render partial: "decidim/action_delegator/link_to_delegations", locals: { consultation: question.consultation } %>
|
74
|
-
|
75
|
-
<% elsif question.consultation.active? %>
|
76
|
-
<%= logged_button_to decidim_consultations.question_question_votes_path(question),
|
77
|
-
class: "card__button button expanded",
|
78
|
-
data: { disable: true },
|
79
|
-
id: "vote_button" do %>
|
80
|
-
<div class="vote-button-caption">
|
81
|
-
<%= t("questions.vote_button.vote", scope: "decidim") %>
|
82
|
-
</div>
|
83
|
-
<% end %>
|
84
|
-
<% end %>
|
85
|
-
</div>
|
86
|
-
<div class="columns mediumlarge-4 show-for-mediumlarge next-question">
|
87
|
-
<%= display_next_previous_button(:next, "float-right") %>
|
88
|
-
</div>
|
89
|
-
</div>
|
90
|
-
|
91
|
-
<div class="row column section hide-for-mediumlarge">
|
92
|
-
<div class="small-buttons">
|
93
|
-
<div class="columns small-6 previous-question">
|
94
|
-
<%= display_next_previous_button(:previous, "expanded") %>
|
95
|
-
</div>
|
96
|
-
<div class="columns small-6 next-question">
|
97
|
-
<%= display_next_previous_button(:next, "expanded") %>
|
98
|
-
</div>
|
99
|
-
</div>
|
100
|
-
</div>
|
101
|
-
<% end %>
|
102
|
-
|
103
|
-
<%= render partial: "decidim/consultations/questions/vote_modal", locals: { question: question } %>
|
104
|
-
<%= render partial: "decidim/consultations/questions/vote_modal_confirm", locals: { question: question } %>
|
105
|
-
<%= render partial: "decidim/action_delegator/delegations_modal", locals: { question: question } %>
|
106
|
-
<%= javascript_pack_tag "decidim_consultations" %>
|