decidim-admin 0.31.3 → 0.32.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -12
- data/app/cells/decidim/admin/attachments_privacy_warning/show.erb +1 -1
- data/app/cells/decidim/admin/attachments_privacy_warning_cell.rb +2 -6
- data/app/commands/decidim/admin/content_blocks/reorder_content_blocks.rb +1 -1
- data/app/commands/decidim/admin/create_attachment.rb +1 -0
- data/app/commands/decidim/admin/participatory_space/create_member.rb +99 -0
- data/app/commands/decidim/admin/participatory_space/destroy_member.rb +30 -0
- data/app/commands/decidim/admin/participatory_space/import_member_csv.rb +46 -0
- data/app/commands/decidim/admin/participatory_space/publish_all_members.rb +52 -0
- data/app/commands/decidim/admin/participatory_space/unpublish_all_members.rb +52 -0
- data/app/commands/decidim/admin/participatory_space/update_member.rb +13 -0
- data/app/commands/decidim/admin/reorder_components.rb +1 -1
- data/app/commands/decidim/admin/reorder_taxonomies.rb +1 -1
- data/app/commands/decidim/admin/update_organization.rb +1 -1
- data/app/controllers/concerns/decidim/admin/content_blocks/landing_page.rb +1 -0
- data/app/controllers/concerns/decidim/admin/content_blocks/landing_page_content_blocks.rb +3 -2
- data/app/controllers/concerns/decidim/admin/filterable.rb +4 -4
- data/app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb +1 -0
- data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +1 -1
- data/app/controllers/decidim/admin/area_types_controller.rb +2 -2
- data/app/controllers/decidim/admin/areas_controller.rb +3 -2
- data/app/controllers/decidim/admin/block_user_controller.rb +2 -2
- data/app/controllers/decidim/admin/component_permissions_controller.rb +1 -1
- data/app/controllers/decidim/admin/components/base_controller.rb +13 -9
- data/app/controllers/decidim/admin/components_controller.rb +3 -2
- data/app/controllers/decidim/admin/concerns/has_attachment_collections.rb +2 -2
- data/app/controllers/decidim/admin/concerns/has_attachments.rb +2 -2
- data/app/controllers/decidim/admin/conflicts_controller.rb +1 -1
- data/app/controllers/decidim/admin/exports_controller.rb +1 -1
- data/app/controllers/decidim/admin/impersonations_controller.rb +1 -1
- data/app/controllers/decidim/admin/imports_controller.rb +2 -1
- data/app/controllers/decidim/admin/managed_users/promotions_controller.rb +1 -1
- data/app/controllers/decidim/admin/newsletters_controller.rb +9 -8
- data/app/controllers/decidim/admin/organization_appearance_controller.rb +1 -1
- data/app/controllers/decidim/admin/organization_controller.rb +1 -1
- data/app/controllers/decidim/admin/organization_external_domain_allowlist_controller.rb +1 -1
- data/app/controllers/decidim/admin/participatory_space/concerns/has_members.rb +166 -0
- data/app/controllers/decidim/admin/participatory_space/concerns/has_members_csv_import.rb +67 -0
- data/app/controllers/decidim/admin/participatory_space/concerns/members_filterable.rb +36 -0
- data/app/controllers/decidim/admin/participatory_space/user_role_controller.rb +2 -2
- data/app/controllers/decidim/admin/reminders_controller.rb +1 -1
- data/app/controllers/decidim/admin/resource_permissions_controller.rb +1 -1
- data/app/controllers/decidim/admin/scope_types_controller.rb +2 -2
- data/app/controllers/decidim/admin/scopes_controller.rb +3 -2
- data/app/controllers/decidim/admin/share_tokens_controller.rb +2 -2
- data/app/controllers/decidim/admin/space_publications_controller.rb +2 -2
- data/app/controllers/decidim/admin/static_page_topics_controller.rb +2 -2
- data/app/controllers/decidim/admin/static_pages_controller.rb +2 -2
- data/app/controllers/decidim/admin/taxonomies_controller.rb +3 -3
- data/app/controllers/decidim/admin/taxonomy_filters_controller.rb +3 -3
- data/app/controllers/decidim/admin/taxonomy_items_controller.rb +3 -3
- data/app/controllers/decidim/admin/users_controller.rb +1 -1
- data/app/forms/decidim/admin/content_block_form.rb +28 -1
- data/app/forms/decidim/admin/organization_form.rb +0 -1
- data/app/forms/decidim/admin/participatory_space/member_csv_import_form.rb +33 -0
- data/app/forms/decidim/admin/participatory_space/member_form.rb +26 -0
- data/app/forms/decidim/admin/participatory_space_admin_user_form.rb +1 -1
- data/app/forms/decidim/admin/selective_newsletter_form.rb +7 -7
- data/app/forms/decidim/admin/taxonomy_filter_form.rb +1 -0
- data/app/helpers/decidim/admin/newsletters_helper.rb +8 -5
- data/app/helpers/decidim/admin/search_form_helper.rb +17 -0
- data/app/helpers/decidim/admin/settings_helper.rb +2 -0
- data/app/jobs/decidim/admin/newsletter_job.rb +2 -2
- data/app/jobs/decidim/admin/participatory_space/destroy_members_follows_job.rb +36 -0
- data/app/jobs/decidim/admin/participatory_space/import_member_csv_job.rb +29 -0
- data/app/packs/src/decidim/admin/controllers/access_mode/access_mode.test.js +68 -0
- data/app/packs/src/decidim/admin/controllers/access_mode/controller.js +52 -0
- data/app/packs/src/decidim/admin/newsletters.js +2 -2
- data/app/packs/stylesheets/decidim/admin/_datepicker.scss +0 -4
- data/app/queries/decidim/admin/newsletter_recipients.rb +8 -8
- data/app/views/decidim/admin/admin_terms/show.html.erb +3 -1
- data/app/views/decidim/admin/area_types/index.html.erb +3 -2
- data/app/views/decidim/admin/areas/index.html.erb +3 -2
- data/app/views/decidim/admin/attachment_collections/edit.html.erb +2 -2
- data/app/views/decidim/admin/attachment_collections/index.html.erb +2 -2
- data/app/views/decidim/admin/attachment_collections/new.html.erb +2 -2
- data/app/views/decidim/admin/attachments/index.html.erb +3 -2
- data/app/views/decidim/admin/authorization_workflows/index.html.erb +2 -2
- data/app/views/decidim/admin/block_user/new.html.erb +1 -0
- data/app/views/decidim/admin/components/index.html.erb +2 -2
- data/app/views/decidim/admin/components/manage_trash.html.erb +2 -2
- data/app/views/decidim/admin/conflicts/edit.html.erb +3 -1
- data/app/views/decidim/admin/conflicts/index.html.erb +3 -2
- data/app/views/decidim/admin/dashboard/show.html.erb +4 -4
- data/app/views/decidim/admin/help_sections/update.html.erb +2 -0
- data/app/views/decidim/admin/impersonatable_users/index.html.erb +3 -2
- data/app/views/decidim/admin/impersonations/_form.html.erb +2 -2
- data/app/views/decidim/admin/impersonations/new.html.erb +3 -2
- data/app/views/decidim/admin/imports/new.html.erb +1 -0
- data/app/views/decidim/admin/logs/_logs_list.html.erb +1 -1
- data/app/views/decidim/admin/logs/index.html.erb +1 -1
- data/app/views/decidim/admin/managed_users/impersonation_logs/index.html.erb +6 -5
- data/app/views/decidim/admin/managed_users/promotions/new.html.erb +3 -2
- data/app/views/decidim/admin/{participatory_space_private_users → members}/edit.html.erb +2 -2
- data/app/views/decidim/admin/{participatory_space_private_users → members}/index.html.erb +25 -25
- data/app/views/decidim/admin/{participatory_space_private_users → members}/new.html.erb +2 -2
- data/app/views/decidim/admin/{participatory_space_private_users_csv_imports → members_csv_imports}/new.html.erb +2 -2
- data/app/views/decidim/admin/moderations/_moderation-tr.html.erb +2 -6
- data/app/views/decidim/admin/moderations/_moderations-thead.html.erb +0 -1
- data/app/views/decidim/admin/moderations/reports/index.html.erb +1 -1
- data/app/views/decidim/admin/newsletter_templates/show.html.erb +3 -2
- data/app/views/decidim/admin/newsletters/confirm_recipients.html.erb +4 -6
- data/app/views/decidim/admin/newsletters/index.html.erb +2 -2
- data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +2 -2
- data/app/views/decidim/admin/newsletters/show.html.erb +3 -2
- data/app/views/decidim/admin/officializations/index.html.erb +6 -4
- data/app/views/decidim/admin/officializations/show_email.html.erb +2 -0
- data/app/views/decidim/admin/organization/form/_extra_features.html.erb +0 -4
- data/app/views/decidim/admin/organization_external_domain_allowlist/_form.html.erb +2 -2
- data/app/views/decidim/admin/organization_external_domain_allowlist/edit.html.erb +2 -2
- data/app/views/decidim/admin/reminders/new.html.erb +8 -1
- data/app/views/decidim/admin/resource_permissions/edit.html.erb +2 -2
- data/app/views/decidim/admin/scope_types/index.html.erb +3 -2
- data/app/views/decidim/admin/scopes/index.html.erb +2 -2
- data/app/views/decidim/admin/share_tokens/index.html.erb +2 -0
- data/app/views/decidim/admin/shared/landing_page/_content_blocks.html.erb +0 -2
- data/app/views/decidim/admin/shared/landing_page/edit.html.erb +2 -0
- data/app/views/decidim/admin/shared/landing_page_content_blocks/edit.html.erb +1 -0
- data/app/views/decidim/admin/static_page_topics/index.html.erb +2 -2
- data/app/views/decidim/admin/static_pages/edit.html.erb +2 -1
- data/app/views/decidim/admin/static_pages/index.html.erb +2 -2
- data/app/views/decidim/admin/statistics/_statistics.html.erb +1 -1
- data/app/views/decidim/admin/statistics/index.html.erb +2 -0
- data/app/views/decidim/admin/taxonomies/_row.html.erb +1 -1
- data/app/views/decidim/admin/taxonomies/_row_children.html.erb +1 -1
- data/app/views/decidim/admin/taxonomies/_table.html.erb +1 -1
- data/app/views/decidim/admin/taxonomies/edit.html.erb +2 -2
- data/app/views/decidim/admin/taxonomies/index.html.erb +4 -4
- data/app/views/decidim/admin/taxonomy_filters/index.html.erb +2 -2
- data/app/views/decidim/admin/taxonomy_filters_selector/index.html.erb +2 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/new.html.erb +2 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/show.html.erb +2 -0
- data/app/views/decidim/admin/taxonomy_items/edit.html.erb +2 -0
- data/app/views/decidim/admin/taxonomy_items/new.html.erb +2 -0
- data/app/views/decidim/admin/users/index.html.erb +3 -2
- data/config/locales/ar.yml +4 -49
- data/config/locales/bg.yml +4 -55
- data/config/locales/bs-BA.yml +0 -24
- data/config/locales/ca-IT.yml +127 -100
- data/config/locales/ca.yml +127 -100
- data/config/locales/cs.yml +122 -94
- data/config/locales/de.yml +109 -87
- data/config/locales/el.yml +11 -45
- data/config/locales/en.yml +126 -98
- data/config/locales/eo.yml +0 -7
- data/config/locales/es-MX.yml +126 -99
- data/config/locales/es-PY.yml +126 -99
- data/config/locales/es.yml +126 -99
- data/config/locales/eu.yml +126 -99
- data/config/locales/fi-plain.yml +132 -87
- data/config/locales/fi.yml +132 -87
- data/config/locales/fr-CA.yml +87 -91
- data/config/locales/fr.yml +87 -91
- data/config/locales/ga-IE.yml +0 -13
- data/config/locales/gl.yml +4 -41
- data/config/locales/he-IL.yml +0 -5
- data/config/locales/hu.yml +4 -52
- data/config/locales/id-ID.yml +4 -34
- data/config/locales/is-IS.yml +1 -16
- data/config/locales/it.yml +4 -68
- data/config/locales/ja.yml +124 -99
- data/config/locales/kaa.yml +0 -16
- data/config/locales/ko.yml +0 -40
- data/config/locales/lb.yml +4 -41
- data/config/locales/lt.yml +4 -52
- data/config/locales/lv.yml +4 -38
- data/config/locales/nl.yml +4 -46
- data/config/locales/no.yml +4 -46
- data/config/locales/pl.yml +4 -54
- data/config/locales/pt-BR.yml +109 -97
- data/config/locales/pt.yml +4 -42
- data/config/locales/ro-RO.yml +9 -51
- data/config/locales/ru.yml +4 -35
- data/config/locales/sk.yml +4 -38
- data/config/locales/sl.yml +0 -7
- data/config/locales/sq-AL.yml +0 -21
- data/config/locales/sr-CS.yml +0 -24
- data/config/locales/sv.yml +74 -87
- data/config/locales/th-TH.yml +0 -8
- data/config/locales/tr-TR.yml +21 -58
- data/config/locales/uk.yml +0 -26
- data/config/locales/val-ES.yml +0 -1
- data/config/locales/zh-CN.yml +4 -38
- data/config/locales/zh-TW.yml +4 -52
- data/decidim-admin.gemspec +7 -10
- data/lib/decidim/admin/engine.rb +5 -2
- data/lib/decidim/admin/menu.rb +1 -1
- data/lib/decidim/admin/test/admin_members_shared_examples.rb +119 -0
- data/lib/decidim/admin/test/admin_participatory_space_access_examples.rb +3 -3
- data/lib/decidim/admin/test/filterable_examples.rb +20 -11
- data/lib/decidim/admin/test/invite_participatory_space_admins_shared_examples.rb +17 -17
- data/lib/decidim/admin/test/invite_participatory_space_collaborators_shared_examples.rb +1 -1
- data/lib/decidim/admin/test/invite_participatory_space_moderators_shared_examples.rb +1 -1
- data/lib/decidim/admin/test/invite_participatory_space_users_shared_context.rb +1 -1
- data/lib/decidim/admin/test/manage_attachment_collections_examples.rb +3 -3
- data/lib/decidim/admin/test/manage_attachments_examples.rb +6 -6
- data/lib/decidim/admin/test/manage_component_permissions_examples.rb +5 -5
- data/lib/decidim/admin/test/manage_moderations_examples.rb +6 -6
- data/lib/decidim/admin/test/manage_participatory_space_publications_examples.rb +2 -2
- data/lib/decidim/admin/test/manage_resource_soft_deletion_examples.rb +3 -3
- data/lib/decidim/admin/version.rb +1 -1
- data/lib/decidim/admin.rb +0 -2
- metadata +39 -35
- data/app/commands/decidim/admin/create_participatory_space_private_user.rb +0 -98
- data/app/commands/decidim/admin/destroy_participatory_space_private_user.rb +0 -28
- data/app/commands/decidim/admin/process_participatory_space_private_user_import_csv.rb +0 -44
- data/app/commands/decidim/admin/publish_all_participatory_space_private_users.rb +0 -50
- data/app/commands/decidim/admin/unpublish_all_participatory_space_private_users.rb +0 -50
- data/app/commands/decidim/admin/update_participatory_space_private_user.rb +0 -11
- data/app/controllers/concerns/decidim/participatory_space_private_users/admin/filterable.rb +0 -34
- data/app/controllers/decidim/admin/concerns/has_private_users.rb +0 -169
- data/app/controllers/decidim/admin/concerns/has_private_users_csv_import.rb +0 -65
- data/app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb +0 -31
- data/app/forms/decidim/admin/participatory_space_private_user_form.rb +0 -24
- data/app/jobs/decidim/admin/destroy_private_users_follows_job.rb +0 -37
- data/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb +0 -27
- data/app/views/decidim/admin/devise/mailers/password_change.html.erb +0 -3
- data/app/views/decidim/admin/devise/mailers/reset_password_instructions.html.erb +0 -8
- /data/app/views/decidim/admin/{participatory_space_private_users → members}/_form.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: 9da138630750a0739cd6fd8b161f7093193e6293fa32a00e24355c7c0fca9a0c
|
|
4
|
+
data.tar.gz: ba05f9d1e15ac506f29ce14428c7952be077fd8f251c886be250267a1b32fbb9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 135c143b735ee0ada94c33046c6f9c5cbf81027b91ee609677a66b3fd04db2051781eab9b465836666acf5b3268ba372ab69ed823509d4cba115f2b600cd1a83
|
|
7
|
+
data.tar.gz: 501dd3d2f79cc2b1699830d82b7f411ebeb8656aab4ac0de1da085b7ec5a4882053187796221a38687544a5a24446d4df752bdecee3fd445b581c9ef7481b7fe
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# decidim-admin
|
|
2
2
|
|
|
3
3
|
Adds an administration dashboard so users can manage their
|
|
4
4
|
organization, participatory processes and all other entities.
|
|
@@ -10,17 +10,7 @@ It is included by default with Decidim.
|
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```ruby
|
|
16
|
-
gem 'decidim-admin'
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
And then execute:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
bundle
|
|
23
|
-
```
|
|
13
|
+
This is on the default Decidim installation so you should not change anything to use this module.
|
|
24
14
|
|
|
25
15
|
## Components
|
|
26
16
|
|
|
@@ -7,12 +7,8 @@ module Decidim
|
|
|
7
7
|
|
|
8
8
|
private
|
|
9
9
|
|
|
10
|
-
def
|
|
11
|
-
current_participatory_space.
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def transparent_space?
|
|
15
|
-
current_participatory_space.is_transparent if current_participatory_space.respond_to?(:is_transparent)
|
|
10
|
+
def restricted_space?
|
|
11
|
+
current_participatory_space.respond_to?(:restricted?) && current_participatory_space.restricted?
|
|
16
12
|
end
|
|
17
13
|
end
|
|
18
14
|
end
|
|
@@ -58,6 +58,7 @@ module Decidim
|
|
|
58
58
|
|
|
59
59
|
def notify_followers
|
|
60
60
|
return unless @attachment.attached_to.is_a?(Decidim::Followable)
|
|
61
|
+
return if @attachment.attached_to.respond_to?(:published?) && !@attachment.attached_to.published?
|
|
61
62
|
|
|
62
63
|
Decidim::EventsManager.publish(
|
|
63
64
|
event: "decidim.events.attachments.attachment_created",
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Admin
|
|
5
|
+
module ParticipatorySpace
|
|
6
|
+
# A command with all the business logic when creating a new participatory space
|
|
7
|
+
# member in the system.
|
|
8
|
+
class CreateMember < Decidim::Command
|
|
9
|
+
delegate :current_user, to: :form
|
|
10
|
+
# Public: Initializes the command.
|
|
11
|
+
#
|
|
12
|
+
# form - A form object with the params.
|
|
13
|
+
# member_to - The member_to that will hold the
|
|
14
|
+
# user role
|
|
15
|
+
def initialize(form, member_to, via_csv: false)
|
|
16
|
+
@form = form
|
|
17
|
+
@member_to = member_to
|
|
18
|
+
@via_csv = via_csv
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Executes the command. Broadcasts these events:
|
|
22
|
+
#
|
|
23
|
+
# - :ok when everything is valid.
|
|
24
|
+
# - :invalid if the form was not valid and we could not proceed.
|
|
25
|
+
#
|
|
26
|
+
# Returns nothing.
|
|
27
|
+
def call
|
|
28
|
+
return broadcast(:invalid) if form.invalid?
|
|
29
|
+
|
|
30
|
+
ActiveRecord::Base.transaction do
|
|
31
|
+
@user ||= existing_user || new_user
|
|
32
|
+
create_member
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
broadcast(:ok)
|
|
36
|
+
rescue ActiveRecord::RecordInvalid
|
|
37
|
+
form.errors.add(:email, :taken)
|
|
38
|
+
broadcast(:invalid)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
attr_reader :form, :member_to, :user
|
|
44
|
+
|
|
45
|
+
def create_member
|
|
46
|
+
action = @via_csv ? "create_via_csv" : "create"
|
|
47
|
+
Decidim.traceability.perform_action!(
|
|
48
|
+
action,
|
|
49
|
+
Decidim::ParticipatorySpace::Member,
|
|
50
|
+
current_user,
|
|
51
|
+
resource: {
|
|
52
|
+
title: user.name
|
|
53
|
+
}
|
|
54
|
+
) do
|
|
55
|
+
member = Decidim::ParticipatorySpace::Member.where(user:, participatory_space: @member_to).first_or_initialize
|
|
56
|
+
member.role = form.role
|
|
57
|
+
member.published = form.published
|
|
58
|
+
member.save!
|
|
59
|
+
member
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def existing_user
|
|
64
|
+
return @existing_user if defined?(@existing_user)
|
|
65
|
+
|
|
66
|
+
@existing_user = User.find_by(
|
|
67
|
+
email: form.email.downcase,
|
|
68
|
+
organization: member_to.organization
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
InviteUserAgain.call(@existing_user, invitation_instructions) if @existing_user&.invitation_pending?
|
|
72
|
+
|
|
73
|
+
@existing_user
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def new_user
|
|
77
|
+
@new_user ||= InviteUser.call(user_form) do
|
|
78
|
+
on(:ok) do |user|
|
|
79
|
+
return user
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def user_form
|
|
85
|
+
OpenStruct.new(name: form.name,
|
|
86
|
+
email: form.email.downcase,
|
|
87
|
+
organization: member_to.organization,
|
|
88
|
+
admin: false,
|
|
89
|
+
invited_by: current_user,
|
|
90
|
+
invitation_instructions:)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def invitation_instructions
|
|
94
|
+
"invite_member"
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Admin
|
|
5
|
+
module ParticipatorySpace
|
|
6
|
+
# A command with all the business logic to destroy a member.
|
|
7
|
+
class DestroyMember < Decidim::Commands::DestroyResource
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def extra_params
|
|
11
|
+
{
|
|
12
|
+
resource: {
|
|
13
|
+
title: resource.user.name
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def run_after_hooks
|
|
19
|
+
return unless resource.participatory_space.respond_to?(:restricted?)
|
|
20
|
+
return unless resource.participatory_space.restricted?
|
|
21
|
+
return if resource.participatory_space.respond_to?(:transparent?) && resource.participatory_space.transparent?
|
|
22
|
+
|
|
23
|
+
# When member is destroyed, a hook to destroy the follows of user on restricted or transparent spaces
|
|
24
|
+
# and the follows of their children
|
|
25
|
+
DestroyMembersFollowsJob.perform_later(resource.decidim_user_id, resource.participatory_space)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "csv"
|
|
4
|
+
|
|
5
|
+
module Decidim
|
|
6
|
+
module Admin
|
|
7
|
+
module ParticipatorySpace
|
|
8
|
+
class ImportMemberCsv < Decidim::Command
|
|
9
|
+
include Decidim::Admin::CustomImport
|
|
10
|
+
|
|
11
|
+
delegate :current_user, to: :form
|
|
12
|
+
# Public: Initializes the command.
|
|
13
|
+
#
|
|
14
|
+
# form - the form object containing the uploaded file
|
|
15
|
+
# members_to - The members_to that will hold the user role
|
|
16
|
+
def initialize(form, members_to)
|
|
17
|
+
@form = form
|
|
18
|
+
@members_to = members_to
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Executes the command. Broadcasts these events:
|
|
22
|
+
#
|
|
23
|
+
# - :ok when everything is valid.
|
|
24
|
+
# - :invalid if the form was not valid and we could not proceed.
|
|
25
|
+
#
|
|
26
|
+
# Returns nothing.
|
|
27
|
+
def call
|
|
28
|
+
return broadcast(:invalid) unless @form.valid?
|
|
29
|
+
|
|
30
|
+
process_csv
|
|
31
|
+
broadcast(:ok)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
attr_reader :form
|
|
37
|
+
|
|
38
|
+
def process_csv
|
|
39
|
+
process_import_file(@form.file) do |(email, user_name)|
|
|
40
|
+
ImportMemberCsvJob.perform_later(email, user_name, @members_to, current_user) if email.present? && user_name.present?
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Admin
|
|
5
|
+
module ParticipatorySpace
|
|
6
|
+
class PublishAllMembers < Decidim::Command
|
|
7
|
+
# Public: Initializes the command.
|
|
8
|
+
#
|
|
9
|
+
# participatory_space - the participatory space
|
|
10
|
+
# current_user - the current user
|
|
11
|
+
def initialize(participatory_space, current_user)
|
|
12
|
+
@participatory_space = participatory_space
|
|
13
|
+
@current_user = current_user
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Executes the command. Broadcasts these events:
|
|
17
|
+
#
|
|
18
|
+
# - :ok when everything is valid.
|
|
19
|
+
# - :invalid if the form was not valid and we could not proceed.
|
|
20
|
+
#
|
|
21
|
+
# Returns nothing.
|
|
22
|
+
def call
|
|
23
|
+
publish_all
|
|
24
|
+
create_action_log
|
|
25
|
+
broadcast(:ok)
|
|
26
|
+
rescue ActiveRecord::RecordInvalid
|
|
27
|
+
broadcast(:invalid)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
attr_reader :participatory_space, :current_user
|
|
33
|
+
|
|
34
|
+
def publish_all
|
|
35
|
+
# rubocop:disable Rails/SkipsModelValidations
|
|
36
|
+
# Using update_all for performance reasons
|
|
37
|
+
participatory_space.members.update_all(published: true)
|
|
38
|
+
# rubocop:enable Rails/SkipsModelValidations
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def create_action_log
|
|
42
|
+
Decidim.traceability.perform_action!(
|
|
43
|
+
"publish_all_members",
|
|
44
|
+
participatory_space,
|
|
45
|
+
current_user,
|
|
46
|
+
members_ids: participatory_space.members.pluck(:id)
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Admin
|
|
5
|
+
module ParticipatorySpace
|
|
6
|
+
class UnpublishAllMembers < Decidim::Command
|
|
7
|
+
# Public: Initializes the command.
|
|
8
|
+
#
|
|
9
|
+
# participatory_space - the participatory space
|
|
10
|
+
# current_user - the current user
|
|
11
|
+
def initialize(participatory_space, current_user)
|
|
12
|
+
@participatory_space = participatory_space
|
|
13
|
+
@current_user = current_user
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Executes the command. Broadcasts these events:
|
|
17
|
+
#
|
|
18
|
+
# - :ok when everything is valid.
|
|
19
|
+
# - :invalid if the form was not valid and we could not proceed.
|
|
20
|
+
#
|
|
21
|
+
# Returns nothing.
|
|
22
|
+
def call
|
|
23
|
+
unpublish_all
|
|
24
|
+
create_action_log
|
|
25
|
+
broadcast(:ok)
|
|
26
|
+
rescue ActiveRecord::RecordInvalid
|
|
27
|
+
broadcast(:invalid)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
attr_reader :participatory_space, :current_user
|
|
33
|
+
|
|
34
|
+
def unpublish_all
|
|
35
|
+
# rubocop:disable Rails/SkipsModelValidations
|
|
36
|
+
# Using update_all for performance reasons
|
|
37
|
+
participatory_space.members.update_all(published: false)
|
|
38
|
+
# rubocop:enable Rails/SkipsModelValidations
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def create_action_log
|
|
42
|
+
Decidim.traceability.perform_action!(
|
|
43
|
+
"unpublish_all_members",
|
|
44
|
+
participatory_space,
|
|
45
|
+
current_user,
|
|
46
|
+
members_ids: participatory_space.members.pluck(:id)
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Admin
|
|
5
|
+
module ParticipatorySpace
|
|
6
|
+
# A command with all the business logic when updating a participatory space
|
|
7
|
+
# member.
|
|
8
|
+
class UpdateMember < Decidim::Commands::UpdateResource
|
|
9
|
+
fetch_form_attributes :role, :published
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -10,7 +10,7 @@ module Decidim
|
|
|
10
10
|
fetch_form_attributes :name, :description, :default_locale, :reference_prefix, :time_zone, :twitter_handler,
|
|
11
11
|
:facebook_handler, :instagram_handler, :youtube_handler, :github_handler, :badges_enabled,
|
|
12
12
|
:comments_max_length, :enable_machine_translations, :admin_terms_of_service_body,
|
|
13
|
-
:rich_text_editor_in_public_views, :
|
|
13
|
+
:rich_text_editor_in_public_views, :official_url,
|
|
14
14
|
:enable_omnipresent_banner, :omnipresent_banner_url, :omnipresent_banner_title,
|
|
15
15
|
:omnipresent_banner_short_description
|
|
16
16
|
|
|
@@ -5,6 +5,7 @@ module Decidim
|
|
|
5
5
|
module ContentBlocks
|
|
6
6
|
module LandingPage
|
|
7
7
|
extend ActiveSupport::Concern
|
|
8
|
+
|
|
8
9
|
included do
|
|
9
10
|
helper_method :active_blocks, :active_content_blocks_title, :add_content_block_text, :available_manifests,
|
|
10
11
|
:content_block_destroy_confirmation_text, :content_blocks_title, :inactive_blocks,
|
|
@@ -5,6 +5,7 @@ module Decidim
|
|
|
5
5
|
module ContentBlocks
|
|
6
6
|
module LandingPageContentBlocks
|
|
7
7
|
extend ActiveSupport::Concern
|
|
8
|
+
|
|
8
9
|
included do
|
|
9
10
|
helper_method :content_block, :resource_landing_page_content_block_path, :scoped_resource, :submit_button_text
|
|
10
11
|
|
|
@@ -48,14 +49,14 @@ module Decidim
|
|
|
48
49
|
def update
|
|
49
50
|
enforce_permission_to_update_resource
|
|
50
51
|
|
|
51
|
-
@form = form(ContentBlockForm).from_params(params)
|
|
52
|
+
@form = form(ContentBlockForm).from_params(params, content_block:)
|
|
52
53
|
|
|
53
54
|
UpdateContentBlock.call(@form, content_block, content_block_scope) do
|
|
54
55
|
on(:ok) do
|
|
55
56
|
redirect_to edit_resource_landing_page_path
|
|
56
57
|
end
|
|
57
58
|
on(:invalid) do
|
|
58
|
-
render "decidim/admin/shared/landing_page_content_blocks/edit", status: :
|
|
59
|
+
render "decidim/admin/shared/landing_page_content_blocks/edit", status: :unprocessable_content
|
|
59
60
|
end
|
|
60
61
|
end
|
|
61
62
|
end
|
|
@@ -77,7 +77,7 @@ module Decidim
|
|
|
77
77
|
# the query
|
|
78
78
|
def adjacent_items(item)
|
|
79
79
|
query =
|
|
80
|
-
|
|
80
|
+
<<~SQL.squish
|
|
81
81
|
WITH
|
|
82
82
|
collection AS (#{session_filtered_collection.select(:id).to_sql}),
|
|
83
83
|
successors AS (
|
|
@@ -162,7 +162,7 @@ module Decidim
|
|
|
162
162
|
# - FilterableHelper#applied_filters_hidden_field_tags
|
|
163
163
|
# To ensure that filters are kept in the search_form_for.
|
|
164
164
|
def filters
|
|
165
|
-
[:
|
|
165
|
+
[:published_at_null]
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
# Informs which filters are being used OUTSIDE the dropdown.
|
|
@@ -198,8 +198,8 @@ module Decidim
|
|
|
198
198
|
filtered_taxonomies = taxonomies.roots.or(taxonomies.where(id: available_taxonomy_ids))
|
|
199
199
|
return nil if filtered_taxonomies.blank?
|
|
200
200
|
|
|
201
|
-
filtered_taxonomies.
|
|
202
|
-
|
|
201
|
+
filtered_taxonomies.to_h do |taxonomy|
|
|
202
|
+
[taxonomy.id, taxonomy_ids_hash(taxonomy.children)]
|
|
203
203
|
end
|
|
204
204
|
end
|
|
205
205
|
|
|
@@ -34,7 +34,7 @@ module Decidim
|
|
|
34
34
|
|
|
35
35
|
on(:invalid) do
|
|
36
36
|
flash.now[:alert] = I18n.t("area_types.create.error", scope: "decidim.admin")
|
|
37
|
-
render :new, status: :
|
|
37
|
+
render :new, status: :unprocessable_content
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -56,7 +56,7 @@ module Decidim
|
|
|
56
56
|
|
|
57
57
|
on(:invalid) do
|
|
58
58
|
flash.now[:alert] = I18n.t("area_types.update.error", scope: "decidim.admin")
|
|
59
|
-
render :edit, status: :
|
|
59
|
+
render :edit, status: :unprocessable_content
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -6,6 +6,7 @@ module Decidim
|
|
|
6
6
|
#
|
|
7
7
|
class AreasController < Decidim::Admin::ApplicationController
|
|
8
8
|
include Decidim::Admin::Concerns::HasTabbedMenu
|
|
9
|
+
|
|
9
10
|
helper Decidim::Admin::AreasHelper
|
|
10
11
|
|
|
11
12
|
layout "decidim/admin/settings"
|
|
@@ -35,7 +36,7 @@ module Decidim
|
|
|
35
36
|
|
|
36
37
|
on(:invalid) do
|
|
37
38
|
flash.now[:alert] = I18n.t("areas.create.error", scope: "decidim.admin")
|
|
38
|
-
render :new, status: :
|
|
39
|
+
render :new, status: :unprocessable_content
|
|
39
40
|
end
|
|
40
41
|
end
|
|
41
42
|
end
|
|
@@ -57,7 +58,7 @@ module Decidim
|
|
|
57
58
|
|
|
58
59
|
on(:invalid) do
|
|
59
60
|
flash.now[:alert] = I18n.t("areas.update.error", scope: "decidim.admin")
|
|
60
|
-
render :edit, status: :
|
|
61
|
+
render :edit, status: :unprocessable_content
|
|
61
62
|
end
|
|
62
63
|
end
|
|
63
64
|
end
|
|
@@ -27,7 +27,7 @@ module Decidim
|
|
|
27
27
|
|
|
28
28
|
on(:invalid) do
|
|
29
29
|
flash[:alert] = I18n.t("officializations.block.error", scope: "decidim.admin")
|
|
30
|
-
render :new, status: :
|
|
30
|
+
render :new, status: :unprocessable_content
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -65,7 +65,7 @@ module Decidim
|
|
|
65
65
|
|
|
66
66
|
on(:invalid) do
|
|
67
67
|
flash.now[:alert] = I18n.t("officializations.bulk_action.block.invalid", scope: "decidim.admin")
|
|
68
|
-
render :bulk_new, status: :
|
|
68
|
+
render :bulk_new, status: :unprocessable_content
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
end
|
|
@@ -10,6 +10,7 @@ module Decidim
|
|
|
10
10
|
|
|
11
11
|
include Decidim::Admin::ParticipatorySpaceAdminContext
|
|
12
12
|
include Decidim::NeedsPermission
|
|
13
|
+
|
|
13
14
|
participatory_space_admin_layout
|
|
14
15
|
|
|
15
16
|
helper Decidim::ResourceHelper
|
|
@@ -23,15 +24,9 @@ module Decidim
|
|
|
23
24
|
:current_participatory_space,
|
|
24
25
|
:parent_path
|
|
25
26
|
|
|
26
|
-
before_action
|
|
27
|
-
enforce_permission_to :manage, :component, component: current_component unless skip_manage_component_permission
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
before_action on: [:index, :show] do
|
|
31
|
-
enforce_permission_to :read, :component, component: current_component
|
|
32
|
-
end
|
|
27
|
+
before_action :enforce_component_permissions
|
|
33
28
|
|
|
34
|
-
before_action :
|
|
29
|
+
before_action :set_breadcrumb_items
|
|
35
30
|
|
|
36
31
|
def permissions_context
|
|
37
32
|
super.merge(
|
|
@@ -68,7 +63,16 @@ module Decidim
|
|
|
68
63
|
false
|
|
69
64
|
end
|
|
70
65
|
|
|
71
|
-
def
|
|
66
|
+
def enforce_component_permissions
|
|
67
|
+
case action_name.to_sym
|
|
68
|
+
when :index, :show
|
|
69
|
+
enforce_permission_to :read, :component, component: current_component
|
|
70
|
+
else
|
|
71
|
+
enforce_permission_to :manage, :component, component: current_component unless skip_manage_component_permission
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def set_breadcrumb_items
|
|
72
76
|
context_breadcrumb_items << {
|
|
73
77
|
label: t("components", scope: "decidim.admin.menu"),
|
|
74
78
|
url: parent_path,
|
|
@@ -7,6 +7,7 @@ module Decidim
|
|
|
7
7
|
#
|
|
8
8
|
class ComponentsController < Decidim::Admin::ApplicationController
|
|
9
9
|
include Decidim::Admin::HasTrashableResources
|
|
10
|
+
|
|
10
11
|
helper_method :manifest
|
|
11
12
|
|
|
12
13
|
def index
|
|
@@ -47,7 +48,7 @@ module Decidim
|
|
|
47
48
|
|
|
48
49
|
on(:invalid) do
|
|
49
50
|
flash.now[:alert] = I18n.t("components.create.error", scope: "decidim.admin")
|
|
50
|
-
render action: "new", status: :
|
|
51
|
+
render action: "new", status: :unprocessable_content
|
|
51
52
|
end
|
|
52
53
|
end
|
|
53
54
|
end
|
|
@@ -74,7 +75,7 @@ module Decidim
|
|
|
74
75
|
|
|
75
76
|
on(:invalid) do
|
|
76
77
|
flash[:alert] = I18n.t("components.update.error", scope: "decidim.admin")
|
|
77
|
-
render action: :edit, status: :
|
|
78
|
+
render action: :edit, status: :unprocessable_content
|
|
78
79
|
end
|
|
79
80
|
end
|
|
80
81
|
end
|
|
@@ -39,7 +39,7 @@ module Decidim
|
|
|
39
39
|
|
|
40
40
|
on(:invalid) do
|
|
41
41
|
flash.now[:alert] = I18n.t("attachment_collections.create.error", scope: "decidim.admin")
|
|
42
|
-
render template: "decidim/admin/attachment_collections/new", status: :
|
|
42
|
+
render template: "decidim/admin/attachment_collections/new", status: :unprocessable_content
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -64,7 +64,7 @@ module Decidim
|
|
|
64
64
|
|
|
65
65
|
on(:invalid) do
|
|
66
66
|
flash.now[:alert] = I18n.t("attachment_collections.update.error", scope: "decidim.admin")
|
|
67
|
-
render template: "decidim/admin/attachment_collections/edit", status: :
|
|
67
|
+
render template: "decidim/admin/attachment_collections/edit", status: :unprocessable_content
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
end
|
|
@@ -39,7 +39,7 @@ module Decidim
|
|
|
39
39
|
|
|
40
40
|
on(:invalid) do
|
|
41
41
|
flash.now[:alert] = I18n.t("attachments.create.error", scope: "decidim.admin")
|
|
42
|
-
render template: "decidim/admin/attachments/new", status: :
|
|
42
|
+
render template: "decidim/admin/attachments/new", status: :unprocessable_content
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -64,7 +64,7 @@ module Decidim
|
|
|
64
64
|
|
|
65
65
|
on(:invalid) do
|
|
66
66
|
flash.now[:alert] = I18n.t("attachments.update.error", scope: "decidim.admin")
|
|
67
|
-
render template: "decidim/admin/attachments/edit", status: :
|
|
67
|
+
render template: "decidim/admin/attachments/edit", status: :unprocessable_content
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
end
|