decidim-admin 0.31.5 → 0.32.0.rc2
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/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 -48
- data/config/locales/bg.yml +4 -54
- data/config/locales/bs-BA.yml +0 -23
- data/config/locales/ca-IT.yml +126 -98
- data/config/locales/ca.yml +126 -98
- data/config/locales/cs.yml +122 -95
- data/config/locales/de.yml +109 -93
- data/config/locales/el.yml +11 -44
- data/config/locales/en.yml +126 -98
- data/config/locales/eo.yml +0 -6
- data/config/locales/es-MX.yml +126 -98
- data/config/locales/es-PY.yml +126 -98
- data/config/locales/es.yml +126 -98
- data/config/locales/eu.yml +126 -98
- data/config/locales/fi-plain.yml +126 -98
- data/config/locales/fi.yml +126 -98
- data/config/locales/fr-CA.yml +91 -90
- data/config/locales/fr.yml +91 -90
- data/config/locales/ga-IE.yml +0 -12
- data/config/locales/gl.yml +4 -40
- data/config/locales/he-IL.yml +0 -4
- data/config/locales/hu.yml +4 -51
- data/config/locales/id-ID.yml +4 -33
- data/config/locales/is-IS.yml +0 -14
- data/config/locales/it.yml +4 -67
- data/config/locales/ja.yml +124 -98
- data/config/locales/kaa.yml +0 -15
- data/config/locales/ko.yml +0 -39
- data/config/locales/lb.yml +4 -40
- data/config/locales/lt.yml +4 -51
- data/config/locales/lv.yml +4 -37
- data/config/locales/nl.yml +4 -45
- data/config/locales/no.yml +4 -45
- data/config/locales/pl.yml +4 -53
- data/config/locales/pt-BR.yml +109 -96
- data/config/locales/pt.yml +4 -41
- data/config/locales/ro-RO.yml +9 -50
- data/config/locales/ru.yml +4 -34
- data/config/locales/sk.yml +126 -98
- data/config/locales/sl.yml +0 -6
- data/config/locales/sq-AL.yml +0 -20
- data/config/locales/sr-CS.yml +0 -23
- data/config/locales/sv.yml +74 -86
- data/config/locales/th-TH.yml +0 -7
- data/config/locales/tr-TR.yml +21 -57
- data/config/locales/uk.yml +0 -25
- data/config/locales/zh-CN.yml +4 -37
- data/config/locales/zh-TW.yml +4 -51
- 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
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Decidim
|
|
4
|
-
module Admin
|
|
5
|
-
class PublishAllParticipatorySpacePrivateUsers < Decidim::Command
|
|
6
|
-
# Public: Initializes the command.
|
|
7
|
-
#
|
|
8
|
-
# participatory_space - the participatory space
|
|
9
|
-
# current_user - the current user
|
|
10
|
-
def initialize(participatory_space, current_user)
|
|
11
|
-
@participatory_space = participatory_space
|
|
12
|
-
@current_user = current_user
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Executes the command. Broadcasts these events:
|
|
16
|
-
#
|
|
17
|
-
# - :ok when everything is valid.
|
|
18
|
-
# - :invalid if the form was not valid and we could not proceed.
|
|
19
|
-
#
|
|
20
|
-
# Returns nothing.
|
|
21
|
-
def call
|
|
22
|
-
publish_all
|
|
23
|
-
create_action_log
|
|
24
|
-
broadcast(:ok)
|
|
25
|
-
rescue ActiveRecord::RecordInvalid
|
|
26
|
-
broadcast(:invalid)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
private
|
|
30
|
-
|
|
31
|
-
attr_reader :participatory_space, :current_user
|
|
32
|
-
|
|
33
|
-
def publish_all
|
|
34
|
-
# rubocop:disable Rails/SkipsModelValidations
|
|
35
|
-
# Using update_all for performance reasons
|
|
36
|
-
participatory_space.participatory_space_private_users.update_all(published: true)
|
|
37
|
-
# rubocop:enable Rails/SkipsModelValidations
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def create_action_log
|
|
41
|
-
Decidim.traceability.perform_action!(
|
|
42
|
-
"publish_all_members",
|
|
43
|
-
participatory_space,
|
|
44
|
-
current_user,
|
|
45
|
-
private_users_ids: participatory_space.participatory_space_private_users.pluck(:id)
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Decidim
|
|
4
|
-
module Admin
|
|
5
|
-
class UnpublishAllParticipatorySpacePrivateUsers < Decidim::Command
|
|
6
|
-
# Public: Initializes the command.
|
|
7
|
-
#
|
|
8
|
-
# participatory_space - the participatory space
|
|
9
|
-
# current_user - the current user
|
|
10
|
-
def initialize(participatory_space, current_user)
|
|
11
|
-
@participatory_space = participatory_space
|
|
12
|
-
@current_user = current_user
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Executes the command. Broadcasts these events:
|
|
16
|
-
#
|
|
17
|
-
# - :ok when everything is valid.
|
|
18
|
-
# - :invalid if the form was not valid and we could not proceed.
|
|
19
|
-
#
|
|
20
|
-
# Returns nothing.
|
|
21
|
-
def call
|
|
22
|
-
unpublish_all
|
|
23
|
-
create_action_log
|
|
24
|
-
broadcast(:ok)
|
|
25
|
-
rescue ActiveRecord::RecordInvalid
|
|
26
|
-
broadcast(:invalid)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
private
|
|
30
|
-
|
|
31
|
-
attr_reader :participatory_space, :current_user
|
|
32
|
-
|
|
33
|
-
def unpublish_all
|
|
34
|
-
# rubocop:disable Rails/SkipsModelValidations
|
|
35
|
-
# Using update_all for performance reasons
|
|
36
|
-
participatory_space.participatory_space_private_users.update_all(published: false)
|
|
37
|
-
# rubocop:enable Rails/SkipsModelValidations
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def create_action_log
|
|
41
|
-
Decidim.traceability.perform_action!(
|
|
42
|
-
"unpublish_all_members",
|
|
43
|
-
participatory_space,
|
|
44
|
-
current_user,
|
|
45
|
-
private_users_ids: participatory_space.participatory_space_private_users.pluck(:id)
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Decidim
|
|
4
|
-
module Admin
|
|
5
|
-
# A command with all the business logic when updating a participatory space
|
|
6
|
-
# private user.
|
|
7
|
-
class UpdateParticipatorySpacePrivateUser < Decidim::Commands::UpdateResource
|
|
8
|
-
fetch_form_attributes :role, :published
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "active_support/concern"
|
|
4
|
-
|
|
5
|
-
module Decidim
|
|
6
|
-
module ParticipatorySpacePrivateUsers
|
|
7
|
-
module Admin
|
|
8
|
-
module Filterable
|
|
9
|
-
extend ActiveSupport::Concern
|
|
10
|
-
|
|
11
|
-
included do
|
|
12
|
-
include Decidim::Admin::Filterable
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
def base_query
|
|
17
|
-
collection
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def filters
|
|
21
|
-
[
|
|
22
|
-
:user_invitation_sent_at_not_null,
|
|
23
|
-
:user_invitation_accepted_at_not_null
|
|
24
|
-
]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def search_field_predicate
|
|
28
|
-
:user_name_or_user_email_cont
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Decidim
|
|
4
|
-
module Admin
|
|
5
|
-
module Concerns
|
|
6
|
-
# PrivateUsers can be related to any ParticipatorySpace, in order to
|
|
7
|
-
# manage the private users for a given type, you should create a new
|
|
8
|
-
# controller and include this concern.
|
|
9
|
-
#
|
|
10
|
-
# The only requirement is to define a `privatable_to` method that
|
|
11
|
-
# returns an instance of the model to relate the private_user to.
|
|
12
|
-
module HasPrivateUsers
|
|
13
|
-
extend ActiveSupport::Concern
|
|
14
|
-
|
|
15
|
-
included do
|
|
16
|
-
include Decidim::ParticipatorySpacePrivateUsers::Admin::Filterable
|
|
17
|
-
helper PaginateHelper
|
|
18
|
-
helper_method :privatable_to, :participatory_space_private_users
|
|
19
|
-
|
|
20
|
-
# rubocop:disable Rails/LexicallyScopedActionFilter
|
|
21
|
-
before_action :set_private_user, only: [:edit, :update, :destroy, :resend_invitation]
|
|
22
|
-
# rubocop:enable Rails/LexicallyScopedActionFilter
|
|
23
|
-
|
|
24
|
-
def index
|
|
25
|
-
enforce_permission_to :read, :space_private_user
|
|
26
|
-
|
|
27
|
-
render template: "decidim/admin/participatory_space_private_users/index"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def new
|
|
31
|
-
enforce_permission_to :create, :space_private_user
|
|
32
|
-
@form = form(ParticipatorySpacePrivateUserForm).from_params({}, privatable_to:)
|
|
33
|
-
render template: "decidim/admin/participatory_space_private_users/new"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def edit
|
|
37
|
-
enforce_permission_to :update, :space_private_user, private_user: @private_user
|
|
38
|
-
@form = form(ParticipatorySpacePrivateUserForm).from_model(@private_user)
|
|
39
|
-
render template: "decidim/admin/participatory_space_private_users/edit"
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def update
|
|
43
|
-
enforce_permission_to :update, :space_private_user, private_user: @private_user
|
|
44
|
-
@form = form(ParticipatorySpacePrivateUserForm).from_params(params, privatable_to:)
|
|
45
|
-
|
|
46
|
-
UpdateParticipatorySpacePrivateUser.call(@form, @private_user) do
|
|
47
|
-
on(:ok) do
|
|
48
|
-
flash[:notice] = I18n.t("participatory_space_private_users.update.success", scope: "decidim.admin")
|
|
49
|
-
redirect_to action: :index
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
on(:invalid) do
|
|
53
|
-
flash.now[:alert] = I18n.t("participatory_space_private_users.update.error", scope: "decidim.admin")
|
|
54
|
-
render template: "decidim/admin/participatory_space_private_users/edit", status: :unprocessable_entity
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def create
|
|
60
|
-
enforce_permission_to :create, :space_private_user
|
|
61
|
-
@form = form(ParticipatorySpacePrivateUserForm).from_params(params, privatable_to:)
|
|
62
|
-
|
|
63
|
-
CreateParticipatorySpacePrivateUser.call(@form, current_participatory_space) do
|
|
64
|
-
on(:ok) do
|
|
65
|
-
flash[:notice] = I18n.t("participatory_space_private_users.create.success", scope: "decidim.admin")
|
|
66
|
-
redirect_to action: :index
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
on(:invalid) do
|
|
70
|
-
flash.now[:alert] = I18n.t("participatory_space_private_users.create.error", scope: "decidim.admin")
|
|
71
|
-
render template: "decidim/admin/participatory_space_private_users/new", status: :unprocessable_entity
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def destroy
|
|
77
|
-
enforce_permission_to :destroy, :space_private_user, private_user: @private_user
|
|
78
|
-
|
|
79
|
-
DestroyParticipatorySpacePrivateUser.call(@private_user, current_user) do
|
|
80
|
-
on(:ok) do
|
|
81
|
-
flash[:notice] = I18n.t("participatory_space_private_users.destroy.success", scope: "decidim.admin")
|
|
82
|
-
redirect_to after_destroy_path
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
on(:invalid) do
|
|
86
|
-
flash.now[:alert] = I18n.t("participatory_space_private_users.destroy.error", scope: "decidim.admin")
|
|
87
|
-
render template: "decidim/admin/participatory_space_private_users/index", status: :unprocessable_entity
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def resend_invitation
|
|
93
|
-
enforce_permission_to :invite, :space_private_user, private_user: @private_user
|
|
94
|
-
InviteUserAgain.call(@private_user.user, "invite_private_user") do
|
|
95
|
-
on(:ok) do
|
|
96
|
-
flash[:notice] = I18n.t("users.resend_invitation.success", scope: "decidim.admin")
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
on(:invalid) do
|
|
100
|
-
flash[:alert] = I18n.t("users.resend_invitation.error", scope: "decidim.admin")
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
redirect_to after_destroy_path
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def publish_all
|
|
108
|
-
PublishAllParticipatorySpacePrivateUsers.call(current_participatory_space, current_user) do
|
|
109
|
-
on(:ok) do
|
|
110
|
-
flash[:notice] = I18n.t("participatory_space_private_users.publish_all.success", scope: "decidim.admin")
|
|
111
|
-
redirect_to action: :index
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
on(:invalid) do
|
|
115
|
-
flash[:alert] = I18n.t("participatory_space_private_users.publish_all.error", scope: "decidim.admin")
|
|
116
|
-
redirect_to action: :index
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def unpublish_all
|
|
122
|
-
UnpublishAllParticipatorySpacePrivateUsers.call(current_participatory_space, current_user) do
|
|
123
|
-
on(:ok) do
|
|
124
|
-
flash[:notice] = I18n.t("participatory_space_private_users.unpublish_all.success", scope: "decidim.admin")
|
|
125
|
-
redirect_to action: :index
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
on(:invalid) do
|
|
129
|
-
flash[:alert] = I18n.t("participatory_space_private_users.unpublish_all.error", scope: "decidim.admin")
|
|
130
|
-
redirect_to action: :index
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
# Public: Returns a String or Object that will be passed to `redirect_to` after
|
|
136
|
-
# destroying a private user. By default it redirects to the privatable_to.
|
|
137
|
-
#
|
|
138
|
-
# It can be redefined at controller level if you need to redirect elsewhere.
|
|
139
|
-
def after_destroy_path
|
|
140
|
-
privatable_to
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
# Public: The only method to be implemented at the controller. You need to
|
|
144
|
-
# return the object where the attachment will be attached to.
|
|
145
|
-
def privatable_to
|
|
146
|
-
raise NotImplementedError
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def collection
|
|
150
|
-
# there is an unidentified corner case where Decidim::User
|
|
151
|
-
# may have been destroyed, but the related ParticipatorySpacePrivateUser
|
|
152
|
-
# remains in the database. That is why filtering by not null users
|
|
153
|
-
@collection ||= privatable_to
|
|
154
|
-
.participatory_space_private_users
|
|
155
|
-
.includes(:user).where.not("decidim_users.id" => nil)
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def participatory_space_private_users
|
|
159
|
-
filtered_collection
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
def set_private_user
|
|
163
|
-
@private_user = collection.find(params[:id])
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Decidim
|
|
4
|
-
module Admin
|
|
5
|
-
module Concerns
|
|
6
|
-
# PrivateUsers can be related to any ParticipatorySpace, in order to
|
|
7
|
-
# import private users from csv for a given type, you should create a new
|
|
8
|
-
# controller and include this concern.
|
|
9
|
-
#
|
|
10
|
-
# The only requirement is to define a `privatable_to` method that
|
|
11
|
-
# returns an instance of the model to relate the private_user to.
|
|
12
|
-
module HasPrivateUsersCsvImport
|
|
13
|
-
extend ActiveSupport::Concern
|
|
14
|
-
|
|
15
|
-
included do
|
|
16
|
-
helper_method :privatable_to
|
|
17
|
-
|
|
18
|
-
def new
|
|
19
|
-
enforce_permission_to :csv_import, :space_private_user
|
|
20
|
-
@form = form(ParticipatorySpacePrivateUserCsvImportForm).from_params({}, privatable_to:)
|
|
21
|
-
@count = Decidim::ParticipatorySpacePrivateUser.by_participatory_space(privatable_to).count
|
|
22
|
-
render template: "decidim/admin/participatory_space_private_users_csv_imports/new"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def create
|
|
26
|
-
enforce_permission_to :csv_import, :space_private_user
|
|
27
|
-
@form = form(ParticipatorySpacePrivateUserCsvImportForm).from_params(params, privatable_to:)
|
|
28
|
-
|
|
29
|
-
ProcessParticipatorySpacePrivateUserImportCsv.call(@form, current_participatory_space) do
|
|
30
|
-
on(:ok) do
|
|
31
|
-
flash[:notice] = I18n.t("participatory_space_private_users_csv_imports.create.success", scope: "decidim.admin")
|
|
32
|
-
redirect_to after_import_path
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
on(:invalid) do
|
|
36
|
-
flash[:alert] = I18n.t("participatory_space_private_users_csv_imports.create.invalid", scope: "decidim.admin")
|
|
37
|
-
render template: "decidim/admin/participatory_space_private_users_csv_imports/new", status: :unprocessable_entity
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def destroy_all
|
|
43
|
-
enforce_permission_to :csv_import, :space_private_user
|
|
44
|
-
Decidim::ParticipatorySpacePrivateUser.by_participatory_space(privatable_to).delete_all
|
|
45
|
-
redirect_to new_participatory_space_private_users_csv_imports_path
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# Public: Returns a String or Object that will be passed to `redirect_to` after
|
|
49
|
-
# importing private users. By default it redirects to the privatable_to.
|
|
50
|
-
#
|
|
51
|
-
# It can be redefined at controller level if you need to redirect elsewhere.
|
|
52
|
-
def after_import_path
|
|
53
|
-
privatable_to
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Public: The only method to be implemented at the controller. You need to
|
|
57
|
-
# return the object where the attachment will be attached to.
|
|
58
|
-
def privatable_to
|
|
59
|
-
raise NotImplementedError
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "csv"
|
|
4
|
-
|
|
5
|
-
module Decidim
|
|
6
|
-
module Admin
|
|
7
|
-
# A form object used to upload CSV to batch participatory space private users.
|
|
8
|
-
#
|
|
9
|
-
class ParticipatorySpacePrivateUserCsvImportForm < Form
|
|
10
|
-
include Decidim::HasUploadValidations
|
|
11
|
-
include Decidim::Admin::CustomImport
|
|
12
|
-
|
|
13
|
-
attribute :file, Decidim::Attributes::Blob
|
|
14
|
-
attribute :user_name, String
|
|
15
|
-
attribute :email, String
|
|
16
|
-
|
|
17
|
-
validates :file, presence: true, file_content_type: { allow: ["text/csv"] }
|
|
18
|
-
validate :validate_csv
|
|
19
|
-
|
|
20
|
-
def validate_csv
|
|
21
|
-
return if file.blank?
|
|
22
|
-
|
|
23
|
-
process_import_file(file) do |(_email, user_name)|
|
|
24
|
-
errors.add(:user_name, :invalid) if user_name.blank? || !user_name.match?(UserBaseEntity::REGEXP_NAME)
|
|
25
|
-
end
|
|
26
|
-
rescue CSV::MalformedCSVError
|
|
27
|
-
errors.add(:file, :malformed)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Decidim
|
|
4
|
-
module Admin
|
|
5
|
-
# A form object used to create participatory space private users from the
|
|
6
|
-
# admin dashboard.
|
|
7
|
-
#
|
|
8
|
-
class ParticipatorySpacePrivateUserForm < Form
|
|
9
|
-
include TranslatableAttributes
|
|
10
|
-
|
|
11
|
-
mimic :participatory_space_private_user
|
|
12
|
-
|
|
13
|
-
attribute :name, String
|
|
14
|
-
attribute :email, String
|
|
15
|
-
attribute :published, Boolean
|
|
16
|
-
|
|
17
|
-
translatable_attribute :role, String
|
|
18
|
-
|
|
19
|
-
validates :name, :email, presence: true
|
|
20
|
-
|
|
21
|
-
validates :name, format: { with: UserBaseEntity::REGEXP_NAME }
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Decidim
|
|
4
|
-
module Admin
|
|
5
|
-
class DestroyPrivateUsersFollowsJob < ApplicationJob
|
|
6
|
-
queue_as :default
|
|
7
|
-
|
|
8
|
-
def perform(decidim_user_id, space)
|
|
9
|
-
return unless space.respond_to?(:private_space?)
|
|
10
|
-
|
|
11
|
-
return unless space.private_space?
|
|
12
|
-
|
|
13
|
-
return if space.respond_to?(:is_transparent) && space.is_transparent?
|
|
14
|
-
|
|
15
|
-
user = Decidim::User.find_by(id: decidim_user_id)
|
|
16
|
-
|
|
17
|
-
return if user.blank?
|
|
18
|
-
|
|
19
|
-
return if space.respond_to?(:can_participate?) && space.can_participate?(user)
|
|
20
|
-
|
|
21
|
-
follows = Decidim::Follow.where(user: user)
|
|
22
|
-
follows.where(followable: space).destroy_all
|
|
23
|
-
|
|
24
|
-
destroy_children_follows(follows, space)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def destroy_children_follows(follows, space)
|
|
28
|
-
follows.map do |follow|
|
|
29
|
-
object = follow.followable.presence
|
|
30
|
-
next unless object.respond_to?(:decidim_component_id)
|
|
31
|
-
|
|
32
|
-
follow.destroy if space.component_ids.include?(object.decidim_component_id)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Decidim
|
|
4
|
-
module Admin
|
|
5
|
-
# Custom ApplicationJob scoped to the admin panel.
|
|
6
|
-
#
|
|
7
|
-
class ImportParticipatorySpacePrivateUserCsvJob < ApplicationJob
|
|
8
|
-
queue_as :exports
|
|
9
|
-
|
|
10
|
-
def perform(email, user_name, privatable_to, current_user)
|
|
11
|
-
return if email.blank? || user_name.blank?
|
|
12
|
-
|
|
13
|
-
params = {
|
|
14
|
-
name: user_name,
|
|
15
|
-
email: email.downcase.strip
|
|
16
|
-
}
|
|
17
|
-
private_user_form = ParticipatorySpacePrivateUserForm.from_params(params, privatable_to:)
|
|
18
|
-
.with_context(
|
|
19
|
-
current_user:,
|
|
20
|
-
current_participatory_space: privatable_to
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
Decidim::Admin::CreateParticipatorySpacePrivateUser.call(private_user_form, privatable_to, via_csv: true)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<p>Hello <%= @resource.email %>!</p>
|
|
2
|
-
|
|
3
|
-
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
|
|
4
|
-
|
|
5
|
-
<p><%= link_to "Change my password", edit_password_url(@resource, reset_password_token: @token) %></p>
|
|
6
|
-
|
|
7
|
-
<p>If you did not request this, please ignore this email.</p>
|
|
8
|
-
<p>Your password will not change until you access the link above and create a new one.</p>
|
|
File without changes
|