decidim-admin 0.4.4 → 0.5.0
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/app/assets/javascripts/decidim/admin/application.js.es6 +3 -0
- data/app/assets/javascripts/decidim/admin/participatory_processes.js.es6 +12 -0
- data/app/assets/javascripts/decidim/admin/scopes.js.es6 +20 -0
- data/app/assets/javascripts/decidim/admin/select2.js.es6 +8 -0
- data/app/assets/stylesheets/decidim/admin/_decidim.scss +2 -0
- data/app/assets/stylesheets/decidim/admin/extra/_categories.scss +1 -1
- data/app/assets/stylesheets/decidim/admin/extra/_login.scss +1 -1
- data/app/assets/stylesheets/decidim/admin/extra/_sort.scss +1 -1
- data/app/assets/stylesheets/decidim/admin/modules/_buttons.scss +3 -0
- data/app/assets/stylesheets/decidim/admin/modules/_callouts.scss +0 -1
- data/app/assets/stylesheets/decidim/admin/modules/_cards.scss +47 -0
- data/app/assets/stylesheets/decidim/admin/modules/_secondary-nav.scss +2 -2
- data/app/assets/stylesheets/decidim/admin/modules/_typography.scss +1 -1
- data/app/assets/stylesheets/decidim/admin/plugins/_select2.scss +27 -0
- data/app/assets/stylesheets/decidim/admin/utils/_toggle-expand.scss +1 -1
- data/app/commands/decidim/admin/close_session_managed_user.rb +44 -0
- data/app/commands/decidim/admin/create_feature.rb +2 -1
- data/app/commands/decidim/admin/create_managed_user.rb +61 -0
- data/app/commands/decidim/admin/create_scope.rb +7 -2
- data/app/commands/decidim/admin/create_scope_type.rb +40 -0
- data/app/commands/decidim/admin/impersonate_managed_user.rb +61 -0
- data/app/commands/decidim/admin/promote_managed_user.rb +56 -0
- data/app/commands/decidim/admin/update_participatory_process.rb +3 -1
- data/app/commands/decidim/admin/update_scope.rb +4 -1
- data/app/commands/decidim/admin/update_scope_type.rb +45 -0
- data/app/controllers/decidim/admin/application_controller.rb +2 -1
- data/app/controllers/decidim/admin/categories_controller.rb +3 -3
- data/app/controllers/decidim/admin/exports_controller.rb +1 -1
- data/app/controllers/decidim/admin/managed_users/impersonations_controller.rb +78 -0
- data/app/controllers/decidim/admin/managed_users/promotions_controller.rb +43 -0
- data/app/controllers/decidim/admin/managed_users_controller.rb +69 -0
- data/app/controllers/decidim/admin/moderations_controller.rb +4 -4
- data/app/controllers/decidim/admin/newsletters_controller.rb +1 -1
- data/app/controllers/decidim/admin/participatory_processes_controller.rb +0 -5
- data/app/controllers/decidim/admin/scope_types_controller.rb +79 -0
- data/app/controllers/decidim/admin/scopes_controller.rb +22 -7
- data/app/controllers/decidim/admin/user_groups_controller.rb +1 -1
- data/app/controllers/decidim/admin/users_controller.rb +1 -2
- data/app/forms/decidim/admin/impersonate_managed_user_form.rb +20 -0
- data/app/forms/decidim/admin/managed_user_form.rb +35 -0
- data/app/forms/decidim/admin/managed_user_promotion_form.rb +13 -0
- data/app/forms/decidim/admin/participatory_process_form.rb +2 -0
- data/app/forms/decidim/admin/scope_form.rb +17 -6
- data/app/forms/decidim/admin/scope_type_form.rb +21 -0
- data/app/helpers/decidim/admin/scopes_helper.rb +46 -0
- data/app/helpers/decidim/admin/settings_helper.rb +12 -1
- data/app/jobs/decidim/admin/expire_impersonation_job.rb +16 -0
- data/app/models/decidim/admin/abilities/admin_ability.rb +17 -0
- data/app/models/decidim/admin/abilities/user_manager_ability.rb +30 -0
- data/app/views/decidim/admin/categories/_form.html.erb +1 -1
- data/app/views/decidim/admin/categories/edit.html.erb +1 -1
- data/app/views/decidim/admin/categories/index.html.erb +7 -7
- data/app/views/decidim/admin/categories/new.html.erb +1 -1
- data/app/views/decidim/admin/features/_form.html.erb +6 -3
- data/app/views/decidim/admin/features/_settings_fields.html.erb +2 -1
- data/app/views/decidim/admin/managed_users/_form.html.erb +12 -0
- data/app/views/decidim/admin/managed_users/impersonations/_form.html.erb +10 -0
- data/app/views/decidim/admin/managed_users/impersonations/index.html.erb +34 -0
- data/app/views/decidim/admin/managed_users/impersonations/new.html.erb +15 -0
- data/app/views/decidim/admin/managed_users/index.html.erb +44 -0
- data/app/views/decidim/admin/managed_users/new.html.erb +47 -0
- data/app/views/decidim/admin/managed_users/promotions/_form.html.erb +3 -0
- data/app/views/decidim/admin/managed_users/promotions/new.html.erb +21 -0
- data/app/views/decidim/admin/moderations/index.html.erb +4 -4
- data/app/views/decidim/admin/participatory_process_copies/_form.html.erb +1 -1
- data/app/views/decidim/admin/participatory_process_user_roles/edit.html.erb +1 -1
- data/app/views/decidim/admin/participatory_processes/_form.html.erb +13 -8
- data/app/views/decidim/admin/participatory_processes/index.html.erb +1 -1
- data/app/views/decidim/admin/scope_types/_form.html.erb +7 -0
- data/app/views/decidim/admin/scope_types/edit.html.erb +13 -0
- data/app/views/decidim/admin/scope_types/index.html.erb +40 -0
- data/app/views/decidim/admin/scope_types/new.html.erb +13 -0
- data/app/views/decidim/admin/scopes/_form.html.erb +12 -2
- data/app/views/decidim/admin/scopes/index.html.erb +19 -7
- data/app/views/decidim/admin/scopes/new.html.erb +1 -1
- data/app/views/decidim/admin/users/_form.html.erb +4 -0
- data/app/views/decidim/admin/users/index.html.erb +2 -0
- data/app/views/layouts/decidim/admin/newsletters.erb +1 -1
- data/app/views/layouts/decidim/admin/pages.html.erb +1 -1
- data/app/views/layouts/decidim/admin/participatory_process.html.erb +4 -4
- data/app/views/layouts/decidim/admin/participatory_process_groups.html.erb +1 -1
- data/app/views/layouts/decidim/admin/settings.html.erb +4 -1
- data/app/views/layouts/decidim/admin/users.html.erb +8 -3
- data/config/i18n-tasks.yml +2 -1
- data/config/locales/ca.yml +80 -3
- data/config/locales/en.yml +82 -2
- data/config/locales/es.yml +80 -3
- data/config/locales/eu.yml +44 -7
- data/config/locales/fi.yml +0 -7
- data/config/locales/fr.yml +21 -6
- data/config/locales/it.yml +0 -10
- data/config/locales/nl.yml +1 -1
- data/config/locales/pl.yml +7 -0
- data/config/routes.rb +24 -11
- data/lib/decidim/admin/engine.rb +6 -3
- data/lib/decidim/admin/test/manage_attachments_examples.rb +77 -79
- metadata +56 -9
- data/app/views/decidim/admin/participatory_processes/show.html.erb +0 -54
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Admin
|
|
5
|
+
# A command with all the business logic to promote a managed user.
|
|
6
|
+
#
|
|
7
|
+
# Managed users can be promoted to standard users. It means they
|
|
8
|
+
# will be invited to the application and will lose the managed flag
|
|
9
|
+
# so the user cannot be impersonated anymore.
|
|
10
|
+
class PromoteManagedUser < Rectify::Command
|
|
11
|
+
# Public: Initializes the command.
|
|
12
|
+
#
|
|
13
|
+
# form - A form object with the params.
|
|
14
|
+
# user - The user to promote
|
|
15
|
+
# promoted_by - The user performing the operation
|
|
16
|
+
def initialize(form, user, promoted_by)
|
|
17
|
+
@form = form
|
|
18
|
+
@user = user
|
|
19
|
+
@promoted_by = promoted_by
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Executes the command. Broadcasts these events:
|
|
23
|
+
#
|
|
24
|
+
# - :ok when everything is valid.
|
|
25
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
|
26
|
+
#
|
|
27
|
+
# Returns nothing.
|
|
28
|
+
def call
|
|
29
|
+
return broadcast(:invalid) if form.invalid? || !user.managed? || email_already_exists?
|
|
30
|
+
|
|
31
|
+
promote_user
|
|
32
|
+
invite_user
|
|
33
|
+
|
|
34
|
+
broadcast(:ok)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
attr_reader :form, :user, :promoted_by
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def promote_user
|
|
42
|
+
user.email = form.email.downcase
|
|
43
|
+
user.skip_reconfirmation!
|
|
44
|
+
user.save(validate: false)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def invite_user
|
|
48
|
+
user.invite!(promoted_by)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def email_already_exists?
|
|
52
|
+
Decidim::User.where(email: form.email.downcase).any?
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -55,6 +55,7 @@ module Decidim
|
|
|
55
55
|
promoted: form.promoted,
|
|
56
56
|
description: form.description,
|
|
57
57
|
short_description: form.short_description,
|
|
58
|
+
scopes_enabled: form.scopes_enabled,
|
|
58
59
|
scope: form.scope,
|
|
59
60
|
developer_group: form.developer_group,
|
|
60
61
|
local_area: form.local_area,
|
|
@@ -64,7 +65,8 @@ module Decidim
|
|
|
64
65
|
meta_scope: form.meta_scope,
|
|
65
66
|
end_date: form.end_date,
|
|
66
67
|
participatory_process_group: form.participatory_process_group,
|
|
67
|
-
show_statistics: form.show_statistics
|
|
68
|
+
show_statistics: form.show_statistics,
|
|
69
|
+
announcement: form.announcement
|
|
68
70
|
}
|
|
69
71
|
end
|
|
70
72
|
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Admin
|
|
5
|
+
# A command with all the business logic when updating a scope type.
|
|
6
|
+
class UpdateScopeType < Rectify::Command
|
|
7
|
+
# Public: Initializes the command.
|
|
8
|
+
#
|
|
9
|
+
# scope_type - The ScopeType to update
|
|
10
|
+
# form - A form object with the params.
|
|
11
|
+
def initialize(scope_type, form)
|
|
12
|
+
@scope_type = scope_type
|
|
13
|
+
@form = form
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Executes the command. Broadcasts these events:
|
|
17
|
+
#
|
|
18
|
+
# - :ok when everything is valid.
|
|
19
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
|
20
|
+
#
|
|
21
|
+
# Returns nothing.
|
|
22
|
+
def call
|
|
23
|
+
return broadcast(:invalid) if form.invalid?
|
|
24
|
+
|
|
25
|
+
update_scope_type
|
|
26
|
+
broadcast(:ok)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
attr_reader :form
|
|
32
|
+
|
|
33
|
+
def update_scope_type
|
|
34
|
+
@scope_type.update_attributes!(attributes)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def attributes
|
|
38
|
+
{
|
|
39
|
+
name: form.name,
|
|
40
|
+
plural: form.plural
|
|
41
|
+
}
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -17,9 +17,10 @@ module Decidim
|
|
|
17
17
|
helper Decidim::Admin::ProcessesForSelectHelper
|
|
18
18
|
helper Decidim::Admin::IconLinkHelper
|
|
19
19
|
helper Decidim::Admin::MenuHelper
|
|
20
|
+
helper Decidim::Admin::ScopesHelper
|
|
20
21
|
helper Decidim::DecidimFormHelper
|
|
21
22
|
helper Decidim::ReplaceButtonsHelper
|
|
22
|
-
helper Decidim::
|
|
23
|
+
helper Decidim::ScopesHelper
|
|
23
24
|
helper Decidim::TranslationsHelper
|
|
24
25
|
helper Decidim::LanguageChooserHelper
|
|
25
26
|
helper Decidim::FeaturePathHelper
|
|
@@ -23,7 +23,7 @@ module Decidim
|
|
|
23
23
|
CreateCategory.call(@form, current_participatory_process) do
|
|
24
24
|
on(:ok) do
|
|
25
25
|
flash[:notice] = I18n.t("categories.create.success", scope: "decidim.admin")
|
|
26
|
-
redirect_to
|
|
26
|
+
redirect_to categories_path(current_participatory_process)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
on(:invalid) do
|
|
@@ -47,7 +47,7 @@ module Decidim
|
|
|
47
47
|
UpdateCategory.call(@category, @form) do
|
|
48
48
|
on(:ok) do
|
|
49
49
|
flash[:notice] = I18n.t("categories.update.success", scope: "decidim.admin")
|
|
50
|
-
redirect_to
|
|
50
|
+
redirect_to categories_path(current_participatory_process)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
on(:invalid) do
|
|
@@ -75,7 +75,7 @@ module Decidim
|
|
|
75
75
|
flash[:alert] = I18n.t("categories.destroy.error", scope: "decidim.admin")
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
redirect_back(fallback_location:
|
|
78
|
+
redirect_back(fallback_location: categories_path(current_participatory_process))
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module Admin
|
|
5
5
|
# This controller allows admins to manage proposals in a participatory process.
|
|
6
|
-
class ExportsController < ApplicationController
|
|
6
|
+
class ExportsController < Decidim::Admin::ApplicationController
|
|
7
7
|
include Concerns::ParticipatoryProcessAdmin
|
|
8
8
|
include Decidim::FeaturePathHelper
|
|
9
9
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_dependency "decidim/admin/application_controller"
|
|
4
|
+
|
|
5
|
+
module Decidim
|
|
6
|
+
module Admin
|
|
7
|
+
module ManagedUsers
|
|
8
|
+
# Controller that allows impersonating managed users at the admin panel.
|
|
9
|
+
#
|
|
10
|
+
class ImpersonationsController < Admin::ApplicationController
|
|
11
|
+
layout "decidim/admin/users"
|
|
12
|
+
|
|
13
|
+
skip_authorization_check only: [:index, :close_session]
|
|
14
|
+
|
|
15
|
+
def index
|
|
16
|
+
@impersonation_logs = Decidim::ImpersonationLog.where(user: user).order(started_at: :desc).page(params[:page]).per(15)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def new
|
|
20
|
+
authorize! :impersonate, user
|
|
21
|
+
|
|
22
|
+
if handler_name.present?
|
|
23
|
+
@form = form(ImpersonateManagedUserForm).from_params(
|
|
24
|
+
authorization: {
|
|
25
|
+
handler_name: handler_name
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def create
|
|
32
|
+
authorize! :impersonate, user
|
|
33
|
+
|
|
34
|
+
@form = form(ImpersonateManagedUserForm).from_params(params)
|
|
35
|
+
|
|
36
|
+
ImpersonateManagedUser.call(@form, user, current_user) do
|
|
37
|
+
on(:ok) do
|
|
38
|
+
redirect_to decidim.root_path
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
on(:invalid) do
|
|
42
|
+
flash.now[:alert] = I18n.t("managed_users.impersonate.error", scope: "decidim.admin")
|
|
43
|
+
render :new
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def close_session
|
|
49
|
+
CloseSessionManagedUser.call(user, current_user) do
|
|
50
|
+
on(:ok) do
|
|
51
|
+
flash[:notice] = I18n.t("managed_users.close_session.success", scope: "decidim.admin")
|
|
52
|
+
redirect_to managed_users_path
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
on(:invalid) do
|
|
56
|
+
flash.now[:alert] = I18n.t("managed_users.close_session.error", scope: "decidim.admin")
|
|
57
|
+
redirect_to decidim.root_path
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def user
|
|
65
|
+
@user ||= current_organization.users.managed.find(params[:managed_user_id])
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def handler_name
|
|
69
|
+
authorization.name
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def authorization
|
|
73
|
+
@authorization ||= Authorization.where(user: user).first
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_dependency "decidim/admin/application_controller"
|
|
4
|
+
|
|
5
|
+
module Decidim
|
|
6
|
+
module Admin
|
|
7
|
+
module ManagedUsers
|
|
8
|
+
# Controller that allows promoting managed users at the admin panel.
|
|
9
|
+
#
|
|
10
|
+
class PromotionsController < Admin::ApplicationController
|
|
11
|
+
layout "decidim/admin/users"
|
|
12
|
+
|
|
13
|
+
def new
|
|
14
|
+
authorize! :promote, user
|
|
15
|
+
@form = form(ManagedUserPromotionForm).instance
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def create
|
|
19
|
+
authorize! :promote, user
|
|
20
|
+
@form = form(ManagedUserPromotionForm).from_params(params)
|
|
21
|
+
|
|
22
|
+
PromoteManagedUser.call(@form, user, current_user) do
|
|
23
|
+
on(:ok) do
|
|
24
|
+
flash[:notice] = I18n.t("managed_users.promotion.success", scope: "decidim.admin")
|
|
25
|
+
redirect_to managed_users_path
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
on(:invalid) do
|
|
29
|
+
flash.now[:alert] = I18n.t("managed_users.promotion.error", scope: "decidim.admin")
|
|
30
|
+
render :new
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def user
|
|
38
|
+
@user ||= current_organization.users.managed.find(params[:managed_user_id])
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_dependency "decidim/admin/application_controller"
|
|
4
|
+
|
|
5
|
+
module Decidim
|
|
6
|
+
module Admin
|
|
7
|
+
# Controller that allows managing managed users at the admin panel.
|
|
8
|
+
#
|
|
9
|
+
class ManagedUsersController < Admin::ApplicationController
|
|
10
|
+
layout "decidim/admin/users"
|
|
11
|
+
|
|
12
|
+
helper_method :available_authorizations, :more_than_one_authorization?
|
|
13
|
+
|
|
14
|
+
def index
|
|
15
|
+
authorize! :index, :managed_users
|
|
16
|
+
@managed_users = collection.page(params[:page]).per(15)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def new
|
|
20
|
+
authorize! :new, :managed_users
|
|
21
|
+
|
|
22
|
+
if handler_name.present?
|
|
23
|
+
@form = form(ManagedUserForm).from_params(
|
|
24
|
+
authorization: {
|
|
25
|
+
handler_name: handler_name
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def create
|
|
32
|
+
authorize! :create, :managed_users
|
|
33
|
+
|
|
34
|
+
@form = form(ManagedUserForm).from_params(params)
|
|
35
|
+
|
|
36
|
+
CreateManagedUser.call(@form) do
|
|
37
|
+
on(:ok) do
|
|
38
|
+
flash[:notice] = I18n.t("managed_users.create.success", scope: "decidim.admin")
|
|
39
|
+
redirect_to managed_users_path
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
on(:invalid) do
|
|
43
|
+
flash.now[:alert] = I18n.t("managed_users.create.error", scope: "decidim.admin")
|
|
44
|
+
render :new
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def collection
|
|
52
|
+
@collection ||= current_organization.users.managed
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def handler_name
|
|
56
|
+
return params[:handler_name] if more_than_one_authorization?
|
|
57
|
+
available_authorizations.first
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def available_authorizations
|
|
61
|
+
current_organization.available_authorizations.map(&:underscore)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def more_than_one_authorization?
|
|
65
|
+
available_authorizations.length > 1
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -18,12 +18,12 @@ module Decidim
|
|
|
18
18
|
Admin::UnreportResource.call(reportable) do
|
|
19
19
|
on(:ok) do
|
|
20
20
|
flash[:notice] = I18n.t("reportable.unreport.success", scope: "decidim.moderations.admin")
|
|
21
|
-
redirect_to
|
|
21
|
+
redirect_to moderations_path
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
on(:invalid) do
|
|
25
25
|
flash.now[:alert] = I18n.t("reportable.unreport.invalid", scope: "decidim.moderations.admin")
|
|
26
|
-
redirect_to
|
|
26
|
+
redirect_to moderations_path
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -34,12 +34,12 @@ module Decidim
|
|
|
34
34
|
Admin::HideResource.call(reportable) do
|
|
35
35
|
on(:ok) do
|
|
36
36
|
flash[:notice] = I18n.t("reportable.hide.success", scope: "decidim.moderations.admin")
|
|
37
|
-
redirect_to
|
|
37
|
+
redirect_to moderations_path
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
on(:invalid) do
|
|
41
41
|
flash.now[:alert] = I18n.t("reportable.hide.invalid", scope: "decidim.moderations.admin")
|
|
42
|
-
redirect_to
|
|
42
|
+
redirect_to moderations_path
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -4,7 +4,7 @@ module Decidim
|
|
|
4
4
|
module Admin
|
|
5
5
|
# Controller that allows managing newsletters.
|
|
6
6
|
#
|
|
7
|
-
class NewslettersController < ApplicationController
|
|
7
|
+
class NewslettersController < Decidim::Admin::ApplicationController
|
|
8
8
|
def index
|
|
9
9
|
authorize! :index, Newsletter
|
|
10
10
|
@newsletters = collection.order(Newsletter.arel_table[:created_at].desc)
|
|
@@ -5,7 +5,6 @@ module Decidim
|
|
|
5
5
|
# Controller that allows managing participatory processes.
|
|
6
6
|
#
|
|
7
7
|
class ParticipatoryProcessesController < Decidim::Admin::ApplicationController
|
|
8
|
-
helper Decidim::OrganizationScopesHelper
|
|
9
8
|
helper_method :current_participatory_process
|
|
10
9
|
|
|
11
10
|
def index
|
|
@@ -58,10 +57,6 @@ module Decidim
|
|
|
58
57
|
end
|
|
59
58
|
end
|
|
60
59
|
|
|
61
|
-
def show
|
|
62
|
-
authorize! :read, current_participatory_process
|
|
63
|
-
end
|
|
64
|
-
|
|
65
60
|
def destroy
|
|
66
61
|
authorize! :destroy, current_participatory_process
|
|
67
62
|
current_participatory_process.destroy!
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Admin
|
|
5
|
+
# Controller that allows managing scopes types at the admin panel.
|
|
6
|
+
#
|
|
7
|
+
class ScopeTypesController < Decidim::Admin::ApplicationController
|
|
8
|
+
layout "decidim/admin/settings"
|
|
9
|
+
helper_method :scope_types
|
|
10
|
+
|
|
11
|
+
def index
|
|
12
|
+
authorize! :index, ScopeType
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def new
|
|
16
|
+
authorize! :new, ScopeType
|
|
17
|
+
@form = form(ScopeTypeForm).instance
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def create
|
|
21
|
+
authorize! :new, ScopeType
|
|
22
|
+
@form = form(ScopeTypeForm).from_params(params)
|
|
23
|
+
|
|
24
|
+
CreateScopeType.call(@form) do
|
|
25
|
+
on(:ok) do
|
|
26
|
+
flash[:notice] = I18n.t("scope_types.create.success", scope: "decidim.admin")
|
|
27
|
+
redirect_to scope_types_path
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
on(:invalid) do
|
|
31
|
+
flash.now[:alert] = I18n.t("scope_types.create.error", scope: "decidim.admin")
|
|
32
|
+
render :new
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def edit
|
|
38
|
+
authorize! :update, scope_type
|
|
39
|
+
@form = form(ScopeTypeForm).from_model(scope_type)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def update
|
|
43
|
+
authorize! :update, scope_type
|
|
44
|
+
@form = form(ScopeTypeForm).from_params(params)
|
|
45
|
+
|
|
46
|
+
UpdateScopeType.call(scope_type, @form) do
|
|
47
|
+
on(:ok) do
|
|
48
|
+
flash[:notice] = I18n.t("scope_types.update.success", scope: "decidim.admin")
|
|
49
|
+
redirect_to scope_types_path
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
on(:invalid) do
|
|
53
|
+
flash.now[:alert] = I18n.t("scope_types.update.error", scope: "decidim.admin")
|
|
54
|
+
render :edit
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def destroy
|
|
60
|
+
authorize! :destroy, scope_type
|
|
61
|
+
scope_type.destroy!
|
|
62
|
+
|
|
63
|
+
flash[:notice] = I18n.t("scope_types.destroy.success", scope: "decidim.admin")
|
|
64
|
+
|
|
65
|
+
redirect_to scope_types_path
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def scope_type
|
|
71
|
+
@scope_type ||= scope_types.find(params[:id])
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def scope_types
|
|
75
|
+
current_organization.scope_types
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|