decidim-decidim_awesome 0.8.3 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -0
  3. data/README.md +55 -45
  4. data/Rakefile +1 -1
  5. data/app/commands/decidim/decidim_awesome/admin/create_constraint.rb +1 -1
  6. data/app/commands/decidim/decidim_awesome/admin/create_custom_redirect.rb +1 -1
  7. data/app/commands/decidim/decidim_awesome/admin/create_menu_hack.rb +1 -1
  8. data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +1 -1
  9. data/app/commands/decidim/decidim_awesome/admin/create_scoped_admin.rb +1 -1
  10. data/app/commands/decidim/decidim_awesome/admin/create_scoped_style.rb +1 -1
  11. data/app/commands/decidim/decidim_awesome/admin/destroy_constraint.rb +1 -1
  12. data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +1 -1
  13. data/app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb +1 -1
  14. data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +1 -1
  15. data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_admin.rb +1 -1
  16. data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_style.rb +1 -1
  17. data/app/commands/decidim/decidim_awesome/admin/rename_scope_label.rb +1 -1
  18. data/app/commands/decidim/decidim_awesome/admin/update_config.rb +2 -3
  19. data/app/commands/decidim/decidim_awesome/admin/update_constraint.rb +2 -2
  20. data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +1 -1
  21. data/app/commands/decidim/decidim_awesome/admin/update_menu_hack.rb +1 -1
  22. data/app/commands/decidim/decidim_awesome/command.rb +14 -0
  23. data/app/commands/decidim/decidim_awesome/create_editor_image.rb +1 -1
  24. data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable.rb +67 -0
  25. data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +37 -0
  26. data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +72 -0
  27. data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +6 -3
  28. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +2 -0
  29. data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +2 -0
  30. data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +2 -0
  31. data/app/controllers/decidim/decidim_awesome/editor_images_controller.rb +0 -2
  32. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +14 -0
  33. data/app/forms/decidim/decidim_awesome/admin/menu_form.rb +1 -1
  34. data/app/forms/decidim/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +26 -8
  35. data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +12 -8
  36. data/app/helpers/decidim/decidim_awesome/map_helper.rb +14 -11
  37. data/app/jobs/decidim/decidim_awesome/export_admin_actions_job.rb +28 -0
  38. data/app/middleware/decidim/decidim_awesome/current_config.rb +4 -0
  39. data/app/models/decidim/decidim_awesome/awesome_config.rb +0 -1
  40. data/app/models/decidim/decidim_awesome/config_constraint.rb +0 -2
  41. data/app/models/decidim/decidim_awesome/editor_image.rb +0 -3
  42. data/app/models/decidim/decidim_awesome/paper_trail_version.rb +113 -0
  43. data/app/packs/entrypoints/decidim_admin_decidim_awesome.js +3 -2
  44. data/app/packs/images/decidim/decidim_awesome/pokecode-logo.png +0 -0
  45. data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +7 -7
  46. data/app/packs/src/decidim/decidim_awesome/admin/check_redirections.js +2 -2
  47. data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +5 -5
  48. data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +11 -10
  49. data/app/packs/src/decidim/decidim_awesome/admin/form_exit_warn.js +1 -0
  50. data/app/packs/src/decidim/decidim_awesome/admin/user_picker.js +1 -0
  51. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/fetcher.js +13 -13
  52. data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +14 -12
  53. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +36 -15
  54. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +3 -3
  55. data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +25 -26
  56. data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +1 -0
  57. data/app/packs/src/decidim/decidim_awesome/editors/editor.js +33 -12
  58. data/app/packs/src/decidim/decidim_awesome/forms/autosave.js +8 -12
  59. data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +36 -27
  60. data/app/packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js +6 -4
  61. data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +7 -7
  62. data/app/packs/src/decidim/decidim_awesome/proposals/images.js +2 -2
  63. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +8 -5
  64. data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +15 -1
  65. data/app/permissions/decidim/decidim_awesome/permissions.rb +4 -6
  66. data/app/presenters/decidim/decidim_awesome/paper_trail_base_presenter.rb +28 -0
  67. data/app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb +45 -0
  68. data/app/presenters/decidim/decidim_awesome/role_base_presenter.rb +102 -0
  69. data/app/presenters/decidim/decidim_awesome/user_entity_presenter.rb +50 -0
  70. data/app/serializers/decidim/decidim_awesome/paper_trail_version_serializer.rb +37 -0
  71. data/app/validators/concerns/decidim/decidim_awesome/etiquette_validator_override.rb +41 -0
  72. data/app/views/decidim/decidim_awesome/admin/admin_accountability/index.html.erb +64 -0
  73. data/app/views/decidim/decidim_awesome/admin/checks/_assets_tester.html.erb +2 -0
  74. data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +82 -2
  75. data/app/views/decidim/decidim_awesome/admin/shared/_filters_with_date.html.erb +56 -0
  76. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +1 -1
  77. data/app/views/layouts/decidim/admin/decidim_awesome.html.erb +1 -1
  78. data/app/views/{v0.25 → v0.27}/layouts/decidim/_head.html.erb +12 -4
  79. data/config/i18n-tasks.yml +4 -0
  80. data/config/locales/ca.yml +73 -2
  81. data/config/locales/cs.yml +66 -2
  82. data/config/locales/de.yml +72 -1
  83. data/config/locales/en.yml +93 -1
  84. data/config/locales/es.yml +72 -2
  85. data/config/locales/fr.yml +73 -2
  86. data/config/locales/it.yml +1 -2
  87. data/config/locales/ja.yml +75 -4
  88. data/config/locales/nl.yml +0 -1
  89. data/config/locales/pt-BR.yml +1 -2
  90. data/db/seeds.rb +1 -1
  91. data/lib/decidim/decidim_awesome/admin_engine.rb +15 -1
  92. data/lib/decidim/decidim_awesome/awesome.rb +55 -1
  93. data/lib/decidim/decidim_awesome/checksums.yml +22 -6
  94. data/lib/decidim/decidim_awesome/config.rb +14 -14
  95. data/lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb +1 -1
  96. data/lib/decidim/decidim_awesome/engine.rb +36 -9
  97. data/lib/decidim/decidim_awesome/iframe_component/component.rb +2 -1
  98. data/lib/decidim/decidim_awesome/menu_hacker.rb +7 -1
  99. data/lib/decidim/decidim_awesome/system_checker.rb +2 -0
  100. data/lib/decidim/decidim_awesome/test/factories.rb +7 -0
  101. data/lib/decidim/decidim_awesome/test/initializer.rb +10 -2
  102. data/lib/decidim/decidim_awesome/test/shared_examples/action_log_presenter_examples.rb +61 -0
  103. data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +7 -4
  104. data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +2 -2
  105. data/lib/decidim/decidim_awesome/version.rb +2 -2
  106. data/lib/tasks/decidim_awesome_active_storage_migrations_tasks.rake +1 -3
  107. data/package.json +21 -163
  108. metadata +38 -42
  109. data/app/packs/images/decidim/decidim_awesome/platoniq-logo.png +0 -0
  110. data/app/packs/src/vendor/image-resize.min.js +0 -1
  111. data/app/packs/src/vendor/image-upload.min.js +0 -6
  112. data/app/packs/src/vendor/leaflet.featuregroup.subgroup.js +0 -184
  113. data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +0 -83
  114. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +0 -1
  115. data/app/views/v0.25/decidim/proposals/collaborative_drafts/_show.html.erb +0 -128
  116. data/app/views/v0.26/decidim/proposals/collaborative_drafts/_show.html.erb +0 -128
  117. /data/app/views/{v0.25 → v0.27}/layouts/decidim/admin/_header.html.erb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eed4ef964d206b4b5a37b77923126a11b05bb42a8973884c893a3968af5a65de
