decidim-decidim_awesome 0.8.3 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim-decidim_awesome might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/README.md +54 -45
- data/Rakefile +1 -1
- data/app/commands/decidim/decidim_awesome/admin/create_constraint.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/create_custom_redirect.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/create_menu_hack.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/create_scoped_admin.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/create_scoped_style.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/destroy_constraint.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_admin.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_style.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/rename_scope_label.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/update_config.rb +2 -3
- data/app/commands/decidim/decidim_awesome/admin/update_constraint.rb +2 -2
- data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/update_menu_hack.rb +1 -1
- data/app/commands/decidim/decidim_awesome/command.rb +14 -0
- data/app/commands/decidim/decidim_awesome/create_editor_image.rb +1 -1
- data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable.rb +67 -0
- data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +37 -0
- data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +51 -0
- data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +6 -3
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +2 -0
- data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +2 -0
- data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +2 -0
- data/app/controllers/decidim/decidim_awesome/editor_images_controller.rb +0 -2
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +14 -0
- data/app/forms/decidim/decidim_awesome/admin/menu_form.rb +1 -1
- data/app/forms/decidim/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +26 -8
- data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +12 -8
- data/app/helpers/decidim/decidim_awesome/map_helper.rb +14 -11
- data/app/jobs/decidim/decidim_awesome/export_admin_actions_job.rb +28 -0
- data/app/middleware/decidim/decidim_awesome/current_config.rb +4 -0
- data/app/models/decidim/decidim_awesome/awesome_config.rb +0 -1
- data/app/models/decidim/decidim_awesome/config_constraint.rb +0 -2
- data/app/models/decidim/decidim_awesome/editor_image.rb +0 -3
- data/app/models/decidim/decidim_awesome/paper_trail_version.rb +99 -0
- data/app/packs/entrypoints/decidim_admin_decidim_awesome.js +3 -2
- data/app/packs/images/decidim/decidim_awesome/pokecode-logo.png +0 -0
- data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +7 -7
- data/app/packs/src/decidim/decidim_awesome/admin/check_redirections.js +2 -2
- data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +5 -5
- data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +11 -10
- data/app/packs/src/decidim/decidim_awesome/admin/form_exit_warn.js +1 -0
- data/app/packs/src/decidim/decidim_awesome/admin/user_picker.js +1 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_map/api/fetcher.js +13 -13
- data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +14 -12
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +16 -12
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +3 -3
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +25 -26
- data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +1 -0
- data/app/packs/src/decidim/decidim_awesome/editors/editor.js +33 -12
- data/app/packs/src/decidim/decidim_awesome/forms/autosave.js +8 -12
- data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +36 -27
- data/app/packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js +6 -4
- data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +7 -7
- data/app/packs/src/decidim/decidim_awesome/proposals/images.js +2 -2
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +8 -5
- data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +15 -1
- data/app/permissions/decidim/decidim_awesome/permissions.rb +4 -6
- data/app/presenters/decidim/decidim_awesome/paper_trail_base_presenter.rb +28 -0
- data/app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb +45 -0
- data/app/presenters/decidim/decidim_awesome/role_base_presenter.rb +102 -0
- data/app/presenters/decidim/decidim_awesome/user_entity_presenter.rb +50 -0
- data/app/serializers/decidim/decidim_awesome/paper_trail_version_serializer.rb +37 -0
- data/app/validators/concerns/decidim/decidim_awesome/etiquette_validator_override.rb +41 -0
- data/app/views/decidim/decidim_awesome/admin/admin_accountability/index.html.erb +59 -0
- data/app/views/decidim/decidim_awesome/admin/checks/_assets_tester.html.erb +2 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +82 -2
- data/app/views/decidim/decidim_awesome/admin/shared/_filters_with_date.html.erb +56 -0
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +1 -1
- data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +9 -17
- data/app/views/layouts/decidim/admin/decidim_awesome.html.erb +1 -1
- data/app/views/{v0.25 → v0.27}/layouts/decidim/_head.html.erb +12 -4
- data/config/i18n-tasks.yml +4 -0
- data/config/locales/ca.yml +22 -2
- data/config/locales/cs.yml +7 -2
- data/config/locales/de.yml +20 -1
- data/config/locales/en.yml +90 -1
- data/config/locales/es.yml +2 -2
- data/config/locales/fr.yml +22 -2
- data/config/locales/it.yml +2 -2
- data/config/locales/ja.yml +3 -2
- data/config/locales/nl.yml +1 -1
- data/config/locales/pt-BR.yml +2 -2
- data/db/seeds.rb +1 -1
- data/lib/decidim/decidim_awesome/admin_engine.rb +15 -1
- data/lib/decidim/decidim_awesome/awesome.rb +55 -1
- data/lib/decidim/decidim_awesome/checksums.yml +13 -3
- data/lib/decidim/decidim_awesome/config.rb +14 -14
- data/lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb +1 -1
- data/lib/decidim/decidim_awesome/engine.rb +36 -9
- data/lib/decidim/decidim_awesome/iframe_component/component.rb +2 -1
- data/lib/decidim/decidim_awesome/menu_hacker.rb +6 -0
- data/lib/decidim/decidim_awesome/system_checker.rb +2 -0
- data/lib/decidim/decidim_awesome/test/factories.rb +7 -0
- data/lib/decidim/decidim_awesome/test/initializer.rb +10 -2
- data/lib/decidim/decidim_awesome/test/shared_examples/action_log_presenter_examples.rb +61 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +7 -4
- data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +2 -2
- data/lib/decidim/decidim_awesome/version.rb +2 -2
- data/lib/tasks/decidim_awesome_active_storage_migrations_tasks.rake +1 -3
- data/package.json +21 -164
- metadata +39 -39
- data/app/packs/images/decidim/decidim_awesome/platoniq-logo.png +0 -0
- data/app/packs/src/vendor/image-resize.min.js +0 -1
- data/app/packs/src/vendor/image-upload.min.js +0 -6
- data/app/packs/src/vendor/leaflet.featuregroup.subgroup.js +0 -184
- /data/app/views/{v0.25 → v0.27}/decidim/proposals/collaborative_drafts/_show.html.erb +0 -0
- /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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ada19fbdb65b2b209a2b65791d392684413373d0ab9c5ed82d01c68c5e632e2
|
4
|
+
data.tar.gz: 1f255d53965277523841e002fe45bdf524f5b055bf8ff94f9df0b1f5aaf7e907
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58a26aa8f0b5da17b1628fcc22ad23a452389ddc53376401220d007a2eb2f2f7a13a3801235d9596c10f64fd3853df69ebe5f7777585daf305faf0ebb1573dd6
|
7
|
+
data.tar.gz: bf9a64bb47fcda049f8ed317aa5c0658977a7b38e1d937054c80e41dff0f2daef3b58920468c0e0f569fc97eacca3075689c694f45f0bec9039485c0dfd89ec0
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,38 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
=========
|
3
3
|
|
4
|
+
v0.9.1
|
5
|
+
------
|
6
|
+
|
7
|
+
Compatibility:
|
8
|
+
- Decidim v0.27.x
|
9
|
+
- Decidim v0.26.x
|
10
|
+
|
11
|
+
Features:
|
12
|
+
- Fixes for the Awesome Map
|
13
|
+
- Added Admin Accountability feature
|
14
|
+
|
15
|
+
v0.9.0
|
16
|
+
------
|
17
|
+
|
18
|
+
Compatibility:
|
19
|
+
- Decidim v0.27.x
|
20
|
+
- Decidim v0.26.x
|
21
|
+
|
22
|
+
Features:
|
23
|
+
- Upgrade 0.27 version
|
24
|
+
|
25
|
+
v0.8.4
|
26
|
+
------
|
27
|
+
|
28
|
+
Compatibility:
|
29
|
+
- Decidim v0.26.x
|
30
|
+
- Decidim v0.25.x
|
31
|
+
|
32
|
+
Features:
|
33
|
+
- Feature: Override validation rules for title and body in proposals, with constrains available
|
34
|
+
- Improve loading process to facilitate development
|
35
|
+
|
4
36
|
v0.8.3
|
5
37
|
------
|
6
38
|
|
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# Decidim::DecidimAwesome
|
2
2
|
|
3
|
-
[![[CI]
|
4
|
-
[![
|
5
|
-
[![
|
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
|
-
|
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](/
|
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,7 @@ 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.x | 0.26.x, 0.27.x |
|
193
213
|
| 0.8.x | 0.25.x, 0.26.x |
|
194
214
|
| 0.7.x | 0.23.x, 0.24.x |
|
195
215
|
| 0.6.x | 0.22.x, 0.23.x |
|
@@ -314,22 +334,33 @@ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake test_
|
|
314
334
|
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rspec
|
315
335
|
```
|
316
336
|
|
317
|
-
However, this project
|
337
|
+
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
338
|
|
319
|
-
You can run run
|
339
|
+
You can run run tests against the legacy Decidim versions by using:
|
320
340
|
|
321
341
|
```bash
|
322
|
-
|
323
|
-
|
324
|
-
|
342
|
+
export DATABASE_USERNAME=<username>
|
343
|
+
export DATABASE_PASSWORD=<password>
|
344
|
+
RBENV_VERSION=2.7.6 BUNDLE_GEMFILE=Gemfile.legacy bundle
|
345
|
+
RBENV_VERSION=2.7.6 BUNDLE_GEMFILE=Gemfile.legacy bundle exec rake test_app
|
346
|
+
RBENV_VERSION=2.7.6 BUNDLE_GEMFILE=Gemfile.legacy bundle exec rspec
|
325
347
|
```
|
326
348
|
|
327
|
-
|
349
|
+
For convenience, you can use the scripts `bin/rspec` and `bin/rspec-legacy` to run tests against one or the other version:
|
328
350
|
|
351
|
+
```bash
|
352
|
+
bin/rspec spec/
|
353
|
+
bin/rspec-legacy spec/
|
329
354
|
```
|
330
|
-
|
331
|
-
|
332
|
-
|
355
|
+
|
356
|
+
- Rbenv is required for this script to work.
|
357
|
+
|
358
|
+
> **NOTE:** Remember to reset the database when changing between tests:
|
359
|
+
> ```bash
|
360
|
+
> bin/rspec --reset
|
361
|
+
> bin/rspec-legacy --reset
|
362
|
+
> ```
|
363
|
+
|
333
364
|
|
334
365
|
Note that the database user has to have rights to create and drop a database in
|
335
366
|
order to create the dummy test app database.
|
@@ -342,35 +373,13 @@ commands shown above.
|
|
342
373
|
|
343
374
|
### Test code coverage
|
344
375
|
|
345
|
-
|
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
|
376
|
+
Code coverage report is generated automatically in a folder named `coverage` in the project root which contains
|
353
377
|
the code coverage report.
|
354
378
|
|
355
|
-
|
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
|
379
|
+
```bash
|
380
|
+
firefox coverage/index.html
|
370
381
|
```
|
371
382
|
|
372
|
-
Where 0.XX is the supported version that needs to be updated.
|
373
|
-
|
374
383
|
### Localization
|
375
384
|
|
376
385
|
If you would like to see this module in your own language, you can help with its
|
@@ -384,4 +393,4 @@ This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.
|
|
384
393
|
|
385
394
|
## Credits
|
386
395
|
|
387
|
-
This plugin
|
396
|
+
This plugin maintainted by ![PokeCode](app/packs/images/decidim/decidim_awesome/pokecode-logo.png)
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module DecidimAwesome
|
5
5
|
module Admin
|
6
|
-
class UpdateConfig <
|
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 <
|
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 { |
|
39
|
+
form.attributes.filter { |key, val| key != "id" && val.present? }
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -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
|
data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable.rb
ADDED
@@ -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,51 @@
|
|
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?
|
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 ||= paginate(global? ? PaperTrailVersion.admin_role_actions(params[:admin_role_type]) : PaperTrailVersion.space_role_actions)
|
39
|
+
end
|
40
|
+
|
41
|
+
def export_params
|
42
|
+
params.permit(:format, :admins, :admin_role_type, q: [:role_type_eq, :user_name_or_user_email_cont, :created_at_gteq, :created_at_lteq])
|
43
|
+
end
|
44
|
+
|
45
|
+
def global?
|
46
|
+
params[:admins] == "true"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
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("
|
31
|
+
@head ||= Nokogiri::HTML(render_template("decidim/decidim_awesome/admin/checks/assets_tester"))
|
29
32
|
end
|
30
33
|
|
31
34
|
def admin_head
|
@@ -88,9 +88,11 @@ module Decidim
|
|
88
88
|
DecidimAwesome.config.keys
|
89
89
|
end
|
90
90
|
|
91
|
+
# rubocop:disable Style/OpenStructUse
|
91
92
|
def users_for(ids_list)
|
92
93
|
Decidim::User.where(id: ids_list).map { |user| OpenStruct.new(text: format_user_name(user), id: user.id) }
|
93
94
|
end
|
95
|
+
# rubocop:enable Style/OpenStructUse
|
94
96
|
|
95
97
|
def format_user_name(user)
|
96
98
|
"<span class='#{"is-admin" if user.read_attribute("admin")}'>#{user.name} (@#{user.nickname} - #{user.email})</span>"
|
@@ -75,11 +75,13 @@ module Decidim
|
|
75
75
|
origin, item = current_config.find { |origin, _| md5(origin) == params[:id] }
|
76
76
|
raise ActiveRecord::RecordNotFound unless item
|
77
77
|
|
78
|
+
# rubocop:disable Style/OpenStructUse
|
78
79
|
OpenStruct.new(
|
79
80
|
origin: origin,
|
80
81
|
destination: item["destination"],
|
81
82
|
active: item["active"]
|
82
83
|
)
|
84
|
+
# rubocop:enable Style/OpenStructUse
|
83
85
|
end
|
84
86
|
|
85
87
|
def current_config
|