decidim-action_delegator 0.6.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +136 -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/images/logo-pokecode.png +0 -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 +116 -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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caf66583f72b3582a54d1ab049356ba76fffb5031e4d4ca214c67c80778a4d0f
|
4
|
+
data.tar.gz: 29eed3db878b8d08aca87938cc96796894a39b9354a19a593b43afd7af5caa61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31c6a9dfcacb203062d281cac13c75e1cc972be68872026135c9334800bfb6191d02d0e10433bb50077aa4da8e168e86f23fb313d3a672280ba7309740222c16
|
7
|
+
data.tar.gz: ab3a8ff8260a1713c58fe5db966f98370fa3e5f7dbf04eda01ba7039b3b9cb590d20f5c6f81bdc9ca663a3cc1f1dd6bf2667de3a06b267713abc94a365fa91fb
|
data/README.md
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
# Decidim::ActionDelegator
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![[CI] Lint](https://github.com/coopdevs/decidim-module-action_delegator/actions/workflows/lint.yml/badge.svg)](https://github.com/coopdevs/decidim-module-action_delegator/actions/workflows/lint.yml)
|
4
|
+
[![[CI] Test](https://github.com/coopdevs/decidim-module-action_delegator/actions/workflows/test.yml/badge.svg)](https://github.com/coopdevs/decidim-module-action_delegator/actions/workflows/test.yml)
|
4
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/6ec3c39e8dc2075808e1/maintainability)](https://codeclimate.com/github/coopdevs/decidim-module-action_delegator/maintainability)
|
5
6
|
[![Codecov](https://codecov.io/gh/coopdevs/decidim-module-action_delegator/branch/master/graph/badge.svg)](https://codecov.io/gh/coopdevs/decidim-module-action_delegator)
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/decidim-action_delegator.svg)](https://badge.fury.io/rb/decidim-action_delegator)
|
6
8
|
|
7
|
-
|
8
|
-
A tool for Decidim that provides extended functionalities for cooperatives.
|
9
|
+
A tool for Decidim that provides extended functionalities for cooperatives or any other type of organization that need to vote with weighted-vote results and/or vote-delegation.
|
9
10
|
|
10
11
|
Combines a CSV-like verification method with impersonation capabilities that allow users to delegate some actions to others.
|
11
12
|
|
12
13
|
Admin can set limits to the number of delegation per users an other characteristics.
|
13
14
|
|
14
|
-
Initially, only votes can be delegated.
|
15
|
+
Initially, only votes on consultations can be delegated.
|
15
16
|
|
16
17
|
## Dependencies
|
17
18
|
|
18
|
-
* [decidim-consultations](https://github.com/decidim/decidim/tree/master/decidim-consultations) >= v0.
|
19
|
-
* [decidim-admin](https://github.com/decidim/decidim/tree/master/decidim-admin) >= v0.
|
20
|
-
* [decidim-core](https://github.com/decidim/decidim/tree/master/decidim-core) >= v0.
|
19
|
+
* [decidim-consultations](https://github.com/decidim/decidim/tree/master/decidim-consultations) >= v0.26.0
|
20
|
+
* [decidim-admin](https://github.com/decidim/decidim/tree/master/decidim-admin) >= v0.26.0
|
21
|
+
* [decidim-core](https://github.com/decidim/decidim/tree/master/decidim-core) >= v0.26.0
|
21
22
|
|
22
23
|
## Installation
|
23
24
|
|
@@ -27,6 +28,12 @@ Add this line to your application's Gemfile:
|
|
27
28
|
gem "decidim-action_delegator"
|
28
29
|
```
|
29
30
|
|
31
|
+
Or, if you want to stay up to date with the latest changes use this line instead:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
gem 'decidim-action_delegator', git: "https://github.com/coopdevs/decidim-module-action_delegator"
|
35
|
+
```
|
36
|
+
|
30
37
|
And then execute:
|
31
38
|
|
32
39
|
```bash
|
@@ -35,45 +42,71 @@ bundle exec rails decidim_action_delegator:install:migrations
|
|
35
42
|
bundle exec rails db:migrate
|
36
43
|
```
|
37
44
|
|
38
|
-
|
45
|
+
> **IMPORTANT:**
|
46
|
+
>
|
47
|
+
> If you are upgrading from a previous version, you need to run the migrations again and import all membership types/weights into the built-in census by executing in your production server:
|
48
|
+
>
|
49
|
+
> ```bash
|
50
|
+
> RAILS_ENV=production bundle exec rails decidim_action_delegator:import_direct_verifications
|
51
|
+
> ```
|
52
|
+
>
|
53
|
+
> *It is safe to run the previous command multiple times, no content will be imported twice.*
|
54
|
+
|
55
|
+
|
56
|
+
Depending on your Decidim version, you can choose the corresponding version to ensure compatibility:
|
39
57
|
|
40
58
|
| Version | Compatible Decidim versions |
|
41
59
|
|---|---|
|
42
|
-
| 0.
|
60
|
+
| 0.7.x | 0.26.x |
|
61
|
+
| 0.6.x | 0.26.x |
|
43
62
|
| 0.5 | 0.25.x |
|
44
63
|
| 0.4 | 0.24.x |
|
45
64
|
| 0.3 | 0.24.x |
|
46
65
|
| 0.2 | 0.23.x |
|
47
66
|
| 0.1 | 0.22.0 |
|
48
67
|
|
49
|
-
|
68
|
+
*Heads up!* [Consultations module will be deprecated in the near future.](https://github.com/decidim/decidim/issues/7097)
|
50
69
|
|
51
70
|
## Usage
|
52
71
|
|
53
72
|
ActionDelegator does not provides new Components or Participatory Spaces but enhances some functionalities in them.
|
54
73
|
|
74
|
+
Currently it is designed to work with the Consultations module.
|
75
|
+
|
76
|
+
- On one side, provides a custom verification method that allows admins to ensure only those in specific census (that can be uploaded via CSV) are able to vote. This census can be different for each consultation. This is optional and doesn't affect weighted voting or delegations.
|
77
|
+
|
78
|
+
- On the other, each set of census can work with a different set of weights and delegation.
|
79
|
+
|
80
|
+
![](docs/settings.png)
|
81
|
+
|
55
82
|
### Extended consultation results
|
56
83
|
|
57
84
|
This gem modifies the consultation's results page adding two extra columns
|
58
|
-
`Membership type` and `Membership weight`. This
|
59
|
-
that creates `decidim_authorizations` records which include the following JSON
|
60
|
-
structure in the `metadata` column:
|
85
|
+
`Membership type` and `Membership weight`. This is based on the census uploaded for each consultation and the weights assigned to each participant.
|
61
86
|
|
62
|
-
|
63
|
-
|
64
|
-
|
87
|
+
### Authorization verfifier and SMS gateway setup
|
88
|
+
|
89
|
+
The integrated authorization method is called "Delegations verifier". If included in each question of a consultation, it will check if the user is authorized and present in the census before letting him vote.
|
65
90
|
|
66
|
-
|
67
|
-
as an example of such verification.
|
91
|
+
It can be used in 3 modes:
|
68
92
|
|
69
|
-
|
93
|
+
1. **Email only**: This means that the participants list for each consultation setting relies on the email only. No SMS gateway integration is needed. The user is verified if the email is found in the census.
|
94
|
+
2. **Email and phone**: This means that the participants list for each consultation setting relies on the email and the phone number. An SMS gateway integration is needed. The user is verified if the email is found in the census and then sending a verification code to the phone number that the user cannot edit.
|
95
|
+
3. **Phone only**: This means that the participants list for each consultation setting relies on the phone number only. An SMS gateway integration is needed. The user is verified by a form where a phone number must be introduced. The user can edit the phone number and the verification code is sent to the new phone number if that phone number is found in the participant's list. This method is useful to avoid to relay on keeping track of email changes for user's database.
|
70
96
|
|
71
|
-
|
97
|
+
|
98
|
+
In order to use this new sms gateway you need to configure your application. It can work on two modes,
|
99
|
+
|
100
|
+
The first is to use the same built-in SMS gateway used in Decidim: In `config/initializers/decidim.rb` set:
|
72
101
|
|
73
102
|
```ruby
|
74
103
|
config.sms_gateway_service = 'Decidim::ActionDelegator::SmsGateway'
|
75
|
-
|
76
104
|
```
|
105
|
+
|
106
|
+
> Note that if you use this method you will be able to use the built-in SMS verification method in Decidim.
|
107
|
+
|
108
|
+
The other is to use a gateway service specific only for this plugin, this allows you to separate gateways or prevent decidim to allow admins to use the built in SMS verification method. This comes preinstalled and only requires you to setup some ENV variables.
|
109
|
+
|
77
110
|
#### Som Connexió
|
78
111
|
|
79
112
|
You can use Som Connexió as SMS provider which uses [this SOAP API](https://websms.masmovil.com/api_php/smsvirtual.wsdl). Reach out to Som Connexió to sign up first.
|
@@ -96,6 +129,50 @@ TWILIO_AUTH_TOKEN # Token from your Twilio account
|
|
96
129
|
SMS_SENDER # Twilio's phone number. You need to purchase one there with SMS capability.
|
97
130
|
```
|
98
131
|
|
132
|
+
#### Custom SMS gateways
|
133
|
+
|
134
|
+
It is also possible to use your own Sms Gateway. In an new initializer (ie `config/initializers/action_delegator.rb`) set:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
Decidim::ActionDelegator.configure do |config|
|
138
|
+
config.sms_gateway_service = 'YourOwnSmsGateway'
|
139
|
+
end
|
140
|
+
```
|
141
|
+
|
142
|
+
### Other configuration options
|
143
|
+
|
144
|
+
There are some other configuration options available, for more info check [action_delegator](lib/decidim/action_delegator.rb). These are the default values
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
Decidim::ActionDelegator.configure do |config|
|
148
|
+
# this is the SmsGateway provided by this module
|
149
|
+
# Note that it will be ignored if you provide your own SmsGateway in Decidm.sms_gateway_service
|
150
|
+
config.sms_gateway_service = "Decidim::ActionDelegator::SmsGateway"
|
151
|
+
|
152
|
+
# The default expiration time for the integrated authorization
|
153
|
+
# if zero, the authorization won't be registered
|
154
|
+
config.authorization_expiration_time = 3.months
|
155
|
+
|
156
|
+
# Put this to false if you don't want to allow administrators to invite users not registered
|
157
|
+
# in the platform when uploading a census (inviting users without permission can be a GDPR offense).
|
158
|
+
config.allow_to_invite_users = true
|
159
|
+
|
160
|
+
# used for comparing phone numbers from a census list and the ones introduced by the user
|
161
|
+
# the phone number will be normalized before comparing it so, for instance,
|
162
|
+
# if you have a census list with +34 666 666 666 and the user introduces 0034666666666 or 666666666, they will be considered the same
|
163
|
+
# can be empty or null if yo don't want to check different combinations of prefixes
|
164
|
+
config.phone_prefixes = %w(+34 0034 34)
|
165
|
+
|
166
|
+
# The regex for validating phone numbers
|
167
|
+
config.phone_regex = /^\d{6,15}$/ # 6 to 15 digits
|
168
|
+
|
169
|
+
# Consultations has an annoying and totally useless deprecation warning
|
170
|
+
# This plugin removes it by default.
|
171
|
+
# If you want to keep it, you can set this config to false
|
172
|
+
config.remove_consultation_deprecation_warning = true
|
173
|
+
end
|
174
|
+
```
|
175
|
+
|
99
176
|
### Track delegated votes and unvotes
|
100
177
|
|
101
178
|
Votes and revocations done on behalf of other members are tracked through the
|
@@ -125,7 +202,7 @@ that matter.
|
|
125
202
|
|
126
203
|
## Contributing
|
127
204
|
|
128
|
-
|
205
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/coopdevs/decidim-module-action_delegator.
|
129
206
|
|
130
207
|
### Developing
|
131
208
|
|
@@ -152,16 +229,30 @@ order to create the dummy test app database.
|
|
152
229
|
Then to test how the module works in Decidim, start the development server:
|
153
230
|
|
154
231
|
```bash
|
155
|
-
|
156
|
-
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rails s
|
232
|
+
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bin/rails s
|
157
233
|
```
|
158
234
|
|
235
|
+
Note that `bin/rails` is a convenient wrapper around the command `cd development_app; bundle exec rails`.
|
236
|
+
|
159
237
|
In case you are using [rbenv](https://github.com/rbenv/rbenv) and have the
|
160
238
|
[rbenv-vars](https://github.com/rbenv/rbenv-vars) plugin installed for it, you
|
161
239
|
can add the environment variables to the root directory of the project in a file
|
162
240
|
named `.rbenv-vars`. If these are defined for the environment, you can omit
|
163
241
|
defining these in the commands shown above.
|
164
242
|
|
243
|
+
#### Webpacker notes
|
244
|
+
|
245
|
+
As latests versions of Decidim, this repository uses Webpacker for Rails. This means that compilation
|
246
|
+
of assets is required everytime a Javascript or CSS file is modified. Usually, this happens
|
247
|
+
automatically, but in some cases (specially when actively changes that type of files) you want to
|
248
|
+
speed up the process.
|
249
|
+
|
250
|
+
To do that, start in a separate terminal than the one with `bin/rails s`, and BEFORE it, the following command:
|
251
|
+
|
252
|
+
```bash
|
253
|
+
bin/webpack-dev-server
|
254
|
+
```
|
255
|
+
|
165
256
|
#### Code Styling
|
166
257
|
|
167
258
|
Please follow the code styling defined by the different linters that ensure we
|
@@ -180,21 +271,26 @@ bundle exec rubocop
|
|
180
271
|
To ease up following the style guide, you should install the plugin to your
|
181
272
|
favorite editor, such as:
|
182
273
|
|
183
|
-
- Atom - [linter-rubocop](https://atom.io/packages/linter-rubocop)
|
184
274
|
- Sublime Text - [Sublime RuboCop](https://github.com/pderichs/sublime_rubocop)
|
185
275
|
- Visual Studio Code - [Rubocop for Visual Studio Code](https://github.com/misogi/vscode-ruby-rubocop)
|
186
276
|
|
277
|
+
#### Non-Ruby Code Styling
|
278
|
+
|
279
|
+
There are other linters for Javascript and CSS. These run using NPM packages. You can
|
280
|
+
run the following commands:
|
281
|
+
|
282
|
+
1. `npm run lint`: Runs the linter for Javascript files.
|
283
|
+
2. `npm run lint-fix`: Automatically fix issues for Javascript files (if possible).
|
284
|
+
3. `npm run stylelint`: Runs the linter for SCSS files.
|
285
|
+
4. `npm run stylelint-fix`: Automatically fix issues for SCSS files (if possible).
|
286
|
+
|
187
287
|
### Testing
|
188
288
|
|
189
289
|
To run the tests run the following in the gem development path:
|
190
290
|
|
191
291
|
```bash
|
192
292
|
bundle
|
193
|
-
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake
|
194
|
-
cd spec/decidim_dummy_app
|
195
|
-
bundle exec rails decidim_action_delegator:install:migrations
|
196
|
-
RAILS_ENV=test bundle exec rails db:migrate
|
197
|
-
cd -
|
293
|
+
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake test_app
|
198
294
|
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rspec
|
199
295
|
```
|
200
296
|
|
@@ -209,13 +305,15 @@ commands shown above.
|
|
209
305
|
|
210
306
|
### Test code coverage
|
211
307
|
|
212
|
-
|
213
|
-
the `SIMPLECOV=1` environment variable in the rspec command as follows:
|
308
|
+
Running tests automatically generates a code coverage report. To generate the complete report run all the tests using this command:
|
214
309
|
|
215
310
|
```bash
|
216
|
-
|
311
|
+
bundle exec rspec
|
217
312
|
```
|
218
313
|
|
314
|
+
This will generate a folder named `coverage` in the project root which contains
|
315
|
+
the code coverage report.
|
316
|
+
|
219
317
|
### Localization
|
220
318
|
|
221
319
|
If you would like to see this module in your own language, you can help with its
|
@@ -223,9 +321,11 @@ translation at Crowdin:
|
|
223
321
|
|
224
322
|
https://crowdin.com/project/decidim-action-delegator-vote
|
225
323
|
|
226
|
-
This will generate a folder named `coverage` in the project root which contains
|
227
|
-
the code coverage report.
|
228
|
-
|
229
324
|
## License
|
230
325
|
|
231
326
|
This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.
|
327
|
+
|
328
|
+
## About
|
329
|
+
|
330
|
+
This plugin is currently maintained by [![Pokecode](app/packs/images/logo-pokecode.png)](https://pokecode.net)with much appreciated contributions from other companies.
|
331
|
+
|
@@ -27,7 +27,15 @@ module Decidim
|
|
27
27
|
@delegation ||= Decidim::ActionDelegator::GranteeDelegations.for(
|
28
28
|
form.context.current_question.consultation,
|
29
29
|
form.context.current_user
|
30
|
-
).find_by(id:
|
30
|
+
).find_by(id: delegation_id)
|
31
|
+
end
|
32
|
+
|
33
|
+
def delegation
|
34
|
+
@delegation ||= Decidim::ActionDelegator::Delegation.find_by(id: delegation_id)
|
35
|
+
end
|
36
|
+
|
37
|
+
def delegation_id
|
38
|
+
@delegation_id ||= form.decidim_consultations_delegation_id
|
31
39
|
end
|
32
40
|
end
|
33
41
|
end
|
@@ -54,7 +54,11 @@ module Decidim
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def create_delegation
|
57
|
-
@delegation = Delegation.create(
|
57
|
+
@delegation = Delegation.create(
|
58
|
+
granter: form.granter,
|
59
|
+
grantee: form.grantee,
|
60
|
+
setting: current_setting
|
61
|
+
)
|
58
62
|
end
|
59
63
|
end
|
60
64
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ActionDelegator
|
5
|
+
module Admin
|
6
|
+
class CreateParticipant < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - A form object with the params.
|
10
|
+
def initialize(form)
|
11
|
+
@form = form
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes the command. Broadcasts these events:
|
15
|
+
#
|
16
|
+
# - :ok when everything is valid.
|
17
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
18
|
+
#
|
19
|
+
# Returns nothing.
|
20
|
+
def call
|
21
|
+
return broadcast(:invalid) if form.invalid?
|
22
|
+
|
23
|
+
create_participant
|
24
|
+
|
25
|
+
broadcast(:ok, participant)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :form, :participant
|
31
|
+
|
32
|
+
def create_participant
|
33
|
+
@participant = Participant.create!(email: form.email,
|
34
|
+
phone: form.phone,
|
35
|
+
decidim_action_delegator_ponderation_id: form.decidim_action_delegator_ponderation_id,
|
36
|
+
setting: form.setting)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ActionDelegator
|
5
|
+
module Admin
|
6
|
+
class CreatePonderation < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - A form object with the params.
|
10
|
+
def initialize(form)
|
11
|
+
@form = form
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes the command. Broadcasts these events:
|
15
|
+
#
|
16
|
+
# - :ok when everything is valid.
|
17
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
18
|
+
#
|
19
|
+
# Returns nothing.
|
20
|
+
def call
|
21
|
+
return broadcast(:invalid) if form.invalid?
|
22
|
+
|
23
|
+
create_ponderation
|
24
|
+
|
25
|
+
broadcast(:ok, ponderation)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :form, :ponderation
|
31
|
+
|
32
|
+
def create_ponderation
|
33
|
+
@ponderation = Ponderation.create!(name: form.name, weight: form.weight, setting: form.setting)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ActionDelegator
|
5
|
+
module Admin
|
6
|
+
class CreateSetting < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - A form object with the params.
|
10
|
+
def initialize(form, copy_from_setting)
|
11
|
+
@form = form
|
12
|
+
@copy_from_setting = copy_from_setting
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Broadcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid.
|
18
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
create_setting
|
25
|
+
|
26
|
+
broadcast(:ok, setting)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :form, :setting
|
32
|
+
|
33
|
+
def create_setting
|
34
|
+
selected = @copy_from_setting || Setting.new(ponderations: [], participants: [])
|
35
|
+
|
36
|
+
created_setting = Setting.new(
|
37
|
+
max_grants: form.max_grants,
|
38
|
+
authorization_method: form.authorization_method,
|
39
|
+
decidim_consultation_id: form.decidim_consultation_id,
|
40
|
+
ponderations: selected.ponderations.map(&:dup),
|
41
|
+
participants: selected.participants.map(&:dup)
|
42
|
+
)
|
43
|
+
|
44
|
+
@setting = created_setting.save!
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ActionDelegator
|
5
|
+
module Admin
|
6
|
+
class FixResourcePermissions < Rectify::Command
|
7
|
+
def initialize(resources)
|
8
|
+
@resources = resources
|
9
|
+
@errors = []
|
10
|
+
end
|
11
|
+
|
12
|
+
# Executes the command. Broadcasts these events:
|
13
|
+
#
|
14
|
+
# - :ok when everything is valid.
|
15
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
16
|
+
#
|
17
|
+
# Returns nothing.
|
18
|
+
def call
|
19
|
+
return broadcast(:invalid) if resources.blank?
|
20
|
+
|
21
|
+
update_permissions
|
22
|
+
|
23
|
+
return broadcast(:invalid) if errors.any?
|
24
|
+
|
25
|
+
broadcast(:ok)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :resources, :errors
|
31
|
+
|
32
|
+
def update_permissions
|
33
|
+
resources.each do |resource|
|
34
|
+
resource.resource_manifest.actions.each do |action|
|
35
|
+
resource_permission ||= resource.resource_permission || resource.build_resource_permission
|
36
|
+
next unless resource_permission.permissions.dig(action, "authorization_handlers", "delegations_verifier").nil?
|
37
|
+
|
38
|
+
resource_permission.permissions.deep_merge!({ action => { "authorization_handlers" => { "delegations_verifier" => {} } } })
|
39
|
+
@errors << resource unless resource_permission.save
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ActionDelegator
|
5
|
+
module Admin
|
6
|
+
class UpdateParticipant < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - A form object with the params.
|
10
|
+
def initialize(form, participant)
|
11
|
+
@form = form
|
12
|
+
@participant = participant
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Broadcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid.
|
18
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
update_participant
|
25
|
+
|
26
|
+
broadcast(:ok, participant)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :form, :participant
|
32
|
+
|
33
|
+
def update_participant
|
34
|
+
participant.email = form.email
|
35
|
+
participant.phone = form.phone
|
36
|
+
participant.decidim_action_delegator_ponderation_id = form.decidim_action_delegator_ponderation_id
|
37
|
+
participant.save!
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ActionDelegator
|
5
|
+
module Admin
|
6
|
+
class UpdatePonderation < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - A form object with the params.
|
10
|
+
def initialize(form, ponderation)
|
11
|
+
@form = form
|
12
|
+
@ponderation = ponderation
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Broadcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid.
|
18
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
update_ponderation
|
25
|
+
|
26
|
+
broadcast(:ok, ponderation)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :form, :ponderation
|
32
|
+
|
33
|
+
def update_ponderation
|
34
|
+
ponderation.name = form.name
|
35
|
+
ponderation.weight = form.weight
|
36
|
+
ponderation.save!
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ActionDelegator
|
5
|
+
module Admin
|
6
|
+
class UpdateSetting < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - A form object with the params.
|
10
|
+
def initialize(form, setting, copy_from_setting)
|
11
|
+
@form = form
|
12
|
+
@setting = setting
|
13
|
+
@copy_from_setting = copy_from_setting
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
return broadcast(:invalid) if form.invalid?
|
24
|
+
|
25
|
+
update_setting
|
26
|
+
|
27
|
+
broadcast(:ok, setting)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :form, :setting, :copy_from_setting
|
33
|
+
|
34
|
+
def update_setting
|
35
|
+
setting.assign_attributes(
|
36
|
+
max_grants: form.max_grants,
|
37
|
+
decidim_consultation_id: form.decidim_consultation_id,
|
38
|
+
authorization_method: form.authorization_method
|
39
|
+
)
|
40
|
+
|
41
|
+
if copy_from_setting.present?
|
42
|
+
new_participants = copy_from_setting.participants.reject do |participant|
|
43
|
+
existing_participants.any? { |p| p.email == participant.email || p.phone == participant.phone }
|
44
|
+
end
|
45
|
+
setting.participants += new_participants.map(&:dup)
|
46
|
+
|
47
|
+
new_ponderations = copy_from_setting.ponderations.reject do |ponderation|
|
48
|
+
existing_ponderations.any? { |p| p.name == ponderation.name }
|
49
|
+
end
|
50
|
+
setting.ponderations += new_ponderations.map(&:dup)
|
51
|
+
end
|
52
|
+
|
53
|
+
setting.save!
|
54
|
+
end
|
55
|
+
|
56
|
+
def existing_participants
|
57
|
+
@existing_participants ||= setting.participants.to_a
|
58
|
+
end
|
59
|
+
|
60
|
+
def existing_ponderations
|
61
|
+
@existing_ponderations ||= setting.ponderations.to_a
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ActionDelegator
|
5
|
+
module Consultations
|
6
|
+
module ConsultationsControllerOverride
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
include ::Decidim::ActionDelegator::NeedsConsultationStyles
|
9
|
+
|
10
|
+
included do
|
11
|
+
helper ::Decidim::ActionDelegator::DelegationHelper
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|