4
- data.tar.gz: 8d11f0ac9b2db016ce2b5727b3435260c377c1489df5a312990e7639bb398ab3
3
+ metadata.gz: fc4186635bb63b150df6c031e3ef9337fcfb71ce7057eddf5a990564ca1cd065
4
+ data.tar.gz: c9eaffa1131d1cd81ddb14b45e35928d76901a89e6c5141b3bb03ebb5acac244
5
5
  SHA512:
6
- metadata.gz: 2fc9e69aee8d8ae291f6f6791417fabd4830cfc7867838ba833a025df245635bf3c86faaf4ee4dd3ce28f18ee90712b2da758611e6db494b5b4e29be9704ba88
7
- data.tar.gz: 20829234cbed47b2f146988eeb6e0e68727636d29958c5eec809f089aaaafb6f759f3015714f3358d43cc6f70e840b5f9aa2558e8d4eaae8b6c0d48e8575a913
6
+ metadata.gz: 4c42aced89189c8f99c5ad6370ba1f490e0ec77ce9df796d007754f2f45bc9e3fbba0583ef2db6a4e1d63127d1d299123a69f1ac6fa23b8a3e5c7a65e20d706b
7
+ data.tar.gz: 51cefc6f281d1006ac905ac0fcd3e8c5461caa47403d815077d7fe9cb42e5df213f60a9998de4528c1b2caca47e87878f313752452c739a8186b75b8ed3cece5
data/CHANGELOG.md CHANGED
@@ -1,6 +1,58 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ v0.9.3
5
+ ------
6
+
7
+ Compatibility:
8
+ - Decidim v0.27.3
9
+ - Decidim v0.26.7
10
+
11
+ Features:
12
+ - Fixes for admin accountability leaking other tenants data
13
+
14
+ v0.9.2
15
+ ------
16
+
17
+ Compatibility:
18
+ - Decidim v0.27.3
19
+ - Decidim v0.26.7
20
+
21
+ Features:
22
+ - Fixes for the menu hacker
23
+
24
+ v0.9.1
25
+ ------
26
+
27
+ Compatibility:
28
+ - Decidim v0.27.x
29
+ - Decidim v0.26.x
30
+
31
+ Features:
32
+ - Fixes for the Awesome Map
33
+ - Added Admin Accountability feature
34
+
35
+ v0.9.0
36
+ ------
37
+
38
+ Compatibility:
39
+ - Decidim v0.27.x
40
+ - Decidim v0.26.x
41
+
42
+ Features:
43
+ - Upgrade 0.27 version
44
+
45
+ v0.8.4
46
+ ------
47
+
48
+ Compatibility:
49
+ - Decidim v0.26.x
50
+ - Decidim v0.25.x
51
+
52
+ Features:
53
+ - Feature: Override validation rules for title and body in proposals, with constrains available
54
+ - Improve loading process to facilitate development
55
+
4
56
  v0.8.3
