decidim-action_delegator 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-AGPLv3.txt +661 -0
  3. data/README.md +225 -0
  4. data/Rakefile +41 -0
  5. data/app/assets/config/admin/decidim_action_delegator_manifest.css +0 -0
  6. data/app/assets/config/admin/decidim_action_delegator_manifest.js +1 -0
  7. data/app/assets/config/decidim_action_delegator_manifest.css +3 -0
  8. data/app/assets/config/decidim_action_delegator_manifest.js +2 -0
  9. data/app/assets/images/decidim/action_delegator/icon.svg +1 -0
  10. data/app/assets/javascripts/decidim/action_delegator/admin/action_delegator.js.es6 +3 -0
  11. data/app/assets/javascripts/decidim/action_delegator/questions.js.es6 +26 -0
  12. data/app/assets/stylesheets/decidim/action_delegator/questions.scss +25 -0
  13. data/app/commands/decidim/action_delegator/admin/create_delegation.rb +62 -0
  14. data/app/commands/decidim/action_delegator/consultations/multiple_vote_question_override.rb +31 -0
  15. data/app/commands/decidim/action_delegator/consultations/vote_question_override.rb +36 -0
  16. data/app/commands/decidim/action_delegator/vote_delegation.rb +28 -0
  17. data/app/controllers/concerns/decidim/action_delegator/admin/filterable.rb +23 -0
  18. data/app/controllers/decidim/action_delegator/admin/application_controller.rb +19 -0
  19. data/app/controllers/decidim/action_delegator/admin/consultations/exports_controller.rb +27 -0
  20. data/app/controllers/decidim/action_delegator/admin/consultations_controller.rb +33 -0
  21. data/app/controllers/decidim/action_delegator/admin/delegations_controller.rb +79 -0
  22. data/app/controllers/decidim/action_delegator/admin/exports/sum_of_weights_controller.rb +15 -0
  23. data/app/controllers/decidim/action_delegator/admin/results/sum_of_weights_controller.rb +37 -0
  24. data/app/controllers/decidim/action_delegator/admin/settings_controller.rb +71 -0
  25. data/app/controllers/decidim/action_delegator/application_controller.rb +14 -0
  26. data/app/controllers/decidim/action_delegator/consultations/question_multiple_votes_controller_override.rb +28 -0
  27. data/app/controllers/decidim/action_delegator/consultations/question_votes_controller_override.rb +55 -0
  28. data/app/controllers/decidim/action_delegator/user_delegations_controller.rb +22 -0
  29. data/app/controllers/decidim/action_delegator/verifications/sms/authorizations_controller_override.rb +38 -0
  30. data/app/forms/decidim/action_delegator/admin/delegation_form.rb +25 -0
  31. data/app/forms/decidim/action_delegator/consultations/vote_form_override.rb +15 -0
  32. data/app/helpers/decidim/action_delegator/admin/delegation_helper.rb +27 -0
  33. data/app/helpers/decidim/action_delegator/application_helper.rb +10 -0
  34. data/app/jobs/decidim/action_delegator/export_consultation_results_job.rb +51 -0
  35. data/app/jobs/decidim/action_delegator/send_sms_job.rb +60 -0
  36. data/app/jobs/decidim/action_delegator/twilio_send_sms_job.rb +43 -0
  37. data/app/models/decidim/action_delegator/application_record.rb +10 -0
  38. data/app/models/decidim/action_delegator/consultations/vote_override.rb +15 -0
  39. data/app/models/decidim/action_delegator/delegation.rb +26 -0
  40. data/app/models/decidim/action_delegator/setting.rb +22 -0
  41. data/app/models/decidim/action_delegator/unversioned_vote.rb +19 -0
  42. data/app/models/decidim/action_delegator/whodunnit_vote.rb +28 -0
  43. data/app/permissions/decidim/action_delegator/consultations_permissions_extension.rb +27 -0
  44. data/app/permissions/decidim/action_delegator/permissions.rb +74 -0
  45. data/app/presenters/decidim/action_delegator/admin/consultation_presenter.rb +15 -0
  46. data/app/presenters/decidim/action_delegator/admin/setting_presenter.rb +13 -0
  47. data/app/presenters/decidim/action_delegator/question_with_totals.rb +24 -0
  48. data/app/queries/decidim/action_delegator/consultation_delegations.rb +25 -0
  49. data/app/queries/decidim/action_delegator/decrypted_authorizations.rb +112 -0
  50. data/app/queries/decidim/action_delegator/delegated_votes_versions.rb +31 -0
  51. data/app/queries/decidim/action_delegator/delegates_votes_by_consultation.rb +24 -0
  52. data/app/queries/decidim/action_delegator/delegates_votes_by_question.rb +26 -0
  53. data/app/queries/decidim/action_delegator/delegation_votes.rb +30 -0
  54. data/app/queries/decidim/action_delegator/grantee_delegations.rb +24 -0
  55. data/app/queries/decidim/action_delegator/json_build_object_query.rb +45 -0
  56. data/app/queries/decidim/action_delegator/organization_delegations.rb +26 -0
  57. data/app/queries/decidim/action_delegator/organization_settings.rb +25 -0
  58. data/app/queries/decidim/action_delegator/published_responses.rb +25 -0
  59. data/app/queries/decidim/action_delegator/responses_by_membership.rb +75 -0
  60. data/app/queries/decidim/action_delegator/scrutiny.rb +87 -0
  61. data/app/queries/decidim/action_delegator/setting_delegations.rb +19 -0
  62. data/app/queries/decidim/action_delegator/sum_of_membership_weight.rb +48 -0
  63. data/app/queries/decidim/action_delegator/sum_of_weights.rb +25 -0
  64. data/app/queries/decidim/action_delegator/type_and_weight.rb +26 -0
  65. data/app/queries/decidim/action_delegator/voted_with_direct_verification.rb +53 -0
  66. data/app/queries/decidim/action_delegator/votes_count_aggregation.rb +34 -0
  67. data/app/serializers/decidim/action_delegator/consultation_results_serializer.rb +19 -0
  68. data/app/serializers/decidim/action_delegator/sum_of_weights_serializer.rb +17 -0
  69. data/app/services/decidim/action_delegator/sms_gateway.rb +51 -0
  70. data/app/views/decidim/action_delegator/_callout.html.erb +5 -0
  71. data/app/views/decidim/action_delegator/_delegations_modal.html.erb +93 -0
  72. data/app/views/decidim/action_delegator/_link_to_delegations.html.erb +5 -0
  73. data/app/views/decidim/action_delegator/_link_to_question.html.erb +5 -0
  74. data/app/views/decidim/action_delegator/admin/consultations/results.html.erb +62 -0
  75. data/app/views/decidim/action_delegator/admin/delegations/index.html.erb +36 -0
  76. data/app/views/decidim/action_delegator/admin/delegations/new.html.erb +30 -0
  77. data/app/views/decidim/action_delegator/admin/results/sum_of_weights/index.html.erb +63 -0
  78. data/app/views/decidim/action_delegator/admin/settings/index.html.erb +39 -0
  79. data/app/views/decidim/action_delegator/admin/settings/new.html.erb +30 -0
  80. data/app/views/decidim/action_delegator/user_delegations/index.html.erb +19 -0
  81. data/app/views/decidim/consultations/consultations/_question.html.erb +41 -0
  82. data/app/views/decidim/consultations/consultations/show.html.erb +14 -0
  83. data/app/views/decidim/consultations/question_multiple_votes/_form.html.erb +25 -0
  84. data/app/views/decidim/consultations/question_votes/update_vote_button.js.erb +32 -0
  85. data/app/views/decidim/consultations/questions/_vote_button.html.erb +107 -0
  86. data/app/views/decidim/consultations/questions/_vote_modal.html.erb +30 -0
  87. data/app/views/decidim/consultations/questions/_vote_modal_confirm.html.erb +38 -0
  88. data/app/views/decidim/verifications/sms/authorizations/new.html.erb +33 -0
  89. data/app/views/layouts/decidim/action_delegator/admin/_users_sidebar.html.erb +56 -0
  90. data/app/views/layouts/decidim/action_delegator/admin/delegations.html.erb +13 -0
  91. data/app/views/layouts/decidim/admin/consultation.html.erb +56 -0
  92. data/app/views/layouts/decidim/admin/question.html.erb +98 -0
  93. data/app/views/layouts/decidim/admin/users.html.erb +7 -0
  94. data/config/i18n-tasks.yml +10 -0
  95. data/config/locales/ca.yml +101 -0
  96. data/config/locales/cs.yml +101 -0
  97. data/config/locales/en.yml +109 -0
  98. data/config/locales/es.yml +101 -0
  99. data/db/migrate/20200729194540_create_decidim_action_delegator_delegations.rb +12 -0
  100. data/db/migrate/20200824113801_create_settings.rb +13 -0
  101. data/db/migrate/20200828113755_add_setting_id_to_delegations.rb +11 -0
  102. data/db/migrate/20200831141540_make_granter_id_and_grantee_id_non_nullable.rb +8 -0
  103. data/db/migrate/20201001172345_remove_expires_at_from_delegations.rb +7 -0
  104. data/db/migrate/20201005203554_add_setting_granter_unique_index_to_delegations.rb +10 -0
  105. data/db/migrate/20201006084522_remove_setting_id_index_from_delegations.rb +7 -0
  106. data/db/migrate/20201030164808_add_delegation_id_to_versions.rb +8 -0
  107. data/db/seeds.rb +7 -0
  108. data/lib/decidim/action_delegator/admin.rb +10 -0
  109. data/lib/decidim/action_delegator/admin_engine.rb +42 -0
  110. data/lib/decidim/action_delegator/engine.rb +53 -0
  111. data/lib/decidim/action_delegator/test/factories.rb +25 -0
  112. data/lib/decidim/action_delegator/version.rb +10 -0
  113. data/lib/decidim/action_delegator.rb +29 -0
  114. data/lib/json_key.rb +10 -0
  115. metadata +267 -0
