decidim-decidim_awesome 0.11.1 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +54 -2
- data/app/cells/concerns/decidim/decidim_awesome/proposal_l_cell_override.rb +6 -24
- data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +0 -4
- data/app/cells/decidim/decidim_awesome/voting/proposal_metadata_cell.rb +18 -3
- data/app/commands/concerns/decidim/decidim_awesome/proposals/create_proposal_override.rb +2 -2
- data/app/commands/concerns/decidim/decidim_awesome/proposals/update_proposal_override.rb +2 -2
- data/app/commands/concerns/decidim/decidim_awesome/system/register_organization_override.rb +29 -0
- data/app/commands/concerns/decidim/decidim_awesome/system/update_organization_override.rb +35 -0
- data/app/commands/concerns/decidim/decidim_awesome/update_account_override.rb +30 -0
- data/app/commands/decidim/decidim_awesome/admin/create_scoped_style.rb +3 -2
- data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_style.rb +6 -4
- data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +3 -2
- data/app/controllers/concerns/decidim/decidim_awesome/check_login_authorizations.rb +60 -0
- data/app/controllers/concerns/decidim/decidim_awesome/needs_awesome_config.rb +0 -2
- data/app/controllers/concerns/decidim/decidim_awesome/proposals/memoize_extra_fields.rb +23 -0
- data/app/controllers/concerns/decidim/decidim_awesome/proposals/orderable_override.rb +9 -22
- data/app/controllers/concerns/decidim/decidim_awesome/use_user_time_zone.rb +32 -0
- data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +7 -7
- data/app/controllers/decidim/decidim_awesome/admin/admin_authorizations_controller.rb +122 -0
- data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +1 -1
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +7 -1
- data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +5 -1
- data/app/controllers/decidim/decidim_awesome/admin/maintenance_controller.rb +1 -1
- data/app/controllers/decidim/decidim_awesome/admin/scoped_styles_controller.rb +12 -4
- data/app/controllers/decidim/decidim_awesome/required_authorizations_controller.rb +58 -0
- data/app/forms/concerns/decidim/decidim_awesome/account_form_override.rb +25 -0
- data/app/forms/concerns/decidim/decidim_awesome/system/organization_form_override.rb +34 -0
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +41 -8
- data/app/helpers/decidim/decidim_awesome/map_helper.rb +28 -26
- data/app/models/decidim/decidim_awesome/paper_trail_version.rb +5 -1
- data/app/overrides/decidim/account/show/add_timezone_select.html.erb.deface +3 -0
- data/app/overrides/decidim/admin/officializations/index/add_modal.html.erb.deface +3 -0
- data/app/overrides/decidim/admin/officializations/index/add_td.html.erb.deface +5 -0
- data/app/overrides/decidim/admin/officializations/index/add_th.html.erb.deface +5 -0
- data/app/overrides/decidim/system/organizations/_advanced_settings/add_awesome_config.html.erb.deface +9 -0
- data/app/overrides/layouts/decidim/_head/add_awesome_tags.html.erb.deface +1 -1
- data/app/overrides/layouts/decidim/admin/_header/add_awesome_custom_styles.html.erb.deface +3 -0
- data/app/overrides/layouts/decidim/admin/_header/add_awesome_tags.html.erb.deface +1 -0
- data/app/packs/src/decidim/decidim_awesome/admin/proposal_sortings.js +0 -5
- data/app/packs/src/decidim/decidim_awesome/admin/verification_selects.js +21 -0
- data/app/packs/src/decidim/decidim_awesome/admin/verifications.js +43 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +1 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_admin_global.js +1 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/verifications.scss +99 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +1 -0
- data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +42 -11
- data/app/permissions/decidim/decidim_awesome/permissions.rb +7 -0
- data/app/presenters/decidim/decidim_awesome/admin_log/component_presenter_override.rb +3 -5
- data/app/presenters/decidim/decidim_awesome/admin_log/user_presenter_override.rb +46 -0
- data/app/views/decidim/decidim_awesome/account/_timezone_select.html.erb +3 -0
- data/app/views/decidim/decidim_awesome/admin/admin_authorizations/authorization.html.erb +20 -0
- data/app/views/decidim/decidim_awesome/admin/admin_authorizations/callout.html.erb +3 -0
- data/app/views/decidim/decidim_awesome/admin/admin_authorizations/conflict.html.erb +5 -0
- data/app/views/decidim/decidim_awesome/admin/admin_authorizations/edit.html.erb +41 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_scoped_admin_styles.html.erb +1 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_scoped_styles.html.erb +48 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_surveys.html.erb +8 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_verifications.html.erb +15 -0
- data/app/views/decidim/decidim_awesome/admin/constraints/no_permissions.html.erb +6 -0
- data/app/views/decidim/decidim_awesome/admin/officializations/_participants_td.html.erb +25 -0
- data/app/views/decidim/decidim_awesome/admin/officializations/_participants_th.html.erb +1 -0
- data/app/views/decidim/decidim_awesome/admin/officializations/_verification_modal.html.erb +9 -0
- data/app/views/decidim/decidim_awesome/required_authorizations/index.html.erb +66 -0
- data/app/views/decidim/decidim_awesome/system/organizations/_admin_allowed_authorizations.html.erb +5 -0
- data/app/views/layouts/decidim/decidim_awesome/_custom_styles.html.erb +1 -1
- data/app/views/layouts/decidim/decidim_awesome/admin/_custom_styles.html.erb +3 -0
- data/app/views/layouts/decidim/decidim_awesome/admin/admin_authorizations.html.erb +7 -0
- data/config/i18n-tasks.yml +6 -0
- data/config/locales/ca.yml +172 -10
- data/config/locales/cs.yml +169 -6
- data/config/locales/de.yml +88 -5
- data/config/locales/en.yml +115 -1
- data/config/locales/es.yml +173 -10
- data/config/locales/eu.yml +617 -23
- data/config/locales/fr.yml +121 -7
- data/config/locales/hu.yml +10 -4
- data/config/locales/it.yml +14 -6
- data/config/locales/ja.yml +167 -5
- data/config/locales/lt.yml +0 -4
- data/config/locales/nl.yml +7 -4
- data/config/locales/pt-BR.yml +14 -7
- data/config/locales/pt-PT.yml +0 -1
- data/config/locales/ro-RO.yml +11 -4
- data/config/locales/sv.yml +15 -4
- data/lib/decidim/decidim_awesome/admin_engine.rb +2 -0
- data/lib/decidim/decidim_awesome/authorizator.rb +34 -0
- data/lib/decidim/decidim_awesome/awesome.rb +58 -5
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +48 -19
- data/lib/decidim/decidim_awesome/checksums.yml +10 -0
- data/lib/decidim/decidim_awesome/engine.rb +20 -4
- data/lib/decidim/decidim_awesome/menu.rb +45 -9
- data/lib/decidim/decidim_awesome/request_memoizer.rb +16 -0
- data/lib/decidim/decidim_awesome/test/factories.rb +0 -4
- data/lib/decidim/decidim_awesome/test/initializer.rb +4 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +1 -1
- data/lib/decidim/decidim_awesome/test/shared_examples/custom_styles_examples.rb +156 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +26 -10
- data/lib/decidim/decidim_awesome/version.rb +1 -1
- data/package.json +6 -5
- metadata +42 -7
- data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca78262a57db332a236230c15e2584c2dcbc1f5ee6055400b7fc187fbb24dfae
|
4
|
+
data.tar.gz: 48a4aa2ca9b10d8f9c6a8b4a6dc3e8084360e87398ad1c5160a87e9569e18060
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e59ee2965fc55d0e8874a2745508ef10d15fe8d2582e5a1dad84f79810d0b39d4f58124f637c88a7100eaca171e9a59237f792f7acce7485ceae8de8b05f5ee5
|
7
|
+
data.tar.gz: e66c77623b540ed323d083d2d68967e033dc3bfed826ef82df9db5c40832fab46253ac5d3840a38226aa547cee7ca33ba5a6a4caf76b13e2612e983a6ddc5b1b
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,27 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
=========
|
3
3
|
|
4
|
+
v0.11.3
|
5
|
+
-------
|
6
|
+
Compatibility:
|
7
|
+
- Decidim v0.28.x
|
8
|
+
|
9
|
+
Features:
|
10
|
+
- Added user time zones in account settings
|
11
|
+
- Added custom styles for the admin panel
|
12
|
+
- Added Verification tweaks
|
13
|
+
- Added Admin manual verifications
|
14
|
+
|
15
|
+
v0.11.2
|
16
|
+
-------
|
17
|
+
|
18
|
+
Compatibility:
|
19
|
+
- Decidim v0.28.x
|
20
|
+
|
21
|
+
Features:
|
22
|
+
- SQL vulnerability fix for admin accountability
|
23
|
+
- Private fields proposal draft update fix
|
24
|
+
|
4
25
|
v0.11.1
|
5
26
|
------
|
6
27
|
|
data/README.md
CHANGED
@@ -83,9 +83,15 @@ With this feature you can have a support chat in Decidim. It is linked to a [Tel
|
|
83
83
|
|
84
84
|
#### 8. Custom CSS applied only according scoped restrictions
|
85
85
|
|
86
|
-
|
86
|
+
##### 8.1 Public styles
|
87
|
+
With this feature you can create directly in the admin a CSS snipped that is only applied in the public frontend, in a particular assembly or even a single proposal!
|
87
88
|
|
88
|
-

|
90
|
+
|
91
|
+
##### 8.2 Admin styles
|
92
|
+
With this feature you can create directly in the admin a CSS snipped that is only applied in the admin panel, in a particular assembly or even a single proposal!
|
93
|
+
|
94
|
+

|
89
95
|
|
90
96
|
#### 9. Change the main menu of Decidim entirely!
|
91
97
|
|
@@ -379,6 +385,46 @@ This menu will show if there's any data older than 6 months (configurable) and w
|
|
379
385
|
|
380
386
|

|
381
387
|
|
388
|
+
#### 19. User custom timezone
|
389
|
+
|
390
|
+
If your organization spans across multiple timezones, you can enable this feature under the "Surveys & Forms" section in the Awesome admin panel. This allows users to set their own timezone, which will be used to display dates and times throughout the platform according to their preference.
|
391
|
+
|
392
|
+

|
393
|
+
|
394
|
+
#### 20. Mandatory verifications
|
395
|
+
|
396
|
+
This feature allows admins to enforce mandatory verifications for users before they can access the platform. Admins can configure which verifications are required.
|
397
|
+
|
398
|
+
Admins can manage these settings in the Awesome admin panel under the "Verifications" section.
|
399
|
+
|
400
|
+

|
401
|
+

|
402
|
+
|
403
|
+
Note that some pages are allowed, you can even configure which controller are allowed by creating an initializer ("required_authorizations" and "authorizations" are always allowed):
|
404
|
+
|
405
|
+
```ruby
|
406
|
+
# config/initializers/decidim_awesome.rb
|
407
|
+
|
408
|
+
Decidim::DecidimAwesome.configure do |config|
|
409
|
+
# default controllers are "account" and "pages"
|
410
|
+
config.force_authorization_allowed_controller_names = %w(account pages homepage)
|
411
|
+
```
|
412
|
+
|
413
|
+
#### 21. Manual verifications
|
414
|
+
|
415
|
+
The admin will be allowed to manually authorize users using the methods specified in the `/system` admin section.
|
416
|
+
Currently, only form based handlers are supported (Direct methods).
|
417
|
+
Admins can manually override or verify users in the participants list but they still have to fulfill the requirements of the verifier (although they will be allowed to force the authorization even if some of them fails).
|
418
|
+
|
419
|
+
Admin logs are also created in each action for accountability.
|
420
|
+
|
421
|
+
System configuration:
|
422
|
+
|
423
|
+

|
424
|
+

|
425
|
+

|
426
|
+

|
427
|
+
|
382
428
|
#### To be continued...
|
383
429
|
|
384
430
|
We're not done! Please check the [issues](/decidim-ice/decidim-module-decidim_awesome/issues) (and participate) to see what's on our mind
|
@@ -401,6 +447,12 @@ bin/rails decidim:upgrade
|
|
401
447
|
bin/rails db:migrate
|
402
448
|
```
|
403
449
|
|
450
|
+
> In production mode you must also precompile the assets:
|
451
|
+
>
|
452
|
+
> ```
|
453
|
+
> bin/rails assets:precompile
|
454
|
+
> ```
|
455
|
+
|
404
456
|
Go to `yourdomain/admin/decidim_awesome` and start tweaking things!
|
405
457
|
|
406
458
|
> **EXPERTS ONLY**
|
@@ -8,36 +8,18 @@ module Decidim
|
|
8
8
|
included do
|
9
9
|
private
|
10
10
|
|
11
|
+
alias_method :decidim_original_cache_hash, :cache_hash
|
12
|
+
|
11
13
|
def metadata_cell
|
12
|
-
awesome_voting_manifest_for(resource&.component)&.proposal_metadata_cell.presence || "decidim/proposals/proposal_metadata"
|
14
|
+
@metadata_cell ||= awesome_voting_manifest_for(resource&.component)&.proposal_metadata_cell.presence || "decidim/proposals/proposal_metadata"
|
13
15
|
end
|
14
16
|
|
15
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
16
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
17
17
|
def cache_hash
|
18
|
-
|
19
|
-
|
20
|
-
hash << model.cache_key_with_version
|
21
|
-
hash << model.proposal_votes_count
|
22
|
-
hash << model.extra_fields&.reload&.vote_weight_totals
|
23
|
-
hash << model.endorsements_count
|
24
|
-
hash << model.comments_count
|
25
|
-
hash << Digest::MD5.hexdigest(model.component.cache_key_with_version)
|
26
|
-
hash << Digest::MD5.hexdigest(resource_image_path) if resource_image_path
|
27
|
-
hash << render_space? ? 1 : 0
|
28
|
-
if current_user
|
29
|
-
hash << current_user.cache_key_with_version
|
30
|
-
hash << current_user.follows?(model) ? 1 : 0
|
31
|
-
end
|
32
|
-
hash << model.follows_count
|
33
|
-
hash << Digest::MD5.hexdigest(model.authors.map(&:cache_key_with_version).to_s)
|
34
|
-
hash << (model.must_render_translation?(model.organization) ? 1 : 0) if model.respond_to?(:must_render_translation?)
|
35
|
-
hash << model.component.participatory_space.active_step.id if model.component.participatory_space.try(:active_step)
|
18
|
+
all_extra_fields = memoize("extra_fields")
|
19
|
+
extra_fields = all_extra_fields ? all_extra_fields[resource.id] : resource.extra_fields
|
36
20
|
|
37
|
-
|
21
|
+
@cache_hash ||= "#{decidim_original_cache_hash}#{Decidim.cache_key_separator}#{extra_fields&.vote_weight_totals}"
|
38
22
|
end
|
39
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
40
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
41
23
|
end
|
42
24
|
end
|
43
25
|
end
|
@@ -12,7 +12,7 @@ module Decidim
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def current_vote
|
15
|
-
@current_vote ||=
|
15
|
+
@current_vote ||= vote_for(current_user) if current_user
|
16
16
|
end
|
17
17
|
|
18
18
|
def user_voted_weight
|
@@ -24,7 +24,7 @@ module Decidim
|
|
24
24
|
weights = [3, 2, 1]
|
25
25
|
weights << 0 if resource.component.settings.voting_cards_show_abstain
|
26
26
|
weights.index_with do |weight|
|
27
|
-
|
27
|
+
weight_count_for(weight)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -38,7 +38,7 @@ module Decidim
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def weight_count_item
|
41
|
-
return unless resource.respond_to?(:weight_count)
|
41
|
+
# return unless resource.respond_to?(:weight_count)
|
42
42
|
return if resource.component.current_settings.votes_hidden?
|
43
43
|
return if resource&.rejected? || resource&.withdrawn?
|
44
44
|
|
@@ -48,6 +48,21 @@ module Decidim
|
|
48
48
|
data_attributes: all_weights.transform_keys { |num| "weight-#{num}" }
|
49
49
|
}
|
50
50
|
end
|
51
|
+
|
52
|
+
def vote_for(user)
|
53
|
+
user_votes = memoize("user_votes")
|
54
|
+
return user_votes[resource.id] if user_votes
|
55
|
+
|
56
|
+
resource.votes.find_by(author: user)
|
57
|
+
end
|
58
|
+
|
59
|
+
def weight_count_for(weight)
|
60
|
+
all_extra_fields = memoize("extra_fields")
|
61
|
+
extra_fields = all_extra_fields ? all_extra_fields[resource.id] : resource.extra_fields
|
62
|
+
return 0 unless extra_fields
|
63
|
+
|
64
|
+
extra_fields.vote_weight_totals[weight.to_s] || 0
|
65
|
+
end
|
51
66
|
end
|
52
67
|
end
|
53
68
|
end
|
@@ -15,10 +15,10 @@ module Decidim
|
|
15
15
|
alias_method :decidim_original_create_proposal, :create_proposal
|
16
16
|
|
17
17
|
def create_proposal
|
18
|
-
|
18
|
+
decidim_original_create_proposal
|
19
19
|
# Update the proposal with the private body, to
|
20
20
|
# avoid tracebility on private fields.
|
21
|
-
|
21
|
+
@proposal.update_private_body!(form.private_body) if form.private_body.present?
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module System
|
6
|
+
module RegisterOrganizationOverride
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
private
|
11
|
+
|
12
|
+
alias_method :decidim_create_organization, :create_organization
|
13
|
+
|
14
|
+
def create_organization
|
15
|
+
@organization = decidim_create_organization
|
16
|
+
if form.clean_awesome_admins_available_authorizations.present?
|
17
|
+
AwesomeConfig.create!(
|
18
|
+
var: :admins_available_authorizations,
|
19
|
+
organization: @organization,
|
20
|
+
value: form.clean_awesome_admins_available_authorizations
|
21
|
+
)
|
22
|
+
end
|
23
|
+
@organization
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module System
|
6
|
+
module UpdateOrganizationOverride
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
private
|
11
|
+
|
12
|
+
alias_method :decidim_original_save_organization, :save_organization
|
13
|
+
|
14
|
+
def save_organization
|
15
|
+
decidim_original_save_organization
|
16
|
+
if form.clean_awesome_admins_available_authorizations.present?
|
17
|
+
add_awesome_configs!
|
18
|
+
elsif awesome_config&.persisted?
|
19
|
+
awesome_config.destroy!
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_awesome_configs!
|
24
|
+
awesome_config.value = form.clean_awesome_admins_available_authorizations
|
25
|
+
awesome_config.save!
|
26
|
+
end
|
27
|
+
|
28
|
+
def awesome_config
|
29
|
+
@awesome_config ||= AwesomeConfig.find_or_initialize_by(var: :admins_available_authorizations, organization: @organization)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module UpdateAccountOverride
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
alias_method :decidim_update_personal_data, :update_personal_data
|
10
|
+
alias_method :decidim_send_update_summary!, :send_update_summary!
|
11
|
+
|
12
|
+
def update_personal_data
|
13
|
+
decidim_update_personal_data
|
14
|
+
return if @form.user_time_zone.blank?
|
15
|
+
|
16
|
+
@user.extended_data ||= {}
|
17
|
+
if @form.user_time_zone == @user.organization.time_zone
|
18
|
+
@user.extended_data.delete("time_zone")
|
19
|
+
else
|
20
|
+
@user.extended_data["time_zone"] = @form.user_time_zone
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def send_update_summary!(changes)
|
25
|
+
decidim_send_update_summary!(changes - ["extended_data"])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -6,9 +6,10 @@ module Decidim
|
|
6
6
|
class CreateScopedStyle < Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
|
-
def initialize(organization)
|
9
|
+
def initialize(organization, config_var = :scoped_styles)
|
10
10
|
@organization = organization
|
11
11
|
@ident = rand(36**8).to_s(36)
|
12
|
+
@config_var = config_var
|
12
13
|
end
|
13
14
|
|
14
15
|
# Executes the command. Broadcasts these events:
|
@@ -18,7 +19,7 @@ module Decidim
|
|
18
19
|
#
|
19
20
|
# Returns nothing.
|
20
21
|
def call
|
21
|
-
styles = AwesomeConfig.find_or_initialize_by(var:
|
22
|
+
styles = AwesomeConfig.find_or_initialize_by(var: @config_var, organization: @organization)
|
22
23
|
styles.value = {} unless styles.value.is_a? Hash
|
23
24
|
# TODO: prevent (unlikely) colisions with exisiting values
|
24
25
|
styles.value[@ident] = ""
|
@@ -6,11 +6,12 @@ module Decidim
|
|
6
6
|
class DestroyScopedStyle < Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
|
-
# key - the key to destroy inside scoped_styles
|
9
|
+
# key - the key to destroy inside scoped_styles/scoped_admin_styles
|
10
10
|
# organization
|
11
|
-
def initialize(key, organization)
|
11
|
+
def initialize(key, organization, config_var = :scoped_styles)
|
12
12
|
@key = key
|
13
13
|
@organization = organization
|
14
|
+
@config_var = config_var
|
14
15
|
end
|
15
16
|
|
16
17
|
# Executes the command. Broadcasts these events:
|
@@ -20,14 +21,15 @@ module Decidim
|
|
20
21
|
#
|
21
22
|
# Returns nothing.
|
22
23
|
def call
|
23
|
-
styles = AwesomeConfig.find_by(var:
|
24
|
+
styles = AwesomeConfig.find_by(var: @config_var, organization: @organization)
|
24
25
|
return broadcast(:invalid, "Not a hash") unless styles&.value.is_a? Hash
|
25
26
|
return broadcast(:invalid, "#{key} key invalid") unless styles.value.has_key?(@key)
|
26
27
|
|
27
28
|
styles.value.except!(@key)
|
28
29
|
styles.save!
|
29
30
|
# remove constrains associated (a new config var is generated automatically, by removing it, it will trigger destroy on dependents)
|
30
|
-
constraint =
|
31
|
+
constraint = @config_var == :scoped_styles ? :scoped_style : :scoped_admin_style
|
32
|
+
constraint = AwesomeConfig.find_by(var: "#{constraint}_#{@key}", organization: @organization)
|
31
33
|
constraint.destroy! if constraint.present?
|
32
34
|
|
33
35
|
broadcast(:ok, @key)
|
@@ -13,10 +13,11 @@ module Decidim
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def applied_filters_tags(i18n_ctx)
|
16
|
-
|
16
|
+
admin_role_type = PaperTrailVersion.safe_admin_role_type(params[:admin_role_type])
|
17
|
+
if global? && admin_role_type.present?
|
17
18
|
content_tag(:span, class: "label secondary") do
|
18
19
|
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.#{
|
20
|
+
concat t("decidim.decidim_awesome.admin.admin_accountability.admin_roles.#{admin_role_type}", default: admin_role_type)
|
20
21
|
concat icon_link_to(
|
21
22
|
"close-circle-line",
|
22
23
|
url_for(export_params.except(:admin_role_type)),
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module CheckLoginAuthorizations
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
include ::Decidim::DecidimAwesome::NeedsAwesomeConfig
|
10
|
+
before_action :check_required_login_authorizations
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def check_required_login_authorizations
|
16
|
+
return unless user_signed_in?
|
17
|
+
return unless current_user.confirmed?
|
18
|
+
return if current_user.blocked?
|
19
|
+
return if allowed_controllers.include?(controller_name)
|
20
|
+
|
21
|
+
unless user_is_authorized?
|
22
|
+
flash[:alert] = I18n.t("decidim.decidim_awesome.session.authorization_is_required",
|
23
|
+
authorizations: required_authorizations.map(&:fullname).join(", "))
|
24
|
+
redirect_to decidim_decidim_awesome.required_authorizations_path(redirect_url: request.fullpath)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def user_is_authorized?
|
29
|
+
return true if required_authorizations.blank?
|
30
|
+
|
31
|
+
@user_is_authorized ||= if awesome_config[:force_authorization_with_any_method]
|
32
|
+
current_authorizations.any?
|
33
|
+
else
|
34
|
+
current_authorizations.count == required_authorizations.count
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def required_authorizations
|
39
|
+
return unless awesome_config[:force_authorization_after_login].is_a?(Array)
|
40
|
+
|
41
|
+
@required_authorizations ||= Decidim::Verifications::Adapter.from_collection(
|
42
|
+
awesome_config[:force_authorization_after_login] & current_organization.available_authorizations & Decidim.authorization_workflows.map(&:name)
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def current_authorizations
|
47
|
+
@current_authorizations ||= Decidim::Verifications::Authorizations.new(
|
48
|
+
organization: current_organization,
|
49
|
+
user: current_user,
|
50
|
+
name: required_authorizations.map(&:name),
|
51
|
+
granted: true
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
def allowed_controllers
|
56
|
+
%w(required_authorizations authorizations upload_validations timeouts editor_images locales) + awesome_config[:force_authorization_allowed_controller_names].to_a
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Proposals
|
6
|
+
module MemoizeExtraFields
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
include Decidim::DecidimAwesome::RequestMemoizer
|
9
|
+
|
10
|
+
included do
|
11
|
+
alias_method :decidim_original_index, :index
|
12
|
+
|
13
|
+
def index
|
14
|
+
decidim_original_index
|
15
|
+
|
16
|
+
memoize("extra_fields") { Decidim::DecidimAwesome::ProposalExtraField.where(proposal: @proposals).index_by(&:decidim_proposal_id) }
|
17
|
+
memoize("user_votes") { Decidim::Proposals::ProposalVote.where(proposal: proposals, author: current_user).index_by(&:decidim_proposal_id) if current_user }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -14,6 +14,8 @@ module Decidim
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
+
alias_method :decidim_original_reorder, :reorder
|
18
|
+
|
17
19
|
# read order from session if available
|
18
20
|
def order
|
19
21
|
@order ||= detect_order(session[:order]) || default_order
|
@@ -31,38 +33,23 @@ module Decidim
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
35
36
|
def reorder(proposals)
|
37
|
+
title_by_locale = Arel.sql(proposals.sanitize_sql(["decidim_proposals_proposals.title->>? #{collation}", locale]))
|
38
|
+
title_by_machine_translation = Arel.sql(proposals.sanitize_sql(["decidim_proposals_proposals.title->'machine_translations'->>? #{collation}", locale]))
|
39
|
+
title_by_default_locale = Arel.sql(proposals.sanitize_sql(["decidim_proposals_proposals.title->>? #{collation}", default_locale]))
|
36
40
|
case order
|
37
41
|
when "az"
|
38
|
-
proposals.order(
|
39
|
-
decidim_proposals_proposals.title->'machine_translations'->>'#{locale}',
|
40
|
-
decidim_proposals_proposals.title->>'#{default_locale}') #{collation} ASC"))
|
42
|
+
proposals.order(title_by_locale => :asc, title_by_machine_translation => :asc, title_by_default_locale => :asc)
|
41
43
|
when "za"
|
42
|
-
proposals.order(
|
43
|
-
decidim_proposals_proposals.title->'machine_translations'->>'#{locale}',
|
44
|
-
decidim_proposals_proposals.title->>'#{default_locale}') #{collation} DESC"))
|
44
|
+
proposals.order(title_by_locale => :desc, title_by_machine_translation => :desc, title_by_default_locale => :desc)
|
45
45
|
when "supported_first"
|
46
46
|
proposals.joins(my_votes_join).group(:id).order(Arel.sql("COUNT(decidim_proposals_proposal_votes.id) DESC"))
|
47
47
|
when "supported_last"
|
48
48
|
proposals.joins(my_votes_join).group(:id).order(Arel.sql("COUNT(decidim_proposals_proposal_votes.id) ASC"))
|
49
|
-
|
50
|
-
proposals
|
51
|
-
when "most_endorsed"
|
52
|
-
proposals.order(endorsements_count: :desc)
|
53
|
-
when "most_followed"
|
54
|
-
proposals.left_joins(:follows).group(:id).order(Arel.sql("COUNT(decidim_follows.id) DESC"))
|
55
|
-
when "most_voted"
|
56
|
-
proposals.order(proposal_votes_count: :desc)
|
57
|
-
when "random"
|
58
|
-
proposals.order_randomly(random_seed)
|
59
|
-
when "recent"
|
60
|
-
proposals.order(published_at: :desc)
|
61
|
-
when "with_more_authors"
|
62
|
-
proposals.order(coauthorships_count: :desc)
|
49
|
+
else
|
50
|
+
decidim_original_reorder(proposals)
|
63
51
|
end
|
64
52
|
end
|
65
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
66
53
|
|
67
54
|
def collation
|
68
55
|
@collation ||= begin
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module UseUserTimeZone
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
around_action :use_user_time_zone, if: -> { user_time_zone.present? }
|
10
|
+
helper_method :user_time_zone
|
11
|
+
|
12
|
+
# Executes a block of code in the context of the user's time zone
|
13
|
+
#
|
14
|
+
# &action - a block of code to be wrapped around the time zone
|
15
|
+
#
|
16
|
+
# Returns nothing.
|
17
|
+
def use_user_time_zone(&)
|
18
|
+
Time.use_zone(user_time_zone, &)
|
19
|
+
end
|
20
|
+
|
21
|
+
# The current time zone from the user. Available as a helper for the views.
|
22
|
+
#
|
23
|
+
# Returns a String.
|
24
|
+
def user_time_zone
|
25
|
+
return if helpers&.awesome_config&.[](:user_timezone).blank?
|
26
|
+
|
27
|
+
@user_time_zone ||= current_user&.extended_data&.[]("time_zone")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
class AdminAccountabilityController < DecidimAwesome::Admin::ApplicationController
|
7
7
|
include NeedsAwesomeConfig
|
8
|
-
include
|
8
|
+
include AdminAccountability::Admin::Filterable
|
9
9
|
|
10
10
|
helper_method :admin_actions, :collection, :export_params, :global?, :global_users_missing_date
|
11
11
|
|
@@ -20,9 +20,9 @@ module Decidim
|
|
20
20
|
def export
|
21
21
|
filters = export_params[:q]
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
ExportAdminActionsJob.perform_later(current_user,
|
24
|
+
params[:format].to_s,
|
25
|
+
admin_actions.ransack(filters).result.ids)
|
26
26
|
|
27
27
|
redirect_back fallback_location: decidim_admin_decidim_awesome.admin_accountability_path,
|
28
28
|
notice: t("decidim.decidim_awesome.admin.admin_accountability.exports.notice")
|
@@ -39,11 +39,11 @@ module Decidim
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def space_role_actions
|
42
|
-
@space_role_actions ||=
|
42
|
+
@space_role_actions ||= PaperTrailVersion.space_role_actions(current_organization)
|
43
43
|
end
|
44
44
|
|
45
45
|
def admin_role_actions
|
46
|
-
@admin_role_actions ||=
|
46
|
+
@admin_role_actions ||= PaperTrailVersion.in_organization(current_organization).admin_role_actions(PaperTrailVersion.safe_admin_role_type(params[:admin_role_type]))
|
47
47
|
end
|
48
48
|
|
49
49
|
def export_params
|
@@ -61,7 +61,7 @@ module Decidim
|
|
61
61
|
return unless global?
|
62
62
|
|
63
63
|
@global_users_missing_date ||= begin
|
64
|
-
first_version =
|
64
|
+
first_version = PaperTrailVersion.where(item_type: "Decidim::UserBaseEntity").last
|
65
65
|
first_user = Decidim::User.first
|
66
66
|
first_version.created_at if first_user && first_version && (first_version.created_at > first_user.created_at + 1.second)
|
67
67
|
end
|