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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72ece5d4d1d3c253b4fd99f8372ba014ca14446be9f96119c87879ca8c94be6f
|
4
|
+
data.tar.gz: 8b1fb12a9a22f2bd035deb01273b3a73da14a916d4b250ddccf174d79f4b1f48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f29fbeaeb138c6c2b527b465d40146356f7dfa395ed04bcfc80df697738c94f82589a625ab455a6d11e1810975ef7648b078256684b33863e625866c8a20dd64
|
7
|
+
data.tar.gz: 4119061790bd135c90c14932ab33b939b8f05b05dd07c1c32ca6140f68727da2e4fd43e52308ec4b8cb8b947d00e34350181467664d024e3163098062af9fe88
|
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.
|
90
|
+
|
91
|
+
It can be used in 3 modes:
|
65
92
|
|
66
|
-
|
67
|
-
|
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.
|
68
96
|
|
69
|
-
### SMS gateway setup
|
70
97
|
|
71
|
-
In order to use this new sms gateway you need to configure your application.
|
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,16 @@ 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
|
+
|
99
142
|
### Track delegated votes and unvotes
|
100
143
|
|
101
144
|
Votes and revocations done on behalf of other members are tracked through the
|
@@ -125,7 +168,7 @@ that matter.
|
|
125
168
|
|
126
169
|
## Contributing
|
127
170
|
|
128
|
-
|
171
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/coopdevs/decidim-module-action_delegator.
|
129
172
|
|
130
173
|
### Developing
|
131
174
|
|
@@ -152,16 +195,30 @@ order to create the dummy test app database.
|
|
152
195
|
Then to test how the module works in Decidim, start the development server:
|
153
196
|
|
154
197
|
```bash
|
155
|
-
|
156
|
-
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rails s
|
198
|
+
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bin/rails s
|
157
199
|
```
|
158
200
|
|
201
|
+
Note that `bin/rails` is a convenient wrapper around the command `cd development_app; bundle exec rails`.
|
202
|
+
|
159
203
|
In case you are using [rbenv](https://github.com/rbenv/rbenv) and have the
|
160
204
|
[rbenv-vars](https://github.com/rbenv/rbenv-vars) plugin installed for it, you
|
161
205
|
can add the environment variables to the root directory of the project in a file
|
162
206
|
named `.rbenv-vars`. If these are defined for the environment, you can omit
|
163
207
|
defining these in the commands shown above.
|
164
208
|
|
209
|
+
#### Webpacker notes
|
210
|
+
|
211
|
+
As latests versions of Decidim, this repository uses Webpacker for Rails. This means that compilation
|
212
|
+
of assets is required everytime a Javascript or CSS file is modified. Usually, this happens
|
213
|
+
automatically, but in some cases (specially when actively changes that type of files) you want to
|
214
|
+
speed up the process.
|
215
|
+
|
216
|
+
To do that, start in a separate terminal than the one with `bin/rails s`, and BEFORE it, the following command:
|
217
|
+
|
218
|
+
```bash
|
219
|
+
bin/webpack-dev-server
|
220
|
+
```
|
221
|
+
|
165
222
|
#### Code Styling
|
166
223
|
|
167
224
|
Please follow the code styling defined by the different linters that ensure we
|
@@ -180,21 +237,26 @@ bundle exec rubocop
|
|
180
237
|
To ease up following the style guide, you should install the plugin to your
|
181
238
|
favorite editor, such as:
|
182
239
|
|
183
|
-
- Atom - [linter-rubocop](https://atom.io/packages/linter-rubocop)
|
184
240
|
- Sublime Text - [Sublime RuboCop](https://github.com/pderichs/sublime_rubocop)
|
185
241
|
- Visual Studio Code - [Rubocop for Visual Studio Code](https://github.com/misogi/vscode-ruby-rubocop)
|
186
242
|
|
243
|
+
#### Non-Ruby Code Styling
|
244
|
+
|
245
|
+
There are other linters for Javascript and CSS. These run using NPM packages. You can
|
246
|
+
run the following commands:
|
247
|
+
|
248
|
+
1. `npm run lint`: Runs the linter for Javascript files.
|
249
|
+
2. `npm run lint-fix`: Automatically fix issues for Javascript files (if possible).
|
250
|
+
3. `npm run stylelint`: Runs the linter for SCSS files.
|
251
|
+
4. `npm run stylelint-fix`: Automatically fix issues for SCSS files (if possible).
|
252
|
+
|
187
253
|
### Testing
|
188
254
|
|
189
255
|
To run the tests run the following in the gem development path:
|
190
256
|
|
191
257
|
```bash
|
192
258
|
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 -
|
259
|
+
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake test_app
|
198
260
|
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rspec
|
199
261
|
```
|
200
262
|
|
@@ -209,13 +271,15 @@ commands shown above.
|
|
209
271
|
|
210
272
|
### Test code coverage
|
211
273
|
|
212
|
-
|
213
|
-
the `SIMPLECOV=1` environment variable in the rspec command as follows:
|
274
|
+
Running tests automatically generates a code coverage report. To generate the complete report run all the tests using this command:
|
214
275
|
|
215
276
|
```bash
|
216
|
-
|
277
|
+
bundle exec rspec
|
217
278
|
```
|
218
279
|
|
280
|
+
This will generate a folder named `coverage` in the project root which contains
|
281
|
+
the code coverage report.
|
282
|
+
|
219
283
|
### Localization
|
220
284
|
|
221
285
|
If you would like to see this module in your own language, you can help with its
|
@@ -223,9 +287,6 @@ translation at Crowdin:
|
|
223
287
|
|
224
288
|
https://crowdin.com/project/decidim-action-delegator-vote
|
225
289
|
|
226
|
-
This will generate a folder named `coverage` in the project root which contains
|
227
|
-
the code coverage report.
|
228
|
-
|
229
290
|
## License
|
230
291
|
|
231
292
|
This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.
|
@@ -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
|
@@ -7,9 +7,10 @@ module Decidim
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
+
helper ::Decidim::ActionDelegator::DelegationHelper
|
10
11
|
helper_method :delegation
|
11
12
|
before_action do
|
12
|
-
session[:delegation_id] =
|
13
|
+
session[:delegation_id] = delegation.id if delegation
|
13
14
|
end
|
14
15
|
|
15
16
|
private
|