decidim-admin 0.10.1 → 0.11.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim-admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/assets/config/decidim_admin_manifest.js +1 -0
- data/app/assets/javascripts/decidim/admin/application.js.es6 +13 -5
- data/app/assets/javascripts/decidim/admin/auto_buttons_by_position.component.js.es6 +42 -0
- data/app/assets/javascripts/decidim/admin/auto_label_by_position.component.js.es6 +33 -0
- data/app/assets/javascripts/decidim/admin/dynamic_fields.component.js.es6 +163 -0
- data/app/assets/javascripts/decidim/admin/field_dependent_inputs.component.js.es6 +39 -0
- data/app/assets/javascripts/decidim/admin/managed_users.js.es6 +12 -0
- data/app/assets/javascripts/decidim/admin/sort_list.component.js.es6 +1 -1
- data/app/assets/javascripts/decidim/admin/subform_toggler.component.js.es6 +35 -0
- data/app/assets/javascripts/decidim/admin/tab_focus.js.es6 +4 -4
- data/app/assets/stylesheets/decidim/admin/application.scss.erb +1 -1
- data/app/assets/stylesheets/decidim/admin/extra/_dropdown_inverted.scss +7 -5
- data/app/assets/stylesheets/decidim/admin/modules/_agenda.scss +34 -0
- data/app/assets/stylesheets/decidim/admin/modules/_buttons.scss +5 -0
- data/app/assets/stylesheets/decidim/admin/modules/_cards.scss +15 -0
- data/app/assets/stylesheets/decidim/admin/modules/_forms.scss +4 -0
- data/app/assets/stylesheets/decidim/admin/modules/_modules.scss +1 -0
- data/app/assets/stylesheets/decidim/admin/modules/_typography.scss +8 -0
- data/app/assets/stylesheets/decidim/admin/utils/_flex.scss +2 -2
- data/app/assets/stylesheets/decidim/admin/utils/_helpers.scss +28 -0
- data/app/assets/stylesheets/decidim/admin/utils/_mixins.scss +44 -0
- data/app/commands/decidim/admin/create_area.rb +3 -1
- data/app/commands/decidim/admin/{create_feature.rb → create_component.rb} +11 -11
- data/app/commands/decidim/admin/create_oauth_application.rb +36 -0
- data/app/commands/decidim/admin/create_participatory_space_private_user.rb +85 -0
- data/app/commands/decidim/admin/destroy_area.rb +42 -0
- data/app/commands/decidim/admin/{destroy_feature.rb → destroy_component.rb} +11 -11
- data/app/commands/decidim/admin/destroy_oauth_application.rb +39 -0
- data/app/commands/decidim/admin/{impersonate_managed_user.rb → impersonate_user.rb} +19 -13
- data/app/commands/decidim/admin/publish_component.rb +51 -0
- data/app/commands/decidim/admin/{unpublish_feature.rb → unpublish_component.rb} +12 -12
- data/app/commands/decidim/admin/update_area.rb +5 -1
- data/app/commands/decidim/admin/update_component.rb +62 -0
- data/app/commands/decidim/admin/{update_feature_permissions.rb → update_component_permissions.rb} +10 -10
- data/app/commands/decidim/admin/update_oauth_application.rb +39 -0
- data/app/controllers/decidim/admin/application_controller.rb +1 -1
- data/app/controllers/decidim/admin/areas_controller.rb +6 -4
- data/app/controllers/decidim/admin/{feature_permissions_controller.rb → component_permissions_controller.rb} +12 -12
- data/app/controllers/decidim/admin/{features → components}/base_controller.rb +9 -9
- data/app/controllers/decidim/admin/components_controller.rb +142 -0
- data/app/controllers/decidim/admin/concerns/has_private_users.rb +102 -0
- data/app/controllers/decidim/admin/dashboard_controller.rb +1 -1
- data/app/controllers/decidim/admin/exports_controller.rb +6 -6
- data/app/controllers/decidim/admin/impersonatable_users_controller.rb +29 -0
- data/app/controllers/decidim/admin/impersonations_controller.rb +122 -0
- data/app/controllers/decidim/admin/logs_controller.rb +1 -1
- data/app/controllers/decidim/admin/managed_users/impersonation_logs_controller.rb +25 -0
- data/app/controllers/decidim/admin/managed_users/promotions_controller.rb +3 -5
- data/app/controllers/decidim/admin/newsletters_controller.rb +1 -1
- data/app/controllers/decidim/admin/oauth_applications_controller.rb +90 -0
- data/app/controllers/decidim/admin/officializations_controller.rb +4 -3
- data/app/events/decidim/component_published_event.rb +6 -0
- data/app/forms/decidim/admin/{feature_form.rb → component_form.rb} +3 -3
- data/app/forms/decidim/admin/impersonate_user_form.rb +26 -0
- data/app/forms/decidim/admin/oauth_application_form.rb +32 -0
- data/app/forms/decidim/admin/organization_appearance_form.rb +6 -1
- data/app/forms/decidim/admin/organization_form.rb +1 -1
- data/app/forms/decidim/admin/participatory_space_private_user_form.rb +18 -0
- data/app/forms/decidim/admin/permissions_form.rb +1 -1
- data/app/helpers/decidim/admin/attributes_display_helper.rb +10 -3
- data/app/helpers/decidim/admin/bulk_actions_helper.rb +36 -0
- data/app/helpers/decidim/admin/exports_helper.rb +10 -10
- data/app/helpers/decidim/admin/settings_helper.rb +1 -1
- data/app/models/decidim/admin/abilities/admin_ability.rb +12 -9
- data/app/models/decidim/admin/abilities/participatory_process_admin_ability.rb +2 -2
- data/app/models/decidim/admin/abilities/user_manager_ability.rb +7 -6
- data/app/queries/decidim/admin/user_filter.rb +59 -0
- data/app/views/decidim/admin/area_types/edit.html.erb +1 -1
- data/app/views/decidim/admin/area_types/index.html.erb +2 -2
- data/app/views/decidim/admin/area_types/new.html.erb +1 -1
- data/app/views/decidim/admin/areas/edit.html.erb +1 -1
- data/app/views/decidim/admin/areas/index.html.erb +2 -2
- data/app/views/decidim/admin/areas/new.html.erb +1 -1
- data/app/views/decidim/admin/attachment_collections/edit.html.erb +1 -1
- data/app/views/decidim/admin/attachment_collections/index.html.erb +2 -2
- data/app/views/decidim/admin/attachment_collections/new.html.erb +1 -1
- data/app/views/decidim/admin/attachment_collections/show.html.erb +2 -3
- data/app/views/decidim/admin/attachments/edit.html.erb +1 -1
- data/app/views/decidim/admin/attachments/index.html.erb +1 -1
- data/app/views/decidim/admin/attachments/new.html.erb +1 -1
- data/app/views/decidim/admin/attachments/show.html.erb +2 -3
- data/app/views/decidim/admin/bulk_actions/_recategorize.html.erb +1 -1
- data/app/views/decidim/admin/categories/edit.html.erb +1 -1
- data/app/views/decidim/admin/categories/index.html.erb +2 -2
- data/app/views/decidim/admin/categories/new.html.erb +1 -1
- data/app/views/decidim/admin/categories/show.html.erb +2 -3
- data/app/views/decidim/admin/{feature_permissions → component_permissions}/edit.html.erb +3 -3
- data/app/views/decidim/admin/components/_component.html.erb +37 -0
- data/app/views/decidim/admin/{features → components}/_form.html.erb +6 -6
- data/app/views/decidim/admin/{features → components}/_settings_fields.html.erb +2 -2
- data/app/views/decidim/admin/components/edit.html.erb +7 -0
- data/app/views/decidim/admin/{features → components}/index.html.erb +6 -6
- data/app/views/decidim/admin/components/new.html.erb +8 -0
- data/app/views/decidim/admin/devise/mailers/reset_password_instructions.html.erb +1 -1
- data/app/views/decidim/admin/exports/_dropdown.html.erb +3 -3
- data/app/views/decidim/admin/impersonatable_users/index.html.erb +84 -0
- data/app/views/decidim/admin/impersonations/_form.html.erb +40 -0
- data/app/views/decidim/admin/impersonations/_handler_form.html.erb +5 -0
- data/app/views/decidim/admin/impersonations/new.html.erb +23 -0
- data/app/views/decidim/admin/managed_users/{impersonations → impersonation_logs}/index.html.erb +2 -0
- data/app/views/decidim/admin/managed_users/promotions/new.html.erb +4 -4
- data/app/views/decidim/admin/moderations/index.html.erb +2 -2
- data/app/views/decidim/admin/newsletters/_form.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/edit.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/index.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/new.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/show.html.erb +1 -1
- data/app/views/decidim/admin/oauth_applications/_form.html.erb +19 -0
- data/app/views/decidim/admin/oauth_applications/edit.html.erb +13 -0
- data/app/views/decidim/admin/oauth_applications/index.html.erb +38 -0
- data/app/views/decidim/admin/oauth_applications/new.html.erb +13 -0
- data/app/views/decidim/admin/oauth_applications/show.html.erb +27 -0
- data/app/views/decidim/admin/officializations/index.html.erb +2 -2
- data/app/views/decidim/admin/officializations/new.html.erb +2 -2
- data/app/views/decidim/admin/organization/_form.html.erb +1 -1
- data/app/views/decidim/admin/organization/edit.html.erb +1 -2
- data/app/views/decidim/admin/organization_appearance/edit.html.erb +1 -2
- data/app/views/decidim/admin/participatory_space_private_users/_form.html.erb +18 -0
- data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +59 -0
- data/app/views/decidim/admin/participatory_space_private_users/new.html.erb +7 -0
- data/app/views/decidim/admin/scope_types/edit.html.erb +1 -1
- data/app/views/decidim/admin/scope_types/index.html.erb +2 -2
- data/app/views/decidim/admin/scope_types/new.html.erb +1 -1
- data/app/views/decidim/admin/scopes/edit.html.erb +1 -1
- data/app/views/decidim/admin/scopes/index.html.erb +3 -3
- data/app/views/decidim/admin/scopes/new.html.erb +1 -1
- data/app/views/decidim/admin/static_pages/edit.html.erb +1 -1
- data/app/views/decidim/admin/static_pages/index.html.erb +3 -3
- data/app/views/decidim/admin/static_pages/new.html.erb +1 -1
- data/app/views/decidim/admin/static_pages/show.html.erb +2 -3
- data/app/views/decidim/admin/user_groups/index.html.erb +3 -3
- data/app/views/decidim/admin/users/_form.html.erb +3 -3
- data/app/views/decidim/admin/users/index.html.erb +2 -2
- data/app/views/decidim/admin/users/new.html.erb +1 -1
- data/app/views/layouts/decidim/admin/_application.html.erb +9 -9
- data/app/views/layouts/decidim/admin/_header.html.erb +3 -4
- data/app/views/layouts/decidim/admin/_template_top.html.erb +1 -1
- data/app/views/layouts/decidim/admin/_title_bar.html.erb +1 -1
- data/app/views/layouts/decidim/admin/login.html.erb +1 -1
- data/app/views/layouts/decidim/admin/pages.html.erb +1 -1
- data/app/views/layouts/decidim/admin/users.html.erb +5 -3
- data/config/locales/ca.yml +119 -50
- data/config/locales/en.yml +119 -50
- data/config/locales/es.yml +120 -51
- data/config/locales/eu.yml +122 -53
- data/config/locales/fi.yml +121 -52
- data/config/locales/fr.yml +159 -90
- data/config/locales/gl.yml +119 -50
- data/config/locales/it.yml +120 -51
- data/config/locales/nl.yml +207 -138
- data/config/locales/pl.yml +119 -50
- data/config/locales/pt-BR.yml +120 -51
- data/config/locales/pt.yml +120 -51
- data/config/locales/ru.yml +7 -51
- data/config/locales/sv.yml +120 -51
- data/config/locales/uk.yml +7 -52
- data/config/routes.rb +6 -2
- data/db/migrate/20180413233318_add_reason_to_decidim_impersonation_logs.rb +7 -0
- data/lib/decidim/admin/components.rb +11 -0
- data/lib/decidim/admin/engine.rb +12 -3
- data/lib/decidim/admin/test/forms/attachment_collection_form_examples.rb +9 -9
- data/lib/decidim/admin/test/forms/attachment_form_examples.rb +1 -1
- data/lib/decidim/admin/test/forms/category_form_examples.rb +11 -11
- data/lib/decidim/admin/test/{manage_feature_permissions_examples.rb → manage_component_permissions_examples.rb} +9 -9
- data/lib/decidim/admin/test/manage_moderations_examples.rb +2 -2
- data/lib/decidim/admin/test.rb +1 -1
- data/lib/decidim/admin/version.rb +1 -1
- data/lib/decidim/admin.rb +1 -1
- metadata +66 -43
- data/app/commands/decidim/admin/create_managed_user.rb +0 -69
- data/app/commands/decidim/admin/publish_feature.rb +0 -51
- data/app/commands/decidim/admin/update_feature.rb +0 -62
- data/app/controllers/decidim/admin/features_controller.rb +0 -142
- data/app/controllers/decidim/admin/managed_users/impersonations_controller.rb +0 -78
- data/app/controllers/decidim/admin/managed_users_controller.rb +0 -83
- data/app/events/decidim/feature_published_event.rb +0 -6
- data/app/forms/decidim/admin/impersonate_managed_user_form.rb +0 -20
- data/app/forms/decidim/admin/managed_user_form.rb +0 -24
- data/app/queries/decidim/admin/users_officialization.rb +0 -56
- data/app/views/decidim/admin/features/_feature.html.erb +0 -37
- data/app/views/decidim/admin/features/edit.html.erb +0 -7
- data/app/views/decidim/admin/features/new.html.erb +0 -8
- data/app/views/decidim/admin/managed_users/_form.html.erb +0 -12
- data/app/views/decidim/admin/managed_users/impersonations/_form.html.erb +0 -10
- data/app/views/decidim/admin/managed_users/impersonations/new.html.erb +0 -15
- data/app/views/decidim/admin/managed_users/index.html.erb +0 -44
- data/app/views/decidim/admin/managed_users/new.html.erb +0 -47
- data/lib/decidim/admin/features.rb +0 -11
@@ -58,11 +58,13 @@ module Decidim
|
|
58
58
|
|
59
59
|
def destroy
|
60
60
|
authorize! :destroy, area
|
61
|
-
area.destroy!
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
DestroyArea.call(area, current_user) do
|
63
|
+
on(:ok) do
|
64
|
+
flash[:notice] = I18n.t("areas.destroy.success", scope: "decidim.admin")
|
65
|
+
redirect_to areas_path
|
66
|
+
end
|
67
|
+
end
|
66
68
|
end
|
67
69
|
|
68
70
|
private
|
@@ -2,26 +2,26 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
|
-
# Controller that allows managing
|
5
|
+
# Controller that allows managing component permissions.
|
6
6
|
#
|
7
|
-
class
|
8
|
-
helper_method :authorizations, :
|
7
|
+
class ComponentPermissionsController < Decidim::Admin::ApplicationController
|
8
|
+
helper_method :authorizations, :component
|
9
9
|
|
10
10
|
def edit
|
11
|
-
authorize! :update,
|
11
|
+
authorize! :update, component
|
12
12
|
@permissions_form = PermissionsForm.new(
|
13
13
|
permissions: permission_forms
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
17
|
def update
|
18
|
-
authorize! :update,
|
18
|
+
authorize! :update, component
|
19
19
|
@permissions_form = PermissionsForm.from_params(params)
|
20
20
|
|
21
|
-
|
21
|
+
UpdateComponentPermissions.call(@permissions_form, component) do
|
22
22
|
on(:ok) do
|
23
|
-
flash[:notice] = t("
|
24
|
-
redirect_to
|
23
|
+
flash[:notice] = t("component_permissions.update.success", scope: "decidim.admin")
|
24
|
+
redirect_to components_path(current_participatory_space)
|
25
25
|
end
|
26
26
|
|
27
27
|
on(:invalid) do
|
@@ -33,9 +33,9 @@ module Decidim
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def permission_forms
|
36
|
-
permissions =
|
36
|
+
permissions = component.permissions || {}
|
37
37
|
|
38
|
-
@permission_forms ||=
|
38
|
+
@permission_forms ||= component.manifest.actions.inject({}) do |result, action|
|
39
39
|
form = PermissionForm.new(
|
40
40
|
authorization_handler_name: permissions.dig(action, "authorization_handler_name"),
|
41
41
|
options: permissions.dig(action, "options").try(:to_json)
|
@@ -51,8 +51,8 @@ module Decidim
|
|
51
51
|
)
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
55
|
-
@
|
54
|
+
def component
|
55
|
+
@component ||= current_participatory_space.components.find(params[:component_id])
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
|
-
module
|
6
|
-
# This controller is the abstract class from which all
|
5
|
+
module Components
|
6
|
+
# This controller is the abstract class from which all component
|
7
7
|
# controllers in their admin engines should inherit from.
|
8
8
|
class BaseController < Admin::ApplicationController
|
9
9
|
skip_authorize_resource
|
@@ -16,28 +16,28 @@ module Decidim
|
|
16
16
|
helper Decidim::Admin::ExportsHelper
|
17
17
|
helper Decidim::Admin::BulkActionsHelper
|
18
18
|
|
19
|
-
helper_method :
|
19
|
+
helper_method :current_component,
|
20
20
|
:current_participatory_space,
|
21
21
|
:parent_path
|
22
22
|
|
23
23
|
before_action except: [:index, :show] do
|
24
|
-
authorize! :manage,
|
24
|
+
authorize! :manage, current_component
|
25
25
|
end
|
26
26
|
|
27
27
|
before_action on: [:index, :show] do
|
28
|
-
authorize! :read,
|
28
|
+
authorize! :read, current_component
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
request.env["decidim.
|
31
|
+
def current_component
|
32
|
+
request.env["decidim.current_component"]
|
33
33
|
end
|
34
34
|
|
35
35
|
def current_participatory_space
|
36
|
-
|
36
|
+
current_component.participatory_space
|
37
37
|
end
|
38
38
|
|
39
39
|
def parent_path
|
40
|
-
@parent_path ||= EngineRouter.admin_proxy(current_participatory_space).
|
40
|
+
@parent_path ||= EngineRouter.admin_proxy(current_participatory_space).components_path
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# Controller that allows managing the Participatory Process' Components in the
|
6
|
+
# admin panel.
|
7
|
+
#
|
8
|
+
class ComponentsController < Decidim::Admin::ApplicationController
|
9
|
+
helper_method :manifest, :current_participatory_space
|
10
|
+
|
11
|
+
def index
|
12
|
+
authorize! :read, Component
|
13
|
+
@manifests = Decidim.component_manifests
|
14
|
+
@components = current_participatory_space.components
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
authorize! :create, Component
|
19
|
+
|
20
|
+
@component = Component.new(
|
21
|
+
name: default_name(manifest),
|
22
|
+
manifest_name: params[:type],
|
23
|
+
participatory_space: current_participatory_space
|
24
|
+
)
|
25
|
+
|
26
|
+
@form = form(ComponentForm).from_model(@component)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create
|
30
|
+
@form = form(ComponentForm).from_params(params)
|
31
|
+
authorize! :create, Component
|
32
|
+
|
33
|
+
CreateComponent.call(manifest, @form, current_participatory_space) do
|
34
|
+
on(:ok) do
|
35
|
+
flash[:notice] = I18n.t("components.create.success", scope: "decidim.admin")
|
36
|
+
redirect_to action: :index
|
37
|
+
end
|
38
|
+
|
39
|
+
on(:invalid) do
|
40
|
+
flash.now[:alert] = I18n.t("components.create.error", scope: "decidim.admin")
|
41
|
+
render action: "new"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def edit
|
47
|
+
@component = query_scope.find(params[:id])
|
48
|
+
authorize! :update, @component
|
49
|
+
|
50
|
+
@form = form(ComponentForm).from_model(@component)
|
51
|
+
end
|
52
|
+
|
53
|
+
def update
|
54
|
+
@component = query_scope.find(params[:id])
|
55
|
+
@form = form(ComponentForm).from_params(params)
|
56
|
+
authorize! :update, @component
|
57
|
+
|
58
|
+
UpdateComponent.call(@form, @component) do
|
59
|
+
on(:ok) do |settings_changed, previous_settings, current_settings|
|
60
|
+
handle_component_settings_change(previous_settings, current_settings) if settings_changed
|
61
|
+
|
62
|
+
flash[:notice] = I18n.t("components.update.success", scope: "decidim.admin")
|
63
|
+
redirect_to action: :index
|
64
|
+
end
|
65
|
+
|
66
|
+
on(:invalid) do
|
67
|
+
flash.now[:alert] = I18n.t("components.update.error", scope: "decidim.admin")
|
68
|
+
render action: "new"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def destroy
|
74
|
+
@component = query_scope.find(params[:id])
|
75
|
+
authorize! :destroy, @component
|
76
|
+
|
77
|
+
DestroyComponent.call(@component, current_user) do
|
78
|
+
on(:ok) do
|
79
|
+
flash[:notice] = I18n.t("components.destroy.success", scope: "decidim.admin")
|
80
|
+
redirect_to action: :index
|
81
|
+
end
|
82
|
+
|
83
|
+
on(:invalid) do
|
84
|
+
flash[:alert] = I18n.t("components.destroy.error", scope: "decidim.admin")
|
85
|
+
redirect_to action: :index
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def publish
|
91
|
+
@component = query_scope.find(params[:id])
|
92
|
+
authorize! :update, @component
|
93
|
+
|
94
|
+
PublishComponent.call(@component, current_user) do
|
95
|
+
on(:ok) do
|
96
|
+
flash[:notice] = I18n.t("components.publish.success", scope: "decidim.admin")
|
97
|
+
redirect_to action: :index
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def unpublish
|
103
|
+
@component = query_scope.find(params[:id])
|
104
|
+
authorize! :update, @component
|
105
|
+
|
106
|
+
UnpublishComponent.call(@component, current_user) do
|
107
|
+
on(:ok) do
|
108
|
+
flash[:notice] = I18n.t("components.unpublish.success", scope: "decidim.admin")
|
109
|
+
redirect_to action: :index
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def query_scope
|
117
|
+
current_participatory_space.components
|
118
|
+
end
|
119
|
+
|
120
|
+
def manifest
|
121
|
+
Decidim.find_component_manifest(params[:type])
|
122
|
+
end
|
123
|
+
|
124
|
+
def default_name(manifest)
|
125
|
+
TranslationsHelper.multi_translation(
|
126
|
+
"decidim.components.#{manifest.name}.name",
|
127
|
+
current_organization.available_locales
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
def handle_component_settings_change(previous_settings, current_settings)
|
132
|
+
return if @component.participatory_space.allows_steps?
|
133
|
+
|
134
|
+
Decidim::SettingsChange.publish(
|
135
|
+
@component,
|
136
|
+
previous_settings["default_step"] || {},
|
137
|
+
current_settings["default_step"] || {}
|
138
|
+
)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,102 @@
|
|
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
|
+
helper_method :privatable_to, :authorization_object, :collection
|
17
|
+
|
18
|
+
def index
|
19
|
+
authorize! :read, authorization_object
|
20
|
+
|
21
|
+
render template: "decidim/admin/participatory_space_private_users/index"
|
22
|
+
end
|
23
|
+
|
24
|
+
def new
|
25
|
+
authorize! :create, authorization_object
|
26
|
+
@form = form(ParticipatorySpacePrivateUserForm).from_params({}, privatable_to: privatable_to)
|
27
|
+
render template: "decidim/admin/participatory_space_private_users/new"
|
28
|
+
end
|
29
|
+
|
30
|
+
def create
|
31
|
+
authorize! :create, authorization_object
|
32
|
+
@form = form(ParticipatorySpacePrivateUserForm).from_params(params, privatable_to: privatable_to)
|
33
|
+
|
34
|
+
CreateParticipatorySpacePrivateUser.call(@form, current_user, current_participatory_space) do
|
35
|
+
on(:ok) do
|
36
|
+
flash[:notice] = I18n.t("participatory_space_private_users.create.success", scope: "decidim.admin")
|
37
|
+
redirect_to action: :index
|
38
|
+
end
|
39
|
+
|
40
|
+
on(:invalid) do
|
41
|
+
flash.now[:alert] = I18n.t("participatory_space_private_users.create.error", scope: "decidim.admin")
|
42
|
+
render template: "decidim/admin/participatory_space_private_users/new"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def destroy
|
48
|
+
@private_user = collection.find(params[:id])
|
49
|
+
authorize! :destroy, authorization_object
|
50
|
+
@private_user.destroy!
|
51
|
+
|
52
|
+
flash[:notice] = I18n.t("participatory_space_private_users.destroy.success", scope: "decidim.admin")
|
53
|
+
|
54
|
+
redirect_to after_destroy_path
|
55
|
+
end
|
56
|
+
|
57
|
+
def resend_invitation
|
58
|
+
@private_user = collection.find(params[:id])
|
59
|
+
authorize! :invite, authorization_object
|
60
|
+
InviteUserAgain.call(@private_user.user, "invite_private_user") do
|
61
|
+
on(:ok) do
|
62
|
+
flash[:notice] = I18n.t("users.resend_invitation.success", scope: "decidim.admin")
|
63
|
+
end
|
64
|
+
|
65
|
+
on(:invalid) do
|
66
|
+
flash[:alert] = I18n.t("users.resend_invitation.error", scope: "decidim.admin")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
redirect_to after_destroy_path
|
71
|
+
end
|
72
|
+
|
73
|
+
# Public: Returns a String or Object that will be passed to `redirect_to` after
|
74
|
+
# destroying a private user. By default it redirects to the privatable_to.
|
75
|
+
#
|
76
|
+
# It can be redefined at controller level if you need to redirect elsewhere.
|
77
|
+
def after_destroy_path
|
78
|
+
privatable_to
|
79
|
+
end
|
80
|
+
|
81
|
+
# Public: The only method to be implemented at the controller. You need to
|
82
|
+
# return the object where the attachment will be attached to.
|
83
|
+
def privatable_to
|
84
|
+
raise NotImplementedError
|
85
|
+
end
|
86
|
+
|
87
|
+
# Public: The Class or Object to be used with the authorization layer to
|
88
|
+
# verify the user can manage the private users
|
89
|
+
#
|
90
|
+
# By default is the same as the privatable_to.
|
91
|
+
def authorization_object
|
92
|
+
privatable_to
|
93
|
+
end
|
94
|
+
|
95
|
+
def collection
|
96
|
+
@collection ||= privatable_to.participatory_space_private_users
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -14,7 +14,7 @@ module Decidim
|
|
14
14
|
def latest_action_logs
|
15
15
|
@latest_action_logs ||= Decidim::ActionLog
|
16
16
|
.where(organization: current_organization)
|
17
|
-
.includes(:participatory_space, :user, :resource, :
|
17
|
+
.includes(:participatory_space, :user, :resource, :component, :version)
|
18
18
|
.order(created_at: :desc)
|
19
19
|
.first(20)
|
20
20
|
end
|
@@ -4,17 +4,17 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
# This controller allows admins to manage proposals in a participatory process.
|
6
6
|
class ExportsController < Decidim::Admin::ApplicationController
|
7
|
-
include Decidim::
|
7
|
+
include Decidim::ComponentPathHelper
|
8
8
|
|
9
9
|
def create
|
10
|
-
authorize! :manage,
|
10
|
+
authorize! :manage, component
|
11
11
|
name = params[:id]
|
12
12
|
|
13
|
-
ExportJob.perform_later(current_user,
|
13
|
+
ExportJob.perform_later(current_user, component, name, params[:format] || default_format)
|
14
14
|
|
15
15
|
flash[:notice] = t("decidim.admin.exports.notice")
|
16
16
|
|
17
|
-
redirect_back(fallback_location:
|
17
|
+
redirect_back(fallback_location: manage_component_path(component))
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
@@ -23,8 +23,8 @@ module Decidim
|
|
23
23
|
"json"
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
@
|
26
|
+
def component
|
27
|
+
@component ||= current_participatory_space.components.find(params[:component_id])
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# Controller that lists users in order to perform impersonation actions on
|
6
|
+
# them
|
7
|
+
#
|
8
|
+
class ImpersonatableUsersController < Decidim::Admin::ApplicationController
|
9
|
+
layout "decidim/admin/users"
|
10
|
+
|
11
|
+
def index
|
12
|
+
authorize! :index, :impersonatable_users
|
13
|
+
|
14
|
+
@query = params[:q]
|
15
|
+
@state = params[:state]
|
16
|
+
|
17
|
+
@users = Decidim::Admin::UserFilter.for(collection, @query, @state)
|
18
|
+
.page(params[:page])
|
19
|
+
.per(15)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def collection
|
25
|
+
@collection ||= current_organization.users.where(admin: false, roles: [])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# Controller that allows impersonating managed users at the admin panel.
|
6
|
+
#
|
7
|
+
class ImpersonationsController < Decidim::Admin::ApplicationController
|
8
|
+
layout "decidim/admin/users"
|
9
|
+
|
10
|
+
helper_method :available_authorization_handlers,
|
11
|
+
:other_available_authorizations,
|
12
|
+
:creating_managed_user?
|
13
|
+
|
14
|
+
skip_authorization_check only: [:close_session]
|
15
|
+
|
16
|
+
def new
|
17
|
+
authorize! :impersonate, user
|
18
|
+
|
19
|
+
@form = form(ImpersonateUserForm).from_params(
|
20
|
+
user: user,
|
21
|
+
handler_name: handler_name,
|
22
|
+
authorization: Decidim::AuthorizationHandler.handler_for(
|
23
|
+
handler_name,
|
24
|
+
user: user
|
25
|
+
)
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create
|
30
|
+
authorize! :impersonate, user
|
31
|
+
|
32
|
+
@form = form(ImpersonateUserForm).from_params(
|
33
|
+
user: user,
|
34
|
+
handler_name: handler_name,
|
35
|
+
reason: params[:impersonate_user][:reason],
|
36
|
+
authorization: Decidim::AuthorizationHandler.handler_for(
|
37
|
+
handler_name,
|
38
|
+
params[:impersonate_user][:authorization].merge(user: user)
|
39
|
+
)
|
40
|
+
)
|
41
|
+
|
42
|
+
ImpersonateUser.call(@form) do
|
43
|
+
on(:ok) do
|
44
|
+
flash[:notice] = I18n.t("impersonations.create.success", scope: "decidim.admin") if creating_managed_user?
|
45
|
+
redirect_to decidim.root_path
|
46
|
+
end
|
47
|
+
|
48
|
+
on(:invalid) do
|
49
|
+
flash.now[:alert] = I18n.t("impersonations.create.error", scope: "decidim.admin")
|
50
|
+
render :new
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def close_session
|
56
|
+
CloseSessionManagedUser.call(user, current_user) do
|
57
|
+
on(:ok) do
|
58
|
+
flash[:notice] = I18n.t("impersonations.close_session.success", scope: "decidim.admin")
|
59
|
+
redirect_to impersonatable_users_path
|
60
|
+
end
|
61
|
+
|
62
|
+
on(:invalid) do
|
63
|
+
flash.now[:alert] = I18n.t("impersonations.close_session.error", scope: "decidim.admin")
|
64
|
+
redirect_to decidim.root_path
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def user
|
72
|
+
@user ||= if creating_managed_user?
|
73
|
+
new_managed_user
|
74
|
+
else
|
75
|
+
current_organization.users.find(params[:impersonatable_user_id])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def new_managed_user
|
80
|
+
Decidim::User.find_or_initialize_by(
|
81
|
+
organization: current_organization,
|
82
|
+
managed: true,
|
83
|
+
name: params.dig(:impersonate_user, :name)
|
84
|
+
) do |u|
|
85
|
+
u.admin = false
|
86
|
+
u.tos_agreement = true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def creating_managed_user?
|
91
|
+
params[:impersonatable_user_id] == "new_managed_user"
|
92
|
+
end
|
93
|
+
|
94
|
+
def handler_name
|
95
|
+
authorization = params.dig(:impersonate_user, :authorization)
|
96
|
+
return available_authorization_handlers.first.name unless authorization
|
97
|
+
|
98
|
+
authorization[:handler_name]
|
99
|
+
end
|
100
|
+
|
101
|
+
def other_available_authorizations
|
102
|
+
return [] if available_authorization_handlers.size == 1
|
103
|
+
|
104
|
+
other_available_authorization_handlers.map do |authorization_handler|
|
105
|
+
Decidim::AuthorizationHandler.handler_for(authorization_handler.name)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def other_available_authorization_handlers
|
110
|
+
Decidim::Verifications::Adapter.from_collection(
|
111
|
+
current_organization.available_authorization_handlers - [handler_name]
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
def available_authorization_handlers
|
116
|
+
Decidim::Verifications::Adapter.from_collection(
|
117
|
+
current_organization.available_authorization_handlers
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -15,7 +15,7 @@ module Decidim
|
|
15
15
|
@logs ||= Decidim::ActionLog
|
16
16
|
.where(organization: current_organization)
|
17
17
|
.order(created_at: :desc)
|
18
|
-
.includes(:participatory_space, :user, :resource, :
|
18
|
+
.includes(:participatory_space, :user, :resource, :component, :version)
|
19
19
|
.page(params[:page])
|
20
20
|
.per(20)
|
21
21
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
module ManagedUsers
|
6
|
+
# Controller that allows inspecting impersonation logs
|
7
|
+
#
|
8
|
+
class ImpersonationLogsController < Decidim::Admin::ApplicationController
|
9
|
+
layout "decidim/admin/users"
|
10
|
+
|
11
|
+
skip_authorization_check
|
12
|
+
|
13
|
+
def index
|
14
|
+
@impersonation_logs = Decidim::ImpersonationLog.where(user: user).order(started_at: :desc).page(params[:page]).per(15)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def user
|
20
|
+
@user ||= current_organization.users.find(params[:impersonatable_user_id])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_dependency "decidim/admin/application_controller"
|
4
|
-
|
5
3
|
module Decidim
|
6
4
|
module Admin
|
7
5
|
module ManagedUsers
|
8
6
|
# Controller that allows promoting managed users at the admin panel.
|
9
7
|
#
|
10
|
-
class PromotionsController < Admin::ApplicationController
|
8
|
+
class PromotionsController < Decidim::Admin::ApplicationController
|
11
9
|
layout "decidim/admin/users"
|
12
10
|
|
13
11
|
def new
|
@@ -22,7 +20,7 @@ module Decidim
|
|
22
20
|
PromoteManagedUser.call(@form, user, current_user) do
|
23
21
|
on(:ok) do
|
24
22
|
flash[:notice] = I18n.t("managed_users.promotion.success", scope: "decidim.admin")
|
25
|
-
redirect_to
|
23
|
+
redirect_to impersonatable_users_path
|
26
24
|
end
|
27
25
|
|
28
26
|
on(:invalid) do
|
@@ -35,7 +33,7 @@ module Decidim
|
|
35
33
|
private
|
36
34
|
|
37
35
|
def user
|
38
|
-
@user ||= current_organization.users.managed.find(params[:
|
36
|
+
@user ||= current_organization.users.managed.find(params[:impersonatable_user_id])
|
39
37
|
end
|
40
38
|
end
|
41
39
|
end
|
@@ -62,7 +62,7 @@ module Decidim
|
|
62
62
|
|
63
63
|
UpdateNewsletter.call(@newsletter, @form, current_user) do
|
64
64
|
on(:ok) do |newsletter|
|
65
|
-
flash
|
65
|
+
flash[:notice] = I18n.t("newsletters.update.success", scope: "decidim.admin")
|
66
66
|
redirect_to action: :show, id: newsletter.id
|
67
67
|
end
|
68
68
|
|