5
57
  ------
6
58
 
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Decidim::DecidimAwesome
2
2
 
3
- [![[CI] Test](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test.yml/badge.svg)](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test.yml)
4
- [![Maintainability](https://api.codeclimate.com/v1/badges/2dada53525dd5a944089/maintainability)](https://codeclimate.com/github/Platoniq/decidim-module-decidim_awesome/maintainability)
5
- [![Test Coverage](https://codecov.io/gh/Platoniq/decidim-module-decidim_awesome/branch/master/graph/badge.svg?token=TFBMCLLZJG)](https://codecov.io/gh/Platoniq/decidim-module-decidim_awesome)
3
+ [![[CI] Tests 0.27](https://github.com/decidim-ice/decidim-module-decidim_awesome/actions/workflows/tests.yml/badge.svg)](https://github.com/decidim-ice/decidim-module-decidim_awesome/actions/workflows/tests.yml)
4
+ [![[CI] Tests 0.26](https://github.com/decidim-ice/decidim-module-decidim_awesome/actions/workflows/tests-legacy.yml/badge.svg)](https://github.com/decidim-ice/decidim-module-decidim_awesome/actions/workflows/tests-legacy.yml)
5
+ [![[CI] Lint](https://github.com/decidim-ice/decidim-module-decidim_awesome/actions/workflows/lint.yml/badge.svg)](https://github.com/decidim-ice/decidim-module-decidim_awesome/actions/workflows/lint.yml)
6
+ [![[CI] Precompile](https://github.com/decidim-ice/decidim-module-decidim_awesome/actions/workflows/precompile.yml/badge.svg)](https://github.com/decidim-ice/decidim-module-decidim_awesome/actions/workflows/precompile.yml)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/2dada53525dd5a944089/maintainability)](https://codeclimate.com/github/decidim-ice/decidim-module-decidim_awesome/maintainability)
8
+ [![Test Coverage](https://codecov.io/gh/decidim-ice/decidim-module-decidim_awesome/branch/main/graph/badge.svg?token=TFBMCLLZJG)](https://codecov.io/gh/decidim-ice/decidim-module-decidim_awesome)
6
9
 
7
10
  Usability and UX tweaks for Decidim.
8
11
 
@@ -13,12 +16,7 @@ All tweaks are provided in a optional fashion with granular permissions that let
13
16
 
14
17
  ## Why this plugin?
15
18
 
16
- At Platoniq, we like to explore and combine open tools for enriching democracy in many levels. And also for organizations or companies, not only governments.
17
- Currently we are working very closely with the team behind [Decidim](https://decidim.org) because we believe that it is a great software.
18
-
19
- However in Platoniq we have this slogan: "Democracy is fun if you take it seriously" (feel free to ask for T-shirts 😉).
20
- And, let's face it, sometimes we feel that Decidim lacks a bit of the "fun" part so we created this.
21
- Because Decidim is awesome and so is this!
19
+ Decidim is an awesome platform, but it has some limitations that can be annoying for the users or the admins. This plugin tries to solve some of them. See the list of tweaks below.
22
20
 
23
21
  ## Usage
24
22
 
@@ -143,9 +141,30 @@ Using a link with a query string (ie: `/take-me-somewhere?locale=es`) that will
143
141
 
144
142
  ![Custom redirections screenshot](examples/custom-redirections.png)
145
143
 
144
+ #### 14. Custom validation rules for title and body in proposals
145
+
146
+ Configure as you wish how the fields "title" and "body" are validated in proposals creation.
147
+
148
+ Rules available:
149
+
150
+ * Minimum title and body length (defaults to 15 chars).
151
+ * Maximum percentage of capital letters for title and body (defaults to 25%).
152
+ * Maximum number of "marks" (aka: exclamation and interrogation signs) that can be consective in the title or the body (defaults to 1).
153
+ * Enable/disable forcing to start the title or the body with a capital letter (defaults to "enabled").
154
+
155
+ ![Custom validations](examples/custom_validations.png)
156
+
157
+ #### 15. Admin accountability
158
+
159
+ This feature allows you to list all the users that are, or have been at any point in time, admins, valuators, user managers or any other role in Decidim. Including global admin roles or private admins of a particular participatory space.
160
+
161
+ Results can be filtered by role and by time range and also exported as CSV or other formats.
162
+
163
+ ![Admin accountability](examples/admin_accountability.png)
164
+
146
165
  #### To be continued...
147
166
 
148
- We're not done! Please check the [issues](/Platoniq/decidim-module-decidim_awesome/issues) (and participate) to see what's on our mind
167
+ We're not done! Please check the [issues](/decidim-ice/decidim-module-decidim_awesome/issues) (and participate) to see what's on our mind
149
168
 
150
169
  Also feel free to propose something! or even better send a PR!
151
170
 
@@ -190,6 +209,8 @@ Depending on your Decidim version, choose the corresponding Awesome version to e
190
209
 
191
210
  | Awesome version | Compatible Decidim versions |
192
211
  |---|---|
212
+ | 0.9.2 | >= 0.26.7, >= 0.27.3 |
213
+ | 0.9.x | 0.26.x, 0.27.x |
193
214
  | 0.8.x | 0.25.x, 0.26.x |
194
215
  | 0.7.x | 0.23.x, 0.24.x |
195
216
  | 0.6.x | 0.22.x, 0.23.x |
@@ -314,22 +335,33 @@ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake test_
314
335
  DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rspec
315
336
  ```
316
337
 
317
- However, this project also make use of the gem [Appraisals](https://github.com/thoughtbot/appraisal) in order to test against several versions of Decidim. The idea is to support same supported versions of Decidim.
338
+ However, this project works with different versions of Decidim. In order to test them all, we maintain two different Gemfiles: `Gemfile` and `Gemfile.legacy`. The first one is used for development and testing the latest Decidim version supported, the second one is used for testing against the old Decidim version.
318
339
 
319
- You can run run all tests against all Decidim versions by using:
340
+ You can run run tests against the legacy Decidim versions by using:
320
341
 
321
342
  ```bash
322
- bundle exec appraisal install
323
- DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal rake test_app
324
- DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal rspec
343
+ export DATABASE_USERNAME=<username>
344
+ export DATABASE_PASSWORD=<password>
345
+ RBENV_VERSION=2.7.6 BUNDLE_GEMFILE=Gemfile.legacy bundle
346
+ RBENV_VERSION=2.7.6 BUNDLE_GEMFILE=Gemfile.legacy bundle exec rake test_app
347
+ RBENV_VERSION=2.7.6 BUNDLE_GEMFILE=Gemfile.legacy bundle exec rspec
325
348
  ```
326
349
 
327
- To test a specific apprasail configured version do the following:
350
+ For convenience, you can use the scripts `bin/rspec` and `bin/rspec-legacy` to run tests against one or the other version:
328
351
 
352
+ ```bash
353
+ bin/rspec spec/
354
+ bin/rspec-legacy spec/
329
355
  ```
330
- DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.25 rake test_app
331
- DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.25 rspec
332
- ```
356
+
357
+ - Rbenv is required for this script to work.
358
+
359
+ > **NOTE:** Remember to reset the database when changing between tests:
360
+ > ```bash
361
+ > bin/rspec --reset
362
+ > bin/rspec-legacy --reset
363
+ > ```
364
+
333
365
 
334
366
  Note that the database user has to have rights to create and drop a database in
335
367
  order to create the dummy test app database.
@@ -342,35 +374,13 @@ commands shown above.
342
374
 
343
375
  ### Test code coverage
344
376
 
345
- If you want to generate the code coverage report for the tests, you can use
346
- the `SIMPLECOV=1` environment variable in the rspec command as follows:
347
-
348
- ```bash
349
- SIMPLECOV=1 bundle exec rspec
350
- ```
351
-
352
- This will generate a folder named `coverage` in the project root which contains
377
+ Code coverage report is generated automatically in a folder named `coverage` in the project root which contains
353
378
  the code coverage report.
354
379
 
355
- ### Appraisals commands
356
-
357
- The [Appraisals](Appraisals) file contains the supported versions. In i each version defines the changes respect to the main `Gemfile`.
358
-
359
- Appraisal uses custom gems for testing in the folder `gemfiles`, these gemfiles are generated from the file `Appraisals`. To update definitions do:
360
-
361
- ```
362
- bundle exec appraisal install
363
- ```
364
-
365
- The former command will take care of updating all configured version. To update the Appraisal definitions manually (not usually necessary) do the following:
366
-
367
- ```
368
- cd gemfiles
369
- BUNDLE_GEMFILE=./decidim_0.XX.gemfile bundle update
380
+ ```bash
381
+ firefox coverage/index.html
370
382
  ```
371
383
 
372
- Where 0.XX is the supported version that needs to be updated.
373
-
374
384
  ### Localization
375
385
 
376
386
  If you would like to see this module in your own language, you can help with its
@@ -384,4 +394,4 @@ This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.
384
394
 
385
395
  ## Credits
386
396
 
387
- This plugin has been developed by ![Platoniq](app/packs/images/decidim/decidim_awesome/platoniq-logo.png)
397
+ This plugin maintainted by ![PokeCode](app/packs/images/decidim/decidim_awesome/pokecode-logo.png)
data/Rakefile CHANGED
@@ -51,6 +51,6 @@ task :development_app do
51
51
  end
52
52
 
53
53
  install_module("development_app")
54
- seed_db("development_app")
55
54
  override_webpacker_config_files("development_app")
55
+ seed_db("development_app")
56
56
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class CreateConstraint < Rectify::Command
6
+ class CreateConstraint < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - A constraint form
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class CreateCustomRedirect < Rectify::Command
6
+ class CreateCustomRedirect < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  def initialize(form)
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class CreateMenuHack < Rectify::Command
6
+ class CreateMenuHack < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  def initialize(form, menu_name)
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class CreateProposalCustomField < Rectify::Command
6
+ class CreateProposalCustomField < Command
7
7
  include NeedsConstraintHelpers
8
8
 
9
9
  # Public: Initializes the command.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class CreateScopedAdmin < Rectify::Command
6
+ class CreateScopedAdmin < Command
7
7
  include NeedsConstraintHelpers
8
8
 
9
9
  # Public: Initializes the command.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class CreateScopedStyle < Rectify::Command
6
+ class CreateScopedStyle < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  def initialize(organization)
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class DestroyConstraint < Rectify::Command
6
+ class DestroyConstraint < Command
7
7
  include NeedsConstraintHelpers
8
8
 
9
9
  # Public: Initializes the command.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class DestroyCustomRedirect < Rectify::Command
6
+ class DestroyCustomRedirect < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # item - the redirections item to destroy
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class DestroyMenuHack < Rectify::Command
6
+ class DestroyMenuHack < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # item - the menu item to destroy
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class DestroyProposalCustomField < Rectify::Command
6
+ class DestroyProposalCustomField < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # key - the key to destroy inise proposal_custom_fields
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class DestroyScopedAdmin < Rectify::Command
6
+ class DestroyScopedAdmin < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # key - the key to destroy inside scoped_admins
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class DestroyScopedStyle < Rectify::Command
6
+ class DestroyScopedStyle < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # key - the key to destroy inside scoped_styles
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class RenameScopeLabel < Rectify::Command
6
+ class RenameScopeLabel < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # params - A constraint params
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class UpdateConfig < Rectify::Command
6
+ class UpdateConfig < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - A config form
@@ -27,10 +27,9 @@ module Decidim
27
27
  begin
28
28
  form.attributes.each do |key, val|
29
29
  # ignore nil attributes (must specifically be set to false if necessary)
30
- next unless form.valid_keys.include?(key)
30
+ next unless form.valid_keys.include?(key.to_sym)
31
31
 
32
32
  setting = AwesomeConfig.find_or_initialize_by(var: key, organization: form.current_organization)
33
-
34
33
  setting.value = val.respond_to?(:attributes) ? val.attributes : val
35
34
  setting.save!
36
35
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class UpdateConstraint < Rectify::Command
6
+ class UpdateConstraint < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - A constraint form
@@ -36,7 +36,7 @@ module Decidim
36
36
  attr_reader :form
37
37
 
38
38
  def attributes
39
- form.attributes.filter { |_i, v| v.present? }
39
+ form.attributes.filter { |key, val| key != "id" && val.present? }
40
40
  end
41
41
  end
42
42
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class UpdateCustomRedirect < Rectify::Command
6
+ class UpdateCustomRedirect < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  def initialize(form, item)
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
- class UpdateMenuHack < Rectify::Command
6
+ class UpdateMenuHack < Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  def initialize(form, menu_name)
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ # maintains compatibility with v0.26 which uses Rectify
6
+ if defined? ::Decidim::Command
7
+ class Command < ::Decidim::Command
8
+ end
9
+ else
10
+ class Command < ::Rectify::Command
11
+ end
12
+ end
13
+ end
14
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module DecidimAwesome
5
- class CreateEditorImage < Rectify::Command
5
+ class CreateEditorImage < Command
6
6
  # Creates a blueprint.
7
7
  #
8
8
  # form - The form with the data.
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/concern"
4
+
5
+ module Decidim
6
+ module DecidimAwesome
7
+ module AdminAccountability
8
+ module Admin
9
+ module Filterable
10
+ extend ActiveSupport::Concern
11
+
12
+ included do
13
+ include Decidim::Admin::Filterable
14
+
15
+ helper Decidim::DecidimAwesome::AdminAccountability::Admin::FilterableHelper
16
+
17
+ private
18
+
19
+ def base_query
20
+ collection
21
+ end
22
+
23
+ def filters
24
+ [:role_type_eq, :participatory_space_type_eq]
25
+ end
26
+
27
+ def filters_with_values
28
+ return { admin_role_type: [] } if global?
29
+
30
+ { role_type_eq: role_types, participatory_space_type_eq: participatory_space_types }
31
+ end
32
+
33
+ def dynamically_translated_filters
34
+ [:role_type_eq, :participatory_space_type_eq]
35
+ end
36
+
37
+ def extra_allowed_params
38
+ [:per_page, :admins, :admin_role_type]
39
+ end
40
+
41
+ def translated_role_type_eq(role)
42
+ I18n.t(role, scope: "decidim.decidim_awesome.admin.admin_accountability.roles")
43
+ end
44
+
45
+ def translated_participatory_space_type_eq(item_type)
46
+ item_type.gsub("UserRole", "").safe_constantize&.model_name&.human&.pluralize || item_type
47
+ end
48
+
49
+ def search_field_predicate
50
+ :user_name_or_user_email_cont
51
+ end
52
+
53
+ def participatory_space_types
54
+ @participatory_space_types ||= collection.pluck(:item_type).uniq.sort
55
+ end
56
+
57
+ def role_types
58
+ @role_types ||= PaperTrailVersion.safe_user_roles.map do |role_class|
59
+ role_class.safe_constantize.select(:role).distinct.pluck(:role)
60
+ end.union.flatten.sort
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module AdminAccountability
6
+ module Admin
7
+ module FilterableHelper
8
+ def extra_dropdown_submenu_options_items(_filter, _i18n_scope)
9
+ Decidim.user_roles.sort.map do |role_type|
10
+ link_to(I18n.t(role_type, scope: "decidim.decidim_awesome.admin.admin_accountability.admin_roles"),
11
+ url_for(export_params.merge({ admin_role_type: role_type })))
12
+ end
13
+ end
14
+
15
+ def applied_filters_tags(i18n_ctx)
16
+ if global? && params[:admin_role_type].present?
17
+ content_tag(:span, class: "label secondary") do
18
+ concat "#{i18n_filter_label(:admin_role_type, filterable_i18n_scope_from_ctx(i18n_ctx))}: "
19
+ concat t("decidim.decidim_awesome.admin.admin_accountability.admin_roles.#{params[:admin_role_type]}", default: params[:admin_role_type])
20
+ concat icon_link_to(
21
+ "circle-x",
22
+ url_for(export_params.except(:admin_role_type)),
23
+ t("decidim.admin.actions.cancel"),
24
+ class: "action-icon--remove"
25
+ )
26
+ end
27
+ else
28
+ ransack_params.slice(*filters).map do |filter, value|
29
+ applied_filter_tag(filter, value, filterable_i18n_scope_from_ctx(i18n_ctx))
30
+ end.join.html_safe
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Admin
6
+ class AdminAccountabilityController < DecidimAwesome::Admin::ApplicationController
7
+ include NeedsAwesomeConfig
8
+ include Decidim::DecidimAwesome::AdminAccountability::Admin::Filterable
9
+
10
+ helper_method :admin_actions, :collection, :export_params, :global?, :global_users_missing_date
11
+
12
+ layout "decidim/admin/users"
13
+
14
+ before_action do
15
+ enforce_permission_to :edit_config, :admin_accountability, global: global?
16
+ end
17
+
18
+ def index; end
19
+
20
+ def export
21
+ filters = export_params[:q]
22
+
23
+ Decidim::DecidimAwesome::ExportAdminActionsJob.perform_later(current_user,
24
+ params[:format].to_s,
25
+ admin_actions.ransack(filters).result.ids)
26
+
27
+ redirect_back fallback_location: decidim_admin_decidim_awesome.admin_accountability_path,
28
+ notice: t("decidim.decidim_awesome.admin.admin_accountability.exports.notice")
29
+ end
30
+
31
+ private
32
+
33
+ def admin_actions
34
+ @admin_actions ||= filtered_collection
35
+ end
36
+
37
+ def collection
38
+ @collection = global? ? paginate(admin_role_actions) : paginate(space_role_actions)
39
+ end
40
+
41
+ def space_role_actions
42
+ @space_role_actions ||= Decidim::DecidimAwesome::PaperTrailVersion.space_role_actions(current_organization)
43
+ end
44
+
45
+ def admin_role_actions
46
+ @admin_role_actions ||= Decidim::DecidimAwesome::PaperTrailVersion.in_organization(current_organization).admin_role_actions(params[:admin_role_type])
47
+ end
48
+
49
+ def export_params
50
+ params.permit(:format, :admins, :admin_role_type, q: [:role_type_eq, :user_name_or_user_email_cont, :created_at_gteq, :created_at_lteq])
51
+ end
52
+
53
+ def global?
54
+ params[:admins] == "true"
55
+ end
56
+
57
+ # User traceability was introduced in version 0.24. Users created before that might appear in the list.
58
+ # Returns the first traceability record available if there are users created before.
59
+ # Returns nil otherwise
60
+ def global_users_missing_date
61
+ return unless global?
62
+
63
+ @global_users_missing_date ||= begin
64
+ first_version = Decidim::DecidimAwesome::PaperTrailVersion.where(item_type: "Decidim::UserBaseEntity").last
65
+ first_user = Decidim::User.first
66
+ first_version.created_at if first_user && first_version && (first_version.created_at > first_user.created_at + 1.second)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -10,11 +10,10 @@ module Decidim
10
10
  include NeedsAwesomeConfig
11
11
  helper ConfigConstraintsHelpers
12
12
  helper SystemCheckerHelpers
13
- helper CookiesHelper
14
13
 
15
14
  layout "decidim/admin/decidim_awesome"
16
15
 
17
- helper_method :head, :admin_head, :head_addons, :admin_addons
16
+ helper_method :head, :admin_head, :head_addons, :admin_addons, :legacy_version?
18
17
 
19
18
  def migrate_images
20
19
  Decidim::DecidimAwesome::MigrateLegacyImagesJob.perform_later(current_organization.id)
@@ -24,8 +23,12 @@ module Decidim
24
23
 
25
24
  private
26
25
 
26
+ def legacy_version?
27
+ DecidimAwesome.legacy_version?
28
+ end
29
+
27
30
  def head
28
- @head ||= Nokogiri::HTML(render_template("layouts/decidim/head"))
31
+ @head ||= Nokogiri::HTML(render_template("decidim/decidim_awesome/admin/checks/assets_tester"))
29
32
  end
30
33
 
31
34
  def admin_head