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
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ActionDelegator
|
5
|
+
class DelegationsCsvImporter < CsvImporter
|
6
|
+
def process(row, params, details_csv, import_summary, iterator)
|
7
|
+
if delegation_exists?(params)
|
8
|
+
message = generate_info_message(row)
|
9
|
+
|
10
|
+
handle_skipped_row(row, details_csv, import_summary, iterator, message)
|
11
|
+
|
12
|
+
false
|
13
|
+
else
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def extract_params(row)
|
21
|
+
params = {
|
22
|
+
granter_email: row["from"].to_s.strip.downcase,
|
23
|
+
grantee_email: row["to"].to_s.strip.downcase
|
24
|
+
}
|
25
|
+
|
26
|
+
@form = form(Decidim::ActionDelegator::Admin::DelegationForm).from_params(params, setting: @current_setting)
|
27
|
+
|
28
|
+
{
|
29
|
+
granter_id: @form.granter&.id,
|
30
|
+
grantee_id: @form.grantee&.id
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def delegation_exists?(params)
|
35
|
+
@delegation = Delegation.find_by(granter_id: params[:granter_id], grantee_id: params[:grantee_id])
|
36
|
+
|
37
|
+
@delegation.present?
|
38
|
+
end
|
39
|
+
|
40
|
+
def process_delegation(form)
|
41
|
+
Decidim::ActionDelegator::Admin::CreateDelegation.call(form, @current_user, @current_setting)
|
42
|
+
end
|
43
|
+
|
44
|
+
def handle_form_validity(row, details_csv, import_summary, row_number)
|
45
|
+
if @form.valid?
|
46
|
+
process_delegation(@form)
|
47
|
+
import_summary[:imported_rows] += 1
|
48
|
+
else
|
49
|
+
handle_import_error(row, details_csv, import_summary, row_number, @form.errors.full_messages.join(", "))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ActionDelegator
|
5
|
+
class ParticipantsCsvImporter < CsvImporter
|
6
|
+
def process(row, params, details_csv, import_summary, iterator)
|
7
|
+
weight = ponderation_value(row["weight"].strip) if row["weight"].present?
|
8
|
+
|
9
|
+
@form = form(Decidim::ActionDelegator::Admin::ParticipantForm).from_params(params, setting: @current_setting)
|
10
|
+
|
11
|
+
if participant_exists?(@form)
|
12
|
+
mismatch_fields = mismatched_fields(@form)
|
13
|
+
message = generate_info_message(mismatch_fields)
|
14
|
+
handle_skipped_row(row, details_csv, import_summary, iterator, message)
|
15
|
+
return false
|
16
|
+
end
|
17
|
+
if phone_exists?(@form)
|
18
|
+
reason = I18n.t("phone_exists", scope: "decidim.action_delegator.participants_csv_importer.import")
|
19
|
+
handle_skipped_row(row, details_csv, import_summary, iterator, reason)
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
if weight.present? && find_ponderation(weight).nil?
|
23
|
+
reason = I18n.t("ponderation_not_found", scope: "decidim.action_delegator.participants_csv_importer.import")
|
24
|
+
handle_skipped_row(row, details_csv, import_summary, iterator, reason)
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def authorization_method
|
34
|
+
@current_setting.authorization_method
|
35
|
+
end
|
36
|
+
|
37
|
+
def extract_params(row)
|
38
|
+
email, phone, weight = extract_contact_details(row, authorization_method)
|
39
|
+
weight = ponderation_value(row["weight"].strip) if row["weight"].present?
|
40
|
+
|
41
|
+
params = {
|
42
|
+
email: email,
|
43
|
+
phone: phone,
|
44
|
+
weight: weight,
|
45
|
+
decidim_action_delegator_ponderation_id: find_ponderation(weight)&.id
|
46
|
+
}
|
47
|
+
|
48
|
+
@form = form(Decidim::ActionDelegator::Admin::ParticipantForm).from_params(params, setting: @current_setting)
|
49
|
+
|
50
|
+
params
|
51
|
+
end
|
52
|
+
|
53
|
+
def extract_contact_details(row, authorization_method)
|
54
|
+
email = row["email"].to_s.strip.downcase
|
55
|
+
phone = row["phone"].to_s.strip
|
56
|
+
|
57
|
+
email = nil if %w(email both).include?(authorization_method.to_s) && invalid_email?(email)
|
58
|
+
|
59
|
+
phone = nil if %w(phone both).include?(authorization_method.to_s) && invalid_phone?(phone)
|
60
|
+
|
61
|
+
[email, phone]
|
62
|
+
end
|
63
|
+
|
64
|
+
def invalid_phone?(phone)
|
65
|
+
phone.blank? || !phone.gsub(/[^+0-9]/, "").match?(Decidim::ActionDelegator.phone_regex)
|
66
|
+
end
|
67
|
+
|
68
|
+
def process_participant(form)
|
69
|
+
if find_ponderation(form.weight).present?
|
70
|
+
ponderation = find_ponderation(form.weight)
|
71
|
+
form.decidim_action_delegator_ponderation_id = ponderation.id
|
72
|
+
end
|
73
|
+
|
74
|
+
create_new_participant(form)
|
75
|
+
end
|
76
|
+
|
77
|
+
def participant_exists?(form)
|
78
|
+
check_exists?(:email, form)
|
79
|
+
end
|
80
|
+
|
81
|
+
def phone_exists?(form)
|
82
|
+
check_exists?(:phone, form)
|
83
|
+
end
|
84
|
+
|
85
|
+
def check_exists?(field, form)
|
86
|
+
@participant = Decidim::ActionDelegator::Participant.find_by(field => form.send(field), setting: @current_setting) if form.send(field).present?
|
87
|
+
@participant.present?
|
88
|
+
end
|
89
|
+
|
90
|
+
def handle_form_validity(row, details_csv, import_summary, row_number)
|
91
|
+
if @form.valid?
|
92
|
+
process_participant(@form)
|
93
|
+
import_summary[:imported_rows] += 1
|
94
|
+
else
|
95
|
+
handle_import_error(row, details_csv, import_summary, row_number, @form.errors.full_messages.join(", "))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def mismatched_fields(form)
|
100
|
+
mismatch_fields = []
|
101
|
+
mismatch_fields << I18n.t("decidim.action_delegator.participants_csv_importer.import.field_name.phone") if form.phone != @participant.phone
|
102
|
+
|
103
|
+
if form.decidim_action_delegator_ponderation_id != @participant.decidim_action_delegator_ponderation_id
|
104
|
+
mismatch_fields << I18n.t("decidim.action_delegator.participants_csv_importer.import.field_name.weight")
|
105
|
+
end
|
106
|
+
|
107
|
+
mismatch_fields.empty? ? nil : mismatch_fields.join(", ")
|
108
|
+
end
|
109
|
+
|
110
|
+
def create_new_participant(form)
|
111
|
+
Decidim::ActionDelegator::Admin::CreateParticipant.call(form)
|
112
|
+
end
|
113
|
+
|
114
|
+
def find_ponderation(weight)
|
115
|
+
case weight
|
116
|
+
when String
|
117
|
+
@current_setting.ponderations.find_by(name: weight).presence
|
118
|
+
when Numeric
|
119
|
+
ponderation = @current_setting.ponderations.find_by(weight: weight)
|
120
|
+
ponderation.presence || @current_setting.ponderations.create(name: "weight-#{weight}", weight: weight)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def ponderation_value(value)
|
125
|
+
Float(value)
|
126
|
+
rescue StandardError
|
127
|
+
value
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<span class="label button--title">
|
6
6
|
<%= t "decidim.admin.consultations.results.total_votes", count: current_consultation.total_votes %>
|
7
7
|
/
|
8
|
-
<%= t "decidim.admin.consultations.results.total_delegates", count:
|
8
|
+
<%= t "decidim.admin.consultations.results.total_delegates", count: total_delegates %>
|
9
9
|
/
|
10
10
|
<%= t "decidim.admin.consultations.results.participants", count: current_consultation.total_participants %>
|
11
11
|
</span>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
</div>
|
21
21
|
<div class="card-section">
|
22
22
|
<table class="table-list">
|
23
|
-
<%
|
23
|
+
<% questions.each do |question| %>
|
24
24
|
<% unless question.external_voting %>
|
25
25
|
<thead>
|
26
26
|
<tr>
|
@@ -38,7 +38,7 @@
|
|
38
38
|
</thead>
|
39
39
|
<tbody>
|
40
40
|
<% if question.publishable_results? %>
|
41
|
-
<%
|
41
|
+
<% responses_by_membership.fetch(question.id, []).each do |row| %>
|
42
42
|
<tr>
|
43
43
|
<td class="response-title"><%= strip_tags translated_attribute row.title %></td>
|
44
44
|
<td class="membership-type"><%= row.membership_type %></td>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<span class="label button--title">
|
6
6
|
<%= t "decidim.admin.consultations.results.total_votes", count: current_consultation.total_votes %>
|
7
7
|
/
|
8
|
-
<%= t "decidim.admin.consultations.results.total_delegates", count:
|
8
|
+
<%= t "decidim.admin.consultations.results.total_delegates", count: total_delegates %>
|
9
9
|
/
|
10
10
|
<%= t "decidim.admin.consultations.results.participants", count: current_consultation.total_participants %>
|
11
11
|
</span>
|
@@ -25,7 +25,7 @@
|
|
25
25
|
</div>
|
26
26
|
<div class="card-section">
|
27
27
|
<table id="results" class="table-list">
|
28
|
-
<%
|
28
|
+
<% questions.each do |question| %>
|
29
29
|
<% unless question.external_voting %>
|
30
30
|
<thead>
|
31
31
|
<tr>
|
@@ -41,7 +41,7 @@
|
|
41
41
|
</thead>
|
42
42
|
<tbody>
|
43
43
|
<% if question.publishable_results? %>
|
44
|
-
<%
|
44
|
+
<% responses_by_weight.fetch(question.id, []).each do |row| %>
|
45
45
|
<tr>
|
46
46
|
<td class="response-title"><%= strip_tags translated_attribute row.title %></td>
|
47
47
|
<td class="votes-count"><%= row.votes_count %></td>
|
@@ -1,36 +1,41 @@
|
|
1
1
|
<div class="card with-overflow" id='user-groups'>
|
2
2
|
<div class="card-divider">
|
3
3
|
<h2 class="card-title">
|
4
|
+
<%= link_to translated_attribute(current_setting.title), decidim_admin_action_delegator.settings_path %> >
|
4
5
|
<%= t ".title" %>
|
5
6
|
<%= link_to t(".actions.new_delegation"), decidim_admin_action_delegator.new_setting_delegation_path(current_setting), class: "button tiny button--title" %>
|
7
|
+
<%= link_to t(".actions.csv_import"), decidim_admin_action_delegator.new_setting_manage_delegation_path(current_setting), class: "button tiny button--title import" %>
|
6
8
|
</h2>
|
7
9
|
</div>
|
8
10
|
<div class="card-section">
|
11
|
+
<p class="help-text"><%= t ".description_html" %></p>
|
9
12
|
<div class="table-scroll">
|
10
13
|
<table class="table-list">
|
11
14
|
<thead>
|
12
15
|
<tr>
|
13
16
|
<th><%= t(".granter") %></th>
|
14
17
|
<th><%= t(".grantee") %></th>
|
18
|
+
<th><%= t(".grantee_voted") %></th>
|
15
19
|
<th><%= t(".created_at") %></th>
|
16
20
|
<th> </th>
|
17
21
|
</tr>
|
18
22
|
</thead>
|
19
23
|
<tbody>
|
20
|
-
<%
|
24
|
+
<% delegations.each do |delegation| %>
|
21
25
|
<tr data-delegation-id="<%= delegation.id %>">
|
22
26
|
<td><%= delegation.granter.name %></td>
|
23
27
|
<td><%= delegation.grantee.name %></td>
|
28
|
+
<td><%= t("booleans.#{delegation.grantee_voted?}") %></td>
|
24
29
|
<td><%= l delegation.created_at, format: :short %></td>
|
25
30
|
|
26
31
|
<td class="table-list__actions">
|
27
|
-
<%= icon_link_to "circle-x", decidim_admin_action_delegator.setting_delegation_path(delegation.setting, delegation), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } %>
|
32
|
+
<%= icon_link_to "circle-x", decidim_admin_action_delegator.setting_delegation_path(delegation.setting, delegation), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } unless delegation.grantee_voted? %>
|
28
33
|
</td>
|
29
34
|
</tr>
|
30
35
|
<% end %>
|
31
36
|
</tbody>
|
32
37
|
</table>
|
33
38
|
</div>
|
34
|
-
<%= decidim_paginate
|
39
|
+
<%= decidim_paginate delegations %>
|
35
40
|
</div>
|
36
41
|
</div>
|
@@ -1,14 +1,15 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
</h2>
|
4
|
-
|
5
|
-
<%= decidim_form_for @form, url: { action: "create" }, html: { class: "form new_delegation" } do |f| %>
|
6
|
-
<div class="card">
|
1
|
+
<div class="card">
|
2
|
+
<div class="card-section">
|
7
3
|
<div class="card-divider">
|
8
|
-
<h2 class="card-title"
|
4
|
+
<h2 class="card-title">
|
5
|
+
<%= link_to translated_attribute(current_setting.title), decidim_admin_action_delegator.settings_path %> >
|
6
|
+
<%= link_to t("title", scope: "decidim.action_delegator.admin.delegations.index"), decidim_admin_action_delegator.setting_delegations_path(current_setting) %> >
|
7
|
+
<%= t ".title" %>
|
8
|
+
</h2>
|
9
9
|
</div>
|
10
10
|
|
11
11
|
<div class="card-section">
|
12
|
+
<%= decidim_form_for @form, url: { action: "create" }, html: { class: "form new_delegation" } do |f| %>
|
12
13
|
<% prompt_options = { url: decidim_admin.users_organization_url, placeholder: t(".select_member") } %>
|
13
14
|
|
14
15
|
<div class="row column">
|
@@ -21,10 +22,12 @@
|
|
21
22
|
{ value: user.id, label: "#{user.name} (@#{user.nickname})" }
|
22
23
|
end %>
|
23
24
|
</div>
|
24
|
-
</div>
|
25
|
-
</div>
|
26
25
|
|
27
|
-
|
28
|
-
|
26
|
+
<div class="button--double form-general-submit">
|
27
|
+
<%= f.submit t(".save") %>
|
28
|
+
</div>
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
</div>
|
29
32
|
</div>
|
30
|
-
|
33
|
+
</div>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%= form_tag(setting_manage_delegations_path, multipart: true, class: "form new_import") do %>
|
2
|
+
<%= hidden_field_tag :setting_id, current_setting.id %>
|
3
|
+
<div class="card">
|
4
|
+
<div class="card-divider">
|
5
|
+
<h2 class="card-title">
|
6
|
+
<%= t(".title") %>
|
7
|
+
</h2>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<p><%= t(".upload_instructions") %></p>
|
11
|
+
<p><%= t(".required_fields") %></p>
|
12
|
+
<p><%= t(".title_example") %></p>
|
13
|
+
<pre class="code-block">
|
14
|
+
from,to
|
15
|
+
user_1@example.org,user_2@example.org
|
16
|
+
user_3@example.org,user_4@example.org
|
17
|
+
...</pre>
|
18
|
+
<div class="row column">
|
19
|
+
<%= file_field_tag :csv_file %>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<div class="button--double form-general-submit">
|
23
|
+
<%= submit_tag t(".import"), class: "button" %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= form_tag(setting_manage_participants_path, multipart: true, class: "form new_import") do %>
|
2
|
+
<%= hidden_field_tag :setting_id, current_setting.id %>
|
3
|
+
<div class="card">
|
4
|
+
<div class="card-divider">
|
5
|
+
<h2 class="card-title">
|
6
|
+
<%= t(".title") %>
|
7
|
+
</h2>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<p><%= t(".upload_instructions") %></p>
|
11
|
+
<p><%= t(".required_fields", authorization_method: t(".authorization_method.#{current_setting.authorization_method}")) %></p>
|
12
|
+
<p><%= t(".title_example") %></p>
|
13
|
+
<pre class="code-block">
|
14
|
+
email,phone,weight
|
15
|
+
foo@example.org,6660000,1.5
|
16
|
+
bar@example.org,6660001,1
|
17
|
+
baz@example.org,6660002,2
|
18
|
+
...</pre>
|
19
|
+
<p><%= t(".describe") %></p>
|
20
|
+
<pre class="code-block">
|
21
|
+
email,phone,weight
|
22
|
+
foo@example.org,6660000,producer
|
23
|
+
bar@example.org,6660001,consumer
|
24
|
+
baz@example.org,6660002,associate
|
25
|
+
...</pre>
|
26
|
+
<div class="row column">
|
27
|
+
<%= file_field_tag :csv_file %>
|
28
|
+
</div>
|
29
|
+
|
30
|
+
<div class="button--double form-general-submit">
|
31
|
+
<%= submit_tag t(".import"), class: "button" %>
|
32
|
+
</div>
|
33
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<div class="row column">
|
2
|
+
<%= form.email_field :email %>
|
3
|
+
</div>
|
4
|
+
<div class="row column">
|
5
|
+
<%= form.text_field :phone %>
|
6
|
+
</div>
|
7
|
+
<div class="row column">
|
8
|
+
<%= form.select :decidim_action_delegator_ponderation_id, ponderations_for_select(current_setting), include_blank: true %>
|
9
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% missing_registered = missing_registered_users(current_setting&.participants) %>
|
2
|
+
<% i18n_scope = "decidim.action_delegator.admin.participants.index" %>
|
3
|
+
<% if missing_registered.present? %>
|
4
|
+
<div class="callout warning text-left">
|
5
|
+
<ul class="happy-faces">
|
6
|
+
<li>
|
7
|
+
<%= t("#{i18n_scope}.missing_registered", missing_registered: pluralize(missing_registered.count, t("#{i18n_scope}.participant"))) %>
|
8
|
+
<br>
|
9
|
+
<%= link_to t("send_invitation_link", scope: i18n_scope), invite_all_users_setting_invite_participants_path(current_setting), class: "action-icon--edit", method: :post %>
|
10
|
+
</li>
|
11
|
+
</ul>
|
12
|
+
</div>
|
13
|
+
<% elsif current_setting&.participants.any? %>
|
14
|
+
<div class="callout warning text-left">
|
15
|
+
<p class="happy"><%= t("all_users_registered_html", scope: i18n_scope) %></p>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="card">
|
2
|
+
<div class="card-section">
|
3
|
+
<div class="card-divider">
|
4
|
+
<h2 class="card-title">
|
5
|
+
<%= link_to translated_attribute(current_setting.title), decidim_admin_action_delegator.settings_path %> >
|
6
|
+
<%= link_to t("title", scope: "decidim.action_delegator.admin.participants.index"), decidim_admin_action_delegator.setting_participants_path(current_setting) %> >
|
7
|
+
<%= t ".title" %>
|
8
|
+
</h2>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="card-section">
|
12
|
+
<%= decidim_form_for @form, url: { action: "update" }, html: { class: "form edit_ponderation" } do |f| %>
|
13
|
+
<%= render partial: "form", object: f %>
|
14
|
+
|
15
|
+
<div class="button--double form-general-submit">
|
16
|
+
<%= f.submit t(".save") %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<div class="card with-overflow" id='user-groups'>
|
2
|
+
<div class="card-divider">
|
3
|
+
<h2 class="card-title flex--sbc">
|
4
|
+
<div>
|
5
|
+
<%= link_to translated_attribute(current_setting.title), decidim_admin_action_delegator.settings_path %> >
|
6
|
+
<%= t ".title" %>
|
7
|
+
</div>
|
8
|
+
<div>
|
9
|
+
<%= link_to t(".actions.new_participant"), decidim_admin_action_delegator.new_setting_participant_path(current_setting), class: "button tiny button--title" %>
|
10
|
+
<%= link_to t(".actions.csv_import"),
|
11
|
+
decidim_admin_action_delegator.new_setting_manage_participant_path(setting_id: current_setting.id),
|
12
|
+
class: "button tiny button--title" %>
|
13
|
+
<%= link_to t(".actions.remove_census"), decidim_admin_action_delegator.destroy_all_setting_manage_participants_path(current_setting),
|
14
|
+
method: :delete,
|
15
|
+
data: { confirm: t("participants.remove_census.confirm", scope: "decidim.action_delegator.admin") },
|
16
|
+
class: "button tiny alert button--title" %>
|
17
|
+
</div>
|
18
|
+
</h2>
|
19
|
+
</div>
|
20
|
+
<div class="card-section">
|
21
|
+
<%= render "decidim/action_delegator/admin/settings/participants_email_check", setting: current_setting if (current_setting.authorization_method == "phone") %>
|
22
|
+
<%= render "decidim/action_delegator/admin/settings/participants_sync_check", setting: current_setting %>
|
23
|
+
<% if Decidim::ActionDelegator.allow_to_invite_users %>
|
24
|
+
<%= render "decidim/action_delegator/admin/participants/missing_registered_check", setting: current_setting unless (current_setting.authorization_method == "phone") %>
|
25
|
+
<% end %>
|
26
|
+
<div class="table-scroll">
|
27
|
+
<table class="table-list">
|
28
|
+
<thead>
|
29
|
+
<tr>
|
30
|
+
<th><%= t(".email") %></th>
|
31
|
+
<th><%= t(".phone") %></th>
|
32
|
+
<th><%= t(".ponderation") %></th>
|
33
|
+
<th><%= t(".user") %></th>
|
34
|
+
<th><%= t(".last_login") %></th>
|
35
|
+
<th><%= t(".voted") %></th>
|
36
|
+
<th><%= t(".created_at") %></th>
|
37
|
+
<th> </th>
|
38
|
+
</tr>
|
39
|
+
</thead>
|
40
|
+
<tbody>
|
41
|
+
<% participants.each do |participant| %>
|
42
|
+
<tr data-participant-id="<%= participant.id %>">
|
43
|
+
<td><%= participant.email %></td>
|
44
|
+
<td><%= participant.phone %></td>
|
45
|
+
<td><%= participant.ponderation_title %></td>
|
46
|
+
<td><%= participant.user_name %></td>
|
47
|
+
<td><%= participant.last_login ? l(participant.last_login, format: :short) : t(".never_logged") %></td>
|
48
|
+
<td><%= t("booleans.#{participant.voted?}") %></td>
|
49
|
+
<td><%= l participant.created_at, format: :short %></td>
|
50
|
+
|
51
|
+
<td class="table-list__actions">
|
52
|
+
<% if Decidim::ActionDelegator.allow_to_invite_users %>
|
53
|
+
<%= icon_link_to "action-redo",
|
54
|
+
decidim_admin_action_delegator.resend_invitation_setting_invite_participant_path(participant.setting, participant),
|
55
|
+
t("actions.resend", scope: "decidim.admin"),
|
56
|
+
method: :post if participant.last_login.nil? && participant.user.present? && !(current_setting.authorization_method == "phone") %>
|
57
|
+
<%= icon_link_to "envelope-closed",
|
58
|
+
decidim_admin_action_delegator.invite_user_setting_invite_participant_path(participant.setting, participant),
|
59
|
+
t("actions.invite", scope: "decidim.admin"),
|
60
|
+
method: :post if !participant.user && participant.email.present? && !(current_setting.authorization_method == "phone") %>
|
61
|
+
<% end %>
|
62
|
+
<%= icon_link_to "pencil", decidim_admin_action_delegator.edit_setting_participant_path(participant.setting, participant), t("actions.edit", scope: "decidim.admin"), class: "action-icon--edit" %>
|
63
|
+
<%= icon_link_to "circle-x", decidim_admin_action_delegator.setting_participant_path(participant.setting, participant), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } unless participant.voted? %>
|
64
|
+
</td>
|
65
|
+
</tr>
|
66
|
+
<% end %>
|
67
|
+
</tbody>
|
68
|
+
</table>
|
69
|
+
</div>
|
70
|
+
<%= decidim_paginate participants %>
|
71
|
+
</div>
|
72
|
+
</div>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="card">
|
2
|
+
<div class="card-section">
|
3
|
+
<div class="card-divider">
|
4
|
+
<h2 class="card-title">
|
5
|
+
<%= link_to translated_attribute(current_setting.title), decidim_admin_action_delegator.settings_path %> >
|
6
|
+
<%= link_to t("title", scope: "decidim.action_delegator.admin.participants.index"), decidim_admin_action_delegator.setting_participants_path(current_setting) %> >
|
7
|
+
<%= t ".title" %>
|
8
|
+
</h2>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="card-section">
|
12
|
+
<%= decidim_form_for @form, url: { action: "create" }, html: { class: "form new_participant" } do |f| %>
|
13
|
+
<%= render partial: "form", object: f %>
|
14
|
+
|
15
|
+
<div class="button--double form-general-submit">
|
16
|
+
<%= f.submit t(".save") %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<div class="row column">
|
2
|
+
<%= form.text_field :name, placeholder: t(".name_placeholder") %>
|
3
|
+
<p class="help-text"><%== t(".name_help") %></p>
|
4
|
+
</div>
|
5
|
+
<div class="row column">
|
6
|
+
<%= form.number_field :weight, step: 0.01 %>
|
7
|
+
<p class="help-text"><%== t(".weight_help") %></p>
|
8
|
+
</div>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="card">
|
2
|
+
<div class="card-section">
|
3
|
+
<div class="card-divider">
|
4
|
+
<h2 class="card-title">
|
5
|
+
<%= link_to translated_attribute(current_setting.title), decidim_admin_action_delegator.settings_path %> >
|
6
|
+
<%= link_to t("title", scope: "decidim.action_delegator.admin.ponderations.index"), decidim_admin_action_delegator.setting_ponderations_path(current_setting) %> >
|
7
|
+
<%= t ".title" %>
|
8
|
+
</h2>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="card-section">
|
12
|
+
<%= decidim_form_for @form, url: { action: "update" }, html: { class: "form edit_ponderation" } do |f| %>
|
13
|
+
<%= render partial: "form", object: f %>
|
14
|
+
|
15
|
+
<div class="button--double form-general-submit">
|
16
|
+
<%= f.submit t(".save") %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<div class="card with-overflow" id='user-groups'>
|
2
|
+
<div class="card-divider">
|
3
|
+
<h2 class="card-title">
|
4
|
+
<%= link_to translated_attribute(current_setting.title), decidim_admin_action_delegator.settings_path %> >
|
5
|
+
<%= t ".title" %>
|
6
|
+
<%= link_to t(".actions.new_ponderation"), decidim_admin_action_delegator.new_setting_ponderation_path(current_setting), class: "button tiny button--title" %>
|
7
|
+
</h2>
|
8
|
+
</div>
|
9
|
+
<div class="card-section">
|
10
|
+
<div class="table-scroll">
|
11
|
+
<table class="table-list">
|
12
|
+
<thead>
|
13
|
+
<tr>
|
14
|
+
<th><%= t(".name") %></th>
|
15
|
+
<th><%= t(".weight") %></th>
|
16
|
+
<th><%= t(".num_users") %></th>
|
17
|
+
<th><%= t(".created_at") %></th>
|
18
|
+
<th> </th>
|
19
|
+
</tr>
|
20
|
+
</thead>
|
21
|
+
<tbody>
|
22
|
+
<% ponderations.each do |ponderation| %>
|
23
|
+
<tr data-ponderation-id="<%= ponderation.id %>">
|
24
|
+
<td><%= ponderation.name %></td>
|
25
|
+
<td><%= ponderation.weight %></td>
|
26
|
+
<td><%= ponderation.participants.count %></td>
|
27
|
+
<td><%= l ponderation.created_at, format: :short %></td>
|
28
|
+
|
29
|
+
<td class="table-list__actions">
|
30
|
+
<%= icon_link_to "pencil", decidim_admin_action_delegator.edit_setting_ponderation_path(ponderation.setting, ponderation), t("actions.edit", scope: "decidim.admin"), class: "action-icon--edit" %>
|
31
|
+
<%= icon_link_to "circle-x", decidim_admin_action_delegator.setting_ponderation_path(ponderation.setting, ponderation), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } if ponderation.destroyable? %>
|
32
|
+
</td>
|
33
|
+
</tr>
|
34
|
+
<% end %>
|
35
|
+
</tbody>
|
36
|
+
</table>
|
37
|
+
</div>
|
38
|
+
<%= decidim_paginate ponderations %>
|
39
|
+
</div>
|
40
|
+
</div>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="card">
|
2
|
+
<div class="card-section">
|
3
|
+
<div class="card-divider">
|
4
|
+
<h2 class="card-title">
|
5
|
+
<%= link_to translated_attribute(current_setting.title), decidim_admin_action_delegator.settings_path %> >
|
6
|
+
<%= link_to t("title", scope: "decidim.action_delegator.admin.ponderations.index"), decidim_admin_action_delegator.setting_ponderations_path(current_setting) %> >
|
7
|
+
<%= t ".title" %>
|
8
|
+
</h2>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="card-section">
|
12
|
+
<%= decidim_form_for @form, url: { action: "create" }, html: { class: "form new_ponderation" } do |f| %>
|
13
|
+
<%= render partial: "form", object: f %>
|
14
|
+
|
15
|
+
<div class="button--double form-general-submit">
|
16
|
+
<%= f.submit t(".save") %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class="row column">
|
2
|
+
<%= form.select :decidim_consultation_id, consultations_for_select %>
|
3
|
+
</div>
|
4
|
+
|
5
|
+
<div class="row column">
|
6
|
+
<%= form.number_field :max_grants, min: 1, autofocus: true %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="row column">
|
10
|
+
<%= form.select :authorization_method, [:both, :phone, :email].map { |op| [t(op, scope: "decidim.action_delegator.admin.settings.authorization_method"), op] } %>
|
11
|
+
<div class="help-text"><%= t("authorization_method_help", scope: "decidim.action_delegator.admin.settings").html_safe %></div>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div class="row column">
|
15
|
+
<%= form.collection_select :copy_from_setting_id, settings_select_options, :first, :last, { include_blank: true, label: t("copy_setting", scope: "decidim.action_delegator.admin.settings").html_safe } %>
|
16
|
+
</div>
|