@@ -0,0 +1,101 @@
1
+ ca:
2
+ decidim:
3
+ action_delegator:
4
+ admin:
5
+ consultations:
6
+ results:
7
+ title: Resultats per resposta, tipus de soci i pes
8
+ delegations:
9
+ create:
10
+ error: S'ha produït un error en crear aquesta delegació
11
+ error_granter_unique: ja ha delegat el seu vot
12
+ error_max_grants: Has arribat al limit de delegacions permeses
13
+ success: Delegació creada amb èxit
14
+ destroy:
15
+ error: S'ha produït un error en eliminar aquesta delegació
16
+ success: S'ha eliminat la delegació amb èxit
17
+ index:
18
+ actions:
19
+ new_delegation: Nou participant
20
+ consultation: Consulta
21
+ created_at: Creat el
22
+ delete: Eliminar
23
+ grantee: Receptor
24
+ granter: Atorgant
25
+ title: Participants
26
+ new:
27
+ form:
28
+ title: Informació general
29
+ grantee: Receptor
30
+ granter: Atorgant
31
+ save: Crear
32
+ select_member: Selecciona un membre
33
+ title: Nova delegació
34
+ menu:
35
+ consultations_submenu:
36
+ by_answer: Per resposta
37
+ by_type_and_weight: Per tipus i ponderació
38
+ sum_of_weights: Per suma ponderada
39
+ delegations: Delegacions
40
+ participants: Participants
41
+ results:
42
+ sum_of_weights:
43
+ index:
44
+ title: Resultats per resposta sumant ponderació de vot
45
+ settings:
46
+ create:
47
+ error: S'ha produït un error en crear la configuració
48
+ success: Configuració guardada amb èxit
49
+ destroy:
50
+ error: S'ha produït un error en eliminar aquesta configuració
51
+ success: Configuració eliminada correctament
52
+ index:
53
+ actions:
54
+ new_setting: Nova delegació
55
+ consultation: Consulta
56
+ created_at: Creat el
57
+ title: Delegacions
58
+ new:
59
+ form:
60
+ title: Informació general
61
+ max_grants: Màxim de delegacions rebudes per persona
62
+ save: Desa
63
+ title: Configuració de delacions
64
+ authorizations:
65
+ new:
66
+ missing_phone_error: No s'ha trobat telèfon del membre
67
+ phone_warning: Aquest número de telèfon s'ha importat per l'administrador. Si us plau, poseu-vos-hi en contacte si no és correcte.
68
+ delegations:
69
+ link: Tens delegacions disponibles
70
+ delegations_modal:
71
+ callout: Recorda, estàs votant en nom de
72
+ contextual_help: 'Has estat autoritzat a votar en nom de:'
73
+ title: 'Consulta: delegacions atorgades'
74
+ name: Mòdul Decidim ActionDelegator per a cooperatives
75
+ sms_message: El teu codi de verificació és %{code}
76
+ verification:
77
+ admin:
78
+ members:
79
+ index:
80
+ title: Administració de membres
81
+ admin:
82
+ consultations:
83
+ results:
84
+ default_metadata: "(dades de membre no disponibles)"
85
+ export: Exporta
86
+ export_filename: consulta_resultats
87
+ membership_type: Tipus de membre
88
+ membership_weight: Ponderació
89
+ total_delegates: "%{count} vots delegats"
90
+ authorization_handlers:
91
+ admin:
92
+ delegations_verifier:
93
+ help:
94
+ - Mètode de verificació per la delegació de vot
95
+ delegations_verifier:
96
+ explanation: Els usuaris verificats per aquest mètode poden delegar els seus vots a altres usuaris
97
+ name: Verificador de Delegacions
98
+ layouts:
99
+ decidim:
100
+ user_profile:
101
+ vote_delegations: Delegacions de vot
@@ -0,0 +1,101 @@
1
+ cs:
2
+ decidim:
3
+ action_delegator:
4
+ admin:
5
+ consultations:
6
+ results:
7
+ title: Výsledky podle odpovědi, typu členství a váhy
8
+ delegations:
9
+ create:
10
+ error: Při vytváření delegace došlo k chybě
11
+ error_granter_unique: již delegovali svůj hlas
12
+ error_max_grants: Dosáhli jste limitu povolených delegací pro tohoto příjemce
13
+ success: Delegace úspěšně vytvořena
14
+ destroy:
15
+ error: Došlo k potížím při odstraňování této delegace
16
+ success: Delegace úspěšně zničena
17
+ index:
18
+ actions:
19
+ new_delegation: Nový účastník
20
+ consultation: Konzultace
21
+ created_at: Vytvořeno v
22
+ delete: Smazat
23
+ grantee: Příjemce
24
+ granter: Delegující
25
+ title: Účastníci
26
+ new:
27
+ form:
28
+ title: Obecné informace
29
+ grantee: Příjemce
30
+ granter: Delegující
31
+ save: Vytvořit
32
+ select_member: Vybrat člena
33
+ title: Nová delegace
34
+ menu:
35
+ consultations_submenu:
36
+ by_answer: Podle odpovědi
37
+ by_type_and_weight: Podle typu a váhy
38
+ sum_of_weights: Podle součtu vah
39
+ delegations: Uživatelské delegace
40
+ participants: Účastníci
41
+ results:
42
+ sum_of_weights:
43
+ index:
44
+ title: Výsledky na základě součtu váh členů
45
+ settings:
46
+ create:
47
+ error: Při vytváření nastavení se vyskytl problém
48
+ success: Nastavení bylo úspěšně uloženo
49
+ destroy:
50
+ error: Při odstraňování tohoto nastavení došlo k chybě
51
+ success: Nastavení úspěšně zničeno
52
+ index:
53
+ actions:
54
+ new_setting: Nová delegace
55
+ consultation: Konzultace
56
+ created_at: Vytvořeno v
57
+ title: Delegace
58
+ new:
59
+ form:
60
+ title: Obecné informace
61
+ max_grants: Maximum delegací
62
+ save: Uložit
63
+ title: Nastavení delegování
64
+ authorizations:
65
+ new:
66
+ missing_phone_error: Chybějící členský telefon
67
+ phone_warning: Toto telefonní číslo bylo importováno administrátorem. Pokud není správné, obraťte se na něj.
68
+ delegations:
69
+ link: Máte udělené delegace
70
+ delegations_modal:
71
+ callout: Pamatujte, že hlasujete jménem
72
+ contextual_help: 'Hlasování vám bylo uděleno od:'
73
+ title: 'Konzultace: udělené delegace'
74
+ name: Modul Decidim ActionDelegator cooperatives
75
+ sms_message: Váš ověřovací kód je %{code}
76
+ verification:
77
+ admin:
78
+ members:
79
+ index:
80
+ title: Správa členů
81
+ admin:
82
+ consultations:
83
+ results:
84
+ default_metadata: "(členské údaje nejsou k dispozici)"
85
+ export: Export
86
+ export_filename: výsledky konzultací
87
+ membership_type: Typ členství
88
+ membership_weight: Váha
89
+ total_delegates: "%{count} delegovaných hlasů"
90
+ authorization_handlers:
91
+ admin:
92
+ delegations_verifier:
93
+ help:
94
+ - Metoda ověřování pro delegované hlasování
95
+ delegations_verifier:
96
+ explanation: Ověření uživatelé s touto metodou mohou delegovat hlasy na ostatní uživatele
97
+ name: Ověřovatel delegací
98
+ layouts:
99
+ decidim:
100
+ user_profile:
101
+ vote_delegations: Delegace hlasů
@@ -0,0 +1,109 @@
1
+ ---
2
+ en:
3
+ decidim:
4
+ action_delegator:
5
+ admin:
6
+ consultations:
7
+ results:
8
+ title: Results by answer, membership type and weight
9
+ delegations:
10
+ create:
11
+ error: There was a problem creating the delegation
12
+ error_granter_unique: already delegated their vote
13
+ error_max_grants: You reached the limit of allowed delegations for this
14
+ grantee
15
+ success: Delegation created successfully
16
+ destroy:
17
+ error: There was a problem destroying this delegation
18
+ success: Delegation successfully destroyed
19
+ index:
20
+ actions:
21
+ new_delegation: New participant
22
+ consultation: Consultation
23
+ created_at: Created at
24
+ delete: Delete
25
+ grantee: Grantee
26
+ granter: Granter
27
+ title: Participants
28
+ new:
29
+ form:
30
+ title: General information
31
+ grantee: Grantee
32
+ granter: Granter
33
+ save: Create
34
+ select_member: Select member
35
+ title: New delegation
36
+ menu:
37
+ consultations_submenu:
38
+ by_answer: By answer
39
+ by_type_and_weight: By type and weight
40
+ sum_of_weights: By sum of weights
41
+ delegations: User delegations
42
+ participants: Participants
43
+ results:
44
+ sum_of_weights:
45
+ index:
46
+ title: Results by answer summing membership weights
47
+ settings:
48
+ create:
49
+ error: There was a problem creating the settings
50
+ success: Settings saved successfully
51
+ destroy:
52
+ error: There was a problem destroying this setting
53
+ success: Setting successfully destroyed
54
+ index:
55
+ actions:
56
+ new_setting: New delegation
57
+ consultation: Consultation
58
+ created_at: Created at
59
+ delegations: Total delegations
60
+ max_grants: Max delegations/user
61
+ title: Delegations
62
+ new:
63
+ form:
64
+ title: General information
65
+ max_grants: Maximum delegations per user
66
+ save: Save
67
+ title: Delegation settings
68
+ authorizations:
69
+ new:
70
+ missing_phone_error: Missing membership phone
71
+ phone_warning: This phone number has been imported by the admin. Please,
72
+ reach out if it's not correct.
73
+ delegations:
74
+ link: You have delegations granted
75
+ delegations_modal:
76
+ callout: Remember, you are voting on behalf of
77
+ contextual_help: 'You have been granted the vote from:'
78
+ title: 'Consultation: granted delegations'
79
+ name: Decidim ActionDelegator cooperatives module
80
+ sms_message: Your verification code is %{code}
81
+ user_delegations:
82
+ index:
83
+ vote_delegated: You can vote on behalf of %{name} in this consultation
84
+ verification:
85
+ admin:
86
+ members:
87
+ index:
88
+ title: Members management
89
+ admin:
90
+ consultations:
91
+ results:
92
+ default_metadata: "(membership data not available)"
93
+ export: Export
94
+ export_filename: consultation_results
95
+ membership_type: Membership type
96
+ membership_weight: Weight
97
+ total_delegates: "%{count} delegated votes"
98
+ authorization_handlers:
99
+ admin:
100
+ delegations_verifier:
101
+ help:
102
+ - A verification method for delegate voting
103
+ delegations_verifier:
104
+ explanation: Verified users with this method can delegate votes to other users
105
+ name: Delegations Verifier
106
+ layouts:
107
+ decidim:
108
+ user_profile:
109
+ vote_delegations: Vote delegations
@@ -0,0 +1,101 @@
1
+ es:
2
+ decidim:
3
+ action_delegator:
4
+ admin:
5
+ consultations:
6
+ results:
7
+ title: Results by answer, membership type and weight
8
+ delegations:
9
+ create:
10
+ error: There was a problem creating the delegation
11
+ error_granter_unique: already delegated their vote
12
+ error_max_grants: You reached the limit of allowed delegations
13
+ success: Delegation created successfully
14
+ destroy:
15
+ error: There was a problem destroying this delegation
16
+ success: Delegation successfully destroyed
17
+ index:
18
+ actions:
19
+ new_delegation: New participant
20
+ consultation: Consultation
21
+ created_at: Created at
22
+ delete: Delete
23
+ grantee: Grantee
24
+ granter: Granter
25
+ title: Participants
26
+ new:
27
+ form:
28
+ title: General information
29
+ grantee: Grantee
30
+ granter: Granter
31
+ save: Create
32
+ select_member: Select member
33
+ title: New delegation
34
+ menu:
35
+ consultations_submenu:
36
+ by_answer: By answer
37
+ by_type_and_weight: By type and weight
38
+ sum_of_weights: By sum of weights
39
+ delegations: User delegations
40
+ participants: Participants
41
+ results:
42
+ sum_of_weights:
43
+ index:
44
+ title: Results by answer summing membership weights
45
+ settings:
46
+ create:
47
+ error: There was a problem creating the settings
48
+ success: Settings saved successfully
49
+ destroy:
50
+ error: There was a problem destroying this setting
51
+ success: Setting successfully destroyed
52
+ index:
53
+ actions:
54
+ new_setting: New delegation
55
+ consultation: Consultation
56
+ created_at: Created at
57
+ title: Delegations
58
+ new:
59
+ form:
60
+ title: General information
61
+ max_grants: Maximum delegations
62
+ save: Save
63
+ title: Delegation settings
64
+ authorizations:
65
+ new:
66
+ missing_phone_error: Missing membership phone
67
+ phone_warning: This phone number has been imported by the admin. Please, reach out if it's not correct.
68
+ delegations:
69
+ link: You have delegations granted
70
+ delegations_modal:
71
+ callout: Remember, you are voting on behalf of
72
+ contextual_help: 'You have been granted the vote from:'
73
+ title: 'Consultation: granted delegations'
74
+ name: Decidim ActionDelegator cooperatives module
75
+ sms_message: Your verification code is %{code}
76
+ verification:
77
+ admin:
78
+ members:
79
+ index:
80
+ title: Members management
81
+ admin:
82
+ consultations:
83
+ results:
84
+ default_metadata: "(membership data not available)"
85
+ export: Export
86
+ export_filename: consultation_results
87
+ membership_type: Membership type
88
+ membership_weight: Weight
89
+ total_delegates: "%{count} delegated votes"
90
+ authorization_handlers:
91
+ admin:
92
+ delegations_verifier:
93
+ help:
94
+ - A verification method for delegate voting
95
+ delegations_verifier:
96
+ explanation: Verified users with this method can delegate votes to other users
97
+ name: Delegations Verifier
98
+ layouts:
99
+ decidim:
100
+ user_profile:
101
+ vote_delegations: Vote delegations
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimActionDelegatorDelegations < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :decidim_action_delegator_delegations do |t|
6
+ t.belongs_to :granter
7
+ t.belongs_to :grantee
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSettings < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :decidim_action_delegator_settings do |t|
6
+ t.datetime :expires_at, null: false
7
+ t.integer :max_grants, null: false, default: 0, limit: 2 # Maps to PostgreSQL smallint
8
+ t.belongs_to :decidim_consultation, null: false, foreign_key: true, index: { name: "index_decidim_settings_on_decidim_consultation_id" }
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddSettingIdToDelegations < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_belongs_to :decidim_action_delegator_delegations,
6
+ :decidim_action_delegator_setting,
7
+ null: false,
8
+ foreign_key: true,
9
+ index: { name: "index_decidim_delegations_on_action_delegator_setting_id" }
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class MakeGranterIdAndGranteeIdNonNullable < ActiveRecord::Migration[5.2]
4
+ def change
5
+ change_column_null :decidim_action_delegator_delegations, :granter_id, false
6
+ change_column_null :decidim_action_delegator_delegations, :grantee_id, false
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RemoveExpiresAtFromDelegations < ActiveRecord::Migration[5.2]
4
+ def change
5
+ remove_column :decidim_action_delegator_settings, :expires_at
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddSettingGranterUniqueIndexToDelegations < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_index :decidim_action_delegator_delegations,
6
+ [:decidim_action_delegator_setting_id, :granter_id],
7
+ unique: true,
8
+ name: "index_unique_decidim_delegations_on_setting_id_granter_id"
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RemoveSettingIdIndexFromDelegations < ActiveRecord::Migration[5.2]
4
+ def change
5
+ remove_index :decidim_action_delegator_delegations, name: "index_decidim_delegations_on_action_delegator_setting_id"
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddDelegationIdToVersions < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :versions, :decidim_action_delegator_delegation_id, :integer, null: true, default: nil
6
+ add_index :versions, :decidim_action_delegator_delegation_id
7
+ end
8
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ Decidim::ActionDelegator::Delegation.create(
4
+ granter: Decidim::User.first,
5
+ grantee: Decidim::User.second,
6
+ setting: Decidim::ActionDelegator::Setting.first
7
+ )
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ActionDelegator
5
+ # This module contains all the domain logic associated to the
6
+ # delegations admin panel.
7
+ module Admin
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ActionDelegator
5
+ # This is the engine that runs on the public interface of `ActionDelegator`.
6
+ class AdminEngine < ::Rails::Engine
7
+ isolate_namespace Decidim::ActionDelegator::Admin
8
+
9
+ paths["db/migrate"] = nil
10
+ paths["lib/tasks"] = nil
11
+
12
+ routes do
13
+ resources :settings, only: [:index, :new, :create, :destroy] do
14
+ resources :delegations, only: [:index, :new, :create, :destroy]
15
+ end
16
+
17
+ resources :consultations, param: :slug, only: [] do
18
+ get :results, on: :member
19
+ resources :exports, only: [:create], module: :consultations
20
+
21
+ namespace :exports do
22
+ resources :sum_of_weights, only: :create
23
+ end
24
+
25
+ namespace :results do
26
+ resources :sum_of_weights, only: :index
27
+ end
28
+ end
29
+
30
+ root to: "delegations#index"
31
+ end
32
+
33
+ initializer "decidim_action_delegator.admin_assets" do |app|
34
+ app.config.assets.precompile += %w(admin/decidim_action_delegator_manifest.js admin/decidim_action_delegator_manifest.css)
35
+ end
36
+
37
+ def load_seed
38
+ nil
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "savon"
4
+ require "rails"
5
+ require "decidim/core"
6
+ require "decidim/consultations"
7
+
8
+ module Decidim
9
+ module ActionDelegator
10
+ # This is the engine that runs on the public interface of action_delegator.
11
+ # Handles all the logic related to delegation except verifications
12
+ class Engine < ::Rails::Engine
13
+ isolate_namespace Decidim::ActionDelegator
14
+
15
+ routes do
16
+ # Add engine routes here
17
+ authenticate(:user) do
18
+ resources :user_delegations, controller: :user_delegations
19
+ root to: "user_delegations#index"
20
+ end
21
+ end
22
+
23
+ config.to_prepare do
24
+ # override votes questions
25
+ Decidim::Consultations::VoteQuestion.include(Decidim::ActionDelegator::Consultations::VoteQuestionOverride)
26
+ Decidim::Consultations::MultipleVoteQuestion.include(Decidim::ActionDelegator::Consultations::MultipleVoteQuestionOverride)
27
+ Decidim::Consultations::QuestionVotesController.include(Decidim::ActionDelegator::Consultations::QuestionVotesControllerOverride)
28
+ Decidim::Consultations::QuestionMultipleVotesController.include(Decidim::ActionDelegator::Consultations::QuestionMultipleVotesControllerOverride)
29
+ Decidim::Consultations::VoteForm.include(Decidim::ActionDelegator::Consultations::VoteFormOverride)
30
+ Decidim::Consultations::MultiVoteForm.include(Decidim::ActionDelegator::Consultations::VoteFormOverride)
31
+ Decidim::Consultations::Vote.include(Decidim::ActionDelegator::Consultations::VoteOverride)
32
+ Decidim::Verifications::Sms::AuthorizationsController.include(Decidim::ActionDelegator::Verifications::Sms::AuthorizationsControllerOverride)
33
+ end
34
+
35
+ initializer "decidim_action_delegator.assets" do |app|
36
+ app.config.assets.precompile += %w(decidim_action_delegator_manifest.js decidim_action_delegator_manifest.css)
37
+ end
38
+
39
+ initializer "decidim.user_menu" do
40
+ Decidim.menu :user_menu do |menu|
41
+ menu.item t("vote_delegations", scope: "layouts.decidim.user_profile"),
42
+ decidim_action_delegator.user_delegations_path,
43
+ position: 5.0,
44
+ active: :exact
45
+ end
46
+ end
47
+
48
+ initializer "decidim_action_delegator.permissions" do
49
+ Decidim::Consultations::Permissions.prepend(ConsultationsPermissionsExtension)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/core/test/factories"
4
+ require "decidim/consultations/test/factories"
5
+
6
+ FactoryBot.define do
7
+ factory :delegation, class: "Decidim::ActionDelegator::Delegation" do
8
+ setting
9
+ granter { association :user, organization: setting.consultation.organization }
10
+ grantee { association :user, organization: setting.consultation.organization }
11
+ end
12
+
13
+ factory :setting, class: "Decidim::ActionDelegator::Setting" do
14
+ max_grants { 3 }
15
+ consultation
16
+ end
17
+ end
18
+
19
+ FactoryBot.modify do
20
+ factory :authorization, class: "Decidim::Authorization" do
21
+ trait :direct_verification do
22
+ name { "direct_verifications" }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This holds the decidim-action_delegator version.
5
+ module ActionDelegator
6
+ MIN_DECIDIM_VERSION = ">= 0.24.0"
7
+ MAX_DECIDIM_VERSION = "<= 0.24.3"
8
+ VERSION = "0.4"
9
+ end
10
+ end