decidim-admin 0.11.2 → 0.12.0.pre
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/app/assets/javascripts/decidim/admin/application.js.es6 +5 -1
- data/app/assets/javascripts/decidim/admin/bundle.js +47 -0
- data/app/assets/javascripts/decidim/admin/bundle.js.map +1 -0
- data/app/assets/javascripts/decidim/admin/component_permissions.js.es6 +13 -0
- data/app/assets/javascripts/decidim/admin/managed_users.js.es6 +2 -1
- data/app/assets/javascripts/decidim/admin/subform_toggler.component.js.es6 +14 -7
- data/app/assets/stylesheets/decidim/admin/_decidim.scss +2 -0
- data/app/assets/stylesheets/decidim/admin/bundle.scss +1 -0
- data/app/assets/stylesheets/decidim/admin/components/_autocomplete_select.component.scss +13 -0
- data/app/assets/stylesheets/decidim/admin/modules/_secondary-nav.scss +3 -2
- data/app/assets/stylesheets/decidim/admin/modules/_table-list.scss +7 -0
- data/app/commands/decidim/admin/create_static_page.rb +7 -1
- data/app/commands/decidim/admin/update_component_permissions.rb +9 -3
- data/app/commands/decidim/admin/update_organization_tos_version.rb +47 -0
- data/app/commands/decidim/admin/update_static_page.rb +5 -0
- data/app/constraints/decidim/admin/organization_dashboard_constraint.rb +6 -3
- data/app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb +2 -2
- data/app/controllers/decidim/admin/application_controller.rb +14 -5
- data/app/controllers/decidim/admin/area_types_controller.rb +6 -6
- data/app/controllers/decidim/admin/areas_controller.rb +6 -6
- data/app/controllers/decidim/admin/authorization_workflows_controller.rb +1 -1
- data/app/controllers/decidim/admin/categories_controller.rb +7 -7
- data/app/controllers/decidim/admin/component_permissions_controller.rb +20 -8
- data/app/controllers/decidim/admin/components/base_controller.rb +19 -3
- data/app/controllers/decidim/admin/components_controller.rb +8 -8
- data/app/controllers/decidim/admin/concerns/has_attachment_collections.rb +8 -8
- data/app/controllers/decidim/admin/concerns/has_attachments.rb +11 -9
- data/app/controllers/decidim/admin/concerns/has_private_users.rb +5 -5
- data/app/controllers/decidim/admin/dashboard_controller.rb +4 -2
- data/app/controllers/decidim/admin/exports_controller.rb +1 -1
- data/app/controllers/decidim/admin/impersonatable_users_controller.rb +7 -1
- data/app/controllers/decidim/admin/impersonations_controller.rb +2 -4
- data/app/controllers/decidim/admin/logs_controller.rb +4 -2
- data/app/controllers/decidim/admin/managed_users/impersonation_logs_controller.rb +0 -2
- data/app/controllers/decidim/admin/managed_users/promotions_controller.rb +2 -2
- data/app/controllers/decidim/admin/moderations_controller.rb +4 -4
- data/app/controllers/decidim/admin/newsletters_controller.rb +9 -9
- data/app/controllers/decidim/admin/oauth_applications_controller.rb +7 -7
- data/app/controllers/decidim/admin/officializations_controller.rb +4 -5
- data/app/controllers/decidim/admin/organization_appearance_controller.rb +2 -2
- data/app/controllers/decidim/admin/organization_controller.rb +21 -2
- data/app/controllers/decidim/admin/scope_types_controller.rb +6 -6
- data/app/controllers/decidim/admin/scopes_controller.rb +7 -7
- data/app/controllers/decidim/admin/static_pages_controller.rb +16 -7
- data/app/controllers/decidim/admin/user_groups_controller.rb +3 -3
- data/app/controllers/decidim/admin/users_controller.rb +5 -5
- data/app/forms/decidim/admin/managed_user_promotion_form.rb +1 -1
- data/app/forms/decidim/admin/permission_form.rb +12 -15
- data/app/forms/decidim/admin/static_page_form.rb +1 -0
- data/app/frontend/components/autocomplete.component.test.tsx +19 -0
- data/app/frontend/components/autocomplete.component.tsx +169 -0
- data/app/frontend/entry.ts +17 -0
- data/app/frontend/entry_test.ts +4 -0
- data/app/helpers/decidim/admin/application_helper.rb +0 -4
- data/app/permissions/decidim/admin/permissions.rb +161 -0
- data/app/permissions/decidim/admin/user_manager_permissions.rb +66 -0
- data/app/views/decidim/admin/area_types/index.html.erb +8 -4
- data/app/views/decidim/admin/areas/index.html.erb +6 -3
- data/app/views/decidim/admin/attachment_collections/index.html.erb +3 -3
- data/app/views/decidim/admin/attachment_collections/show.html.erb +2 -2
- data/app/views/decidim/admin/attachments/index.html.erb +3 -3
- data/app/views/decidim/admin/attachments/show.html.erb +2 -2
- data/app/views/decidim/admin/categories/index.html.erb +5 -5
- data/app/views/decidim/admin/categories/show.html.erb +2 -2
- data/app/views/decidim/admin/component_permissions/_options_form.html.erb +14 -0
- data/app/views/decidim/admin/component_permissions/edit.html.erb +37 -16
- data/app/views/decidim/admin/components/_component.html.erb +6 -4
- data/app/views/decidim/admin/components/_form.html.erb +6 -6
- data/app/views/decidim/admin/dashboard/show.html.erb +1 -1
- data/app/views/decidim/admin/impersonatable_users/index.html.erb +5 -3
- data/app/views/decidim/admin/moderations/index.html.erb +2 -2
- data/app/views/decidim/admin/newsletters/index.html.erb +5 -3
- data/app/views/decidim/admin/newsletters/show.html.erb +1 -1
- data/app/views/decidim/admin/oauth_applications/index.html.erb +5 -3
- data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +3 -3
- data/app/views/decidim/admin/scope_types/index.html.erb +5 -3
- data/app/views/decidim/admin/scopes/index.html.erb +4 -4
- data/app/views/decidim/admin/static_pages/_form.html.erb +3 -1
- data/app/views/decidim/admin/static_pages/_form_notable_changes.html.erb +9 -0
- data/app/views/decidim/admin/static_pages/index.html.erb +11 -3
- data/app/views/decidim/admin/static_pages/show.html.erb +2 -2
- data/app/views/decidim/admin/user_groups/index.html.erb +2 -2
- data/app/views/decidim/admin/users/index.html.erb +5 -3
- data/app/views/layouts/decidim/admin/_application.html.erb +0 -1
- data/app/views/layouts/decidim/admin/_template_top.html.erb +1 -0
- data/app/views/layouts/decidim/admin/users.html.erb +4 -4
- data/config/locales/ca.yml +8 -0
- data/config/locales/en.yml +8 -0
- data/config/locales/es.yml +8 -0
- data/config/locales/eu.yml +8 -0
- data/config/locales/fi.yml +8 -0
- data/config/locales/fr.yml +8 -0
- data/config/locales/gl.yml +8 -0
- data/config/locales/it.yml +8 -0
- data/config/locales/nl.yml +8 -0
- data/config/locales/pl.yml +8 -0
- data/config/locales/pt-BR.yml +8 -0
- data/config/locales/pt.yml +8 -0
- data/config/locales/ru.yml +11 -3
- data/config/locales/sv.yml +8 -0
- data/config/locales/uk.yml +8 -0
- data/config/routes.rb +5 -1
- data/lib/decidim/admin.rb +1 -0
- data/lib/decidim/admin/engine.rb +17 -20
- data/lib/decidim/admin/form_builder.rb +64 -0
- data/lib/decidim/admin/test/manage_component_permissions_examples.rb +92 -15
- data/lib/decidim/admin/version.rb +1 -1
- metadata +25 -17
- data/app/models/decidim/admin/abilities/admin_ability.rb +0 -76
- data/app/models/decidim/admin/abilities/base_ability.rb +0 -21
- data/app/models/decidim/admin/abilities/participatory_process_admin_ability.rb +0 -58
- data/app/models/decidim/admin/abilities/participatory_process_collaborator_ability.rb +0 -19
- data/app/models/decidim/admin/abilities/participatory_process_moderator_ability.rb +0 -23
- data/app/models/decidim/admin/abilities/user_manager_ability.rb +0 -34
- data/app/models/decidim/admin/application_record.rb +0 -11
@@ -5,10 +5,12 @@ module Decidim
|
|
5
5
|
# Controller that shows a simple dashboard.
|
6
6
|
#
|
7
7
|
class DashboardController < Decidim::Admin::ApplicationController
|
8
|
-
authorize_resource :admin_dashboard, class: false
|
9
|
-
|
10
8
|
helper_method :latest_action_logs
|
11
9
|
|
10
|
+
def show
|
11
|
+
enforce_permission_to :read, :admin_dashboard
|
12
|
+
end
|
13
|
+
|
12
14
|
private
|
13
15
|
|
14
16
|
def latest_action_logs
|
@@ -7,7 +7,7 @@ module Decidim
|
|
7
7
|
include Decidim::ComponentPathHelper
|
8
8
|
|
9
9
|
def create
|
10
|
-
|
10
|
+
enforce_permission_to :export, :component_data, component: component
|
11
11
|
name = params[:id]
|
12
12
|
|
13
13
|
ExportJob.perform_later(current_user, component, name, params[:format] || default_format)
|
@@ -8,8 +8,10 @@ module Decidim
|
|
8
8
|
class ImpersonatableUsersController < Decidim::Admin::ApplicationController
|
9
9
|
layout "decidim/admin/users"
|
10
10
|
|
11
|
+
helper_method :new_managed_user
|
12
|
+
|
11
13
|
def index
|
12
|
-
|
14
|
+
enforce_permission_to :index, :impersonatable_user
|
13
15
|
|
14
16
|
@query = params[:q]
|
15
17
|
@state = params[:state]
|
@@ -24,6 +26,10 @@ module Decidim
|
|
24
26
|
def collection
|
25
27
|
@collection ||= current_organization.users.where(admin: false, roles: [])
|
26
28
|
end
|
29
|
+
|
30
|
+
def new_managed_user
|
31
|
+
Decidim::User.new(managed: true, admin: false, roles: [])
|
32
|
+
end
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
@@ -11,10 +11,8 @@ module Decidim
|
|
11
11
|
:other_available_authorizations,
|
12
12
|
:creating_managed_user?
|
13
13
|
|
14
|
-
skip_authorization_check only: [:close_session]
|
15
|
-
|
16
14
|
def new
|
17
|
-
|
15
|
+
enforce_permission_to :impersonate, :impersonatable_user, user: user
|
18
16
|
|
19
17
|
@form = form(ImpersonateUserForm).from_params(
|
20
18
|
user: user,
|
@@ -27,7 +25,7 @@ module Decidim
|
|
27
25
|
end
|
28
26
|
|
29
27
|
def create
|
30
|
-
|
28
|
+
enforce_permission_to :impersonate, :impersonatable_user, user: user
|
31
29
|
|
32
30
|
@form = form(ImpersonateUserForm).from_params(
|
33
31
|
user: user,
|
@@ -5,10 +5,12 @@ module Decidim
|
|
5
5
|
# Controller that shows a simple dashboard.
|
6
6
|
#
|
7
7
|
class LogsController < Decidim::Admin::ApplicationController
|
8
|
-
authorize_resource :admin_log, class: false
|
9
|
-
|
10
8
|
helper_method :logs
|
11
9
|
|
10
|
+
def index
|
11
|
+
enforce_permission_to :read, :admin_log
|
12
|
+
end
|
13
|
+
|
12
14
|
private
|
13
15
|
|
14
16
|
def logs
|
@@ -8,8 +8,6 @@ module Decidim
|
|
8
8
|
class ImpersonationLogsController < Decidim::Admin::ApplicationController
|
9
9
|
layout "decidim/admin/users"
|
10
10
|
|
11
|
-
skip_authorization_check
|
12
|
-
|
13
11
|
def index
|
14
12
|
@impersonation_logs = Decidim::ImpersonationLog.where(user: user).order(started_at: :desc).page(params[:page]).per(15)
|
15
13
|
end
|
@@ -9,12 +9,12 @@ module Decidim
|
|
9
9
|
layout "decidim/admin/users"
|
10
10
|
|
11
11
|
def new
|
12
|
-
|
12
|
+
enforce_permission_to :promote, :managed_user, user: user
|
13
13
|
@form = form(ManagedUserPromotionForm).instance
|
14
14
|
end
|
15
15
|
|
16
16
|
def create
|
17
|
-
|
17
|
+
enforce_permission_to :promote, :managed_user, user: user
|
18
18
|
@form = form(ManagedUserPromotionForm).from_params(params)
|
19
19
|
|
20
20
|
PromoteManagedUser.call(@form, user, current_user) do
|
@@ -4,14 +4,14 @@ module Decidim
|
|
4
4
|
module Admin
|
5
5
|
# This controller allows admins to manage moderations in a participatory process.
|
6
6
|
class ModerationsController < Decidim::Admin::ApplicationController
|
7
|
-
helper_method :moderations
|
7
|
+
helper_method :moderations, :allowed_to?
|
8
8
|
|
9
9
|
def index
|
10
|
-
|
10
|
+
enforce_permission_to :read, :moderation
|
11
11
|
end
|
12
12
|
|
13
13
|
def unreport
|
14
|
-
|
14
|
+
enforce_permission_to :unreport, :moderation
|
15
15
|
|
16
16
|
Admin::UnreportResource.call(reportable, current_user) do
|
17
17
|
on(:ok) do
|
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def hide
|
30
|
-
|
30
|
+
enforce_permission_to :hide, :moderation
|
31
31
|
|
32
32
|
Admin::HideResource.call(reportable, current_user) do
|
33
33
|
on(:ok) do
|
@@ -7,24 +7,24 @@ module Decidim
|
|
7
7
|
include Decidim::NewslettersHelper
|
8
8
|
|
9
9
|
def index
|
10
|
-
|
10
|
+
enforce_permission_to :read, :newsletter
|
11
11
|
@newsletters = collection.order(Newsletter.arel_table[:created_at].desc)
|
12
12
|
end
|
13
13
|
|
14
14
|
def new
|
15
|
-
|
15
|
+
enforce_permission_to :create, :newsletter
|
16
16
|
@form = form(NewsletterForm).instance
|
17
17
|
end
|
18
18
|
|
19
19
|
def show
|
20
20
|
@newsletter = collection.find(params[:id])
|
21
21
|
@email = NewsletterMailer.newsletter(current_user, @newsletter)
|
22
|
-
|
22
|
+
enforce_permission_to :read, :newsletter, newsletter: @newsletter
|
23
23
|
end
|
24
24
|
|
25
25
|
def preview
|
26
26
|
@newsletter = collection.find(params[:id])
|
27
|
-
|
27
|
+
enforce_permission_to :read, :newsletter, newsletter: @newsletter
|
28
28
|
|
29
29
|
email = NewsletterMailer.newsletter(current_user, @newsletter)
|
30
30
|
Premailer::Rails::Hook.perform(email)
|
@@ -32,7 +32,7 @@ module Decidim
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def create
|
35
|
-
|
35
|
+
enforce_permission_to :create, :newsletter
|
36
36
|
@form = form(NewsletterForm).from_params(params)
|
37
37
|
|
38
38
|
CreateNewsletter.call(@form, current_user) do
|
@@ -51,13 +51,13 @@ module Decidim
|
|
51
51
|
|
52
52
|
def edit
|
53
53
|
@newsletter = collection.find(params[:id])
|
54
|
-
|
54
|
+
enforce_permission_to :update, :newsletter, newsletter: @newsletter
|
55
55
|
@form = form(NewsletterForm).from_model(@newsletter)
|
56
56
|
end
|
57
57
|
|
58
58
|
def update
|
59
59
|
@newsletter = collection.find(params[:id])
|
60
|
-
|
60
|
+
enforce_permission_to :update, :newsletter, newsletter: @newsletter
|
61
61
|
@form = form(NewsletterForm).from_params(params)
|
62
62
|
|
63
63
|
UpdateNewsletter.call(@newsletter, @form, current_user) do
|
@@ -76,7 +76,7 @@ module Decidim
|
|
76
76
|
|
77
77
|
def destroy
|
78
78
|
@newsletter = collection.find(params[:id])
|
79
|
-
|
79
|
+
enforce_permission_to :destroy, :newsletter, newsletter: @newsletter
|
80
80
|
|
81
81
|
DestroyNewsletter.call(@newsletter, current_user) do
|
82
82
|
on(:already_sent) do
|
@@ -93,7 +93,7 @@ module Decidim
|
|
93
93
|
|
94
94
|
def deliver
|
95
95
|
@newsletter = collection.find(params[:id])
|
96
|
-
|
96
|
+
enforce_permission_to :update, :newsletter, newsletter: @newsletter
|
97
97
|
|
98
98
|
DeliverNewsletter.call(@newsletter, current_user) do
|
99
99
|
on(:ok) do
|
@@ -6,22 +6,22 @@ module Decidim
|
|
6
6
|
#
|
7
7
|
class OAuthApplicationsController < Admin::ApplicationController
|
8
8
|
def index
|
9
|
-
|
9
|
+
enforce_permission_to :read, :oauth_application
|
10
10
|
@oauth_applications = collection.page(params[:page]).per(15)
|
11
11
|
end
|
12
12
|
|
13
13
|
def show
|
14
14
|
@oauth_application = collection.find(params[:id])
|
15
|
-
|
15
|
+
enforce_permission_to :read, :oauth_application
|
16
16
|
end
|
17
17
|
|
18
18
|
def new
|
19
|
-
|
19
|
+
enforce_permission_to :create, :oauth_application
|
20
20
|
@form = form(OAuthApplicationForm).instance
|
21
21
|
end
|
22
22
|
|
23
23
|
def create
|
24
|
-
|
24
|
+
enforce_permission_to :create, :oauth_application
|
25
25
|
|
26
26
|
@form = form(OAuthApplicationForm).from_params(params)
|
27
27
|
|
@@ -40,13 +40,13 @@ module Decidim
|
|
40
40
|
|
41
41
|
def edit
|
42
42
|
@oauth_application = collection.find(params[:id])
|
43
|
-
|
43
|
+
enforce_permission_to :update, :oauth_application, oauth_application: @oauth_application
|
44
44
|
@form = form(OAuthApplicationForm).from_model(@oauth_application)
|
45
45
|
end
|
46
46
|
|
47
47
|
def update
|
48
48
|
@oauth_application = collection.find(params[:id])
|
49
|
-
|
49
|
+
enforce_permission_to :update, :oauth_application, oauth_application: @oauth_application
|
50
50
|
@form = form(OAuthApplicationForm).from_params({ organization_logo: @oauth_application.organization_logo }.merge(params.to_unsafe_h))
|
51
51
|
|
52
52
|
UpdateOAuthApplication.call(@oauth_application, @form, current_user) do
|
@@ -65,7 +65,7 @@ module Decidim
|
|
65
65
|
|
66
66
|
def destroy
|
67
67
|
@oauth_application = collection.find(params[:id])
|
68
|
-
|
68
|
+
enforce_permission_to :destroy, :oauth_application, oauth_application: @oauth_application
|
69
69
|
|
70
70
|
DestroyOAuthApplication.call(@oauth_application, current_user) do
|
71
71
|
on(:ok) do
|
@@ -10,8 +10,7 @@ module Decidim
|
|
10
10
|
helper_method :user
|
11
11
|
|
12
12
|
def index
|
13
|
-
|
14
|
-
|
13
|
+
enforce_permission_to :read, :officialization
|
15
14
|
@query = params[:q]
|
16
15
|
@state = params[:state]
|
17
16
|
|
@@ -21,13 +20,13 @@ module Decidim
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def new
|
24
|
-
|
23
|
+
enforce_permission_to :create, :officialization
|
25
24
|
|
26
25
|
@form = form(OfficializationForm).from_model(user)
|
27
26
|
end
|
28
27
|
|
29
28
|
def create
|
30
|
-
|
29
|
+
enforce_permission_to :create, :officialization
|
31
30
|
|
32
31
|
@form = form(OfficializationForm).from_params(params)
|
33
32
|
|
@@ -41,7 +40,7 @@ module Decidim
|
|
41
40
|
end
|
42
41
|
|
43
42
|
def destroy
|
44
|
-
|
43
|
+
enforce_permission_to :destroy, :officialization
|
45
44
|
|
46
45
|
UnofficializeUser.call(user, current_user) do
|
47
46
|
on(:ok) do
|
@@ -7,12 +7,12 @@ module Decidim
|
|
7
7
|
layout "decidim/admin/settings"
|
8
8
|
|
9
9
|
def edit
|
10
|
-
|
10
|
+
enforce_permission_to :update, :organization, organization: current_organization
|
11
11
|
@form = form(OrganizationAppearanceForm).from_model(current_organization)
|
12
12
|
end
|
13
13
|
|
14
14
|
def update
|
15
|
-
|
15
|
+
enforce_permission_to :update, :organization, organization: current_organization
|
16
16
|
@form = form(OrganizationAppearanceForm).from_params(params)
|
17
17
|
|
18
18
|
UpdateOrganizationAppearance.call(current_organization, @form) do
|
@@ -8,12 +8,12 @@ module Decidim
|
|
8
8
|
layout "decidim/admin/settings"
|
9
9
|
|
10
10
|
def edit
|
11
|
-
|
11
|
+
enforce_permission_to :update, :organization, organization: current_organization
|
12
12
|
@form = form(OrganizationForm).from_model(current_organization)
|
13
13
|
end
|
14
14
|
|
15
15
|
def update
|
16
|
-
|
16
|
+
enforce_permission_to :update, :organization, organization: current_organization
|
17
17
|
@form = form(OrganizationForm).from_params(params)
|
18
18
|
|
19
19
|
UpdateOrganization.call(current_organization, @form) do
|
@@ -28,6 +28,25 @@ module Decidim
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
def users
|
33
|
+
respond_to do |format|
|
34
|
+
format.json do
|
35
|
+
if (term = params[:term].to_s).present?
|
36
|
+
query = current_organization.users.order(name: :asc)
|
37
|
+
query = if term.start_with?("@")
|
38
|
+
query.where("nickname ILIKE ?", "#{term.delete("@")}%")
|
39
|
+
else
|
40
|
+
query.where("name ILIKE ?", "%#{term}%")
|
41
|
+
end
|
42
|
+
|
43
|
+
render json: query.all.collect { |u| { value: u.id, label: "#{u.name} (@#{u.nickname})" } }
|
44
|
+
else
|
45
|
+
render json: []
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
31
50
|
end
|
32
51
|
end
|
33
52
|
end
|
@@ -9,16 +9,16 @@ module Decidim
|
|
9
9
|
helper_method :scope_types
|
10
10
|
|
11
11
|
def index
|
12
|
-
|
12
|
+
enforce_permission_to :read, :scope_type
|
13
13
|
end
|
14
14
|
|
15
15
|
def new
|
16
|
-
|
16
|
+
enforce_permission_to :create, :scope_type
|
17
17
|
@form = form(ScopeTypeForm).instance
|
18
18
|
end
|
19
19
|
|
20
20
|
def create
|
21
|
-
|
21
|
+
enforce_permission_to :create, :scope_type
|
22
22
|
@form = form(ScopeTypeForm).from_params(params)
|
23
23
|
|
24
24
|
CreateScopeType.call(@form) do
|
@@ -35,12 +35,12 @@ module Decidim
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def edit
|
38
|
-
|
38
|
+
enforce_permission_to :update, :scope_type, scope_type: scope_type
|
39
39
|
@form = form(ScopeTypeForm).from_model(scope_type)
|
40
40
|
end
|
41
41
|
|
42
42
|
def update
|
43
|
-
|
43
|
+
enforce_permission_to :update, :scope_type, scope_type: scope_type
|
44
44
|
@form = form(ScopeTypeForm).from_params(params)
|
45
45
|
|
46
46
|
UpdateScopeType.call(scope_type, @form) do
|
@@ -57,7 +57,7 @@ module Decidim
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def destroy
|
60
|
-
|
60
|
+
enforce_permission_to :destroy, :scope_type, scope_type: scope_type
|
61
61
|
scope_type.destroy!
|
62
62
|
|
63
63
|
flash[:notice] = I18n.t("scope_types.destroy.success", scope: "decidim.admin")
|
@@ -9,17 +9,17 @@ module Decidim
|
|
9
9
|
helper_method :scope, :parent_scope, :add_scope_path, :current_scopes_path
|
10
10
|
|
11
11
|
def index
|
12
|
-
|
13
|
-
@scopes = children_scopes.order("name->'#{I18n.locale}' ASC")
|
12
|
+
enforce_permission_to :read, :scope
|
13
|
+
@scopes = children_scopes.order(Arel.sql("name->'#{I18n.locale}' ASC"))
|
14
14
|
end
|
15
15
|
|
16
16
|
def new
|
17
|
-
|
17
|
+
enforce_permission_to :create, :scope
|
18
18
|
@form = form(ScopeForm).instance
|
19
19
|
end
|
20
20
|
|
21
21
|
def create
|
22
|
-
|
22
|
+
enforce_permission_to :create, :scope
|
23
23
|
@form = form(ScopeForm).from_params(params)
|
24
24
|
CreateScope.call(@form, parent_scope) do
|
25
25
|
on(:ok) do
|
@@ -35,12 +35,12 @@ module Decidim
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def edit
|
38
|
-
|
38
|
+
enforce_permission_to :update, :scope, scope: scope
|
39
39
|
@form = form(ScopeForm).from_model(scope)
|
40
40
|
end
|
41
41
|
|
42
42
|
def update
|
43
|
-
|
43
|
+
enforce_permission_to :update, :scope, scope: scope
|
44
44
|
@form = form(ScopeForm).from_params(params)
|
45
45
|
|
46
46
|
UpdateScope.call(scope, @form) do
|
@@ -57,7 +57,7 @@ module Decidim
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def destroy
|
60
|
-
|
60
|
+
enforce_permission_to :destroy, :scope, scope: scope
|
61
61
|
|
62
62
|
DestroyScope.call(scope, current_user) do
|
63
63
|
on(:ok) do
|
@@ -6,19 +6,20 @@ module Decidim
|
|
6
6
|
#
|
7
7
|
class StaticPagesController < Decidim::Admin::ApplicationController
|
8
8
|
layout "decidim/admin/pages"
|
9
|
+
before_action :tos_version_formatted, only: [:index, :edit]
|
9
10
|
|
10
11
|
def index
|
11
|
-
|
12
|
+
enforce_permission_to :read, :static_page
|
12
13
|
@pages = collection
|
13
14
|
end
|
14
15
|
|
15
16
|
def new
|
16
|
-
|
17
|
+
enforce_permission_to :create, :static_page
|
17
18
|
@form = form(StaticPageForm).instance
|
18
19
|
end
|
19
20
|
|
20
21
|
def create
|
21
|
-
|
22
|
+
enforce_permission_to :create, :static_page
|
22
23
|
@form = form(StaticPageForm).from_params(form_params)
|
23
24
|
|
24
25
|
CreateStaticPage.call(@form) do
|
@@ -35,13 +36,13 @@ module Decidim
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def edit
|
38
|
-
|
39
|
+
enforce_permission_to :update, :static_page, static_page: page
|
39
40
|
@form = form(StaticPageForm).from_model(page)
|
40
41
|
end
|
41
42
|
|
42
43
|
def update
|
43
44
|
@page = collection.find(params[:id])
|
44
|
-
|
45
|
+
enforce_permission_to :update, :static_page, static_page: page
|
45
46
|
@form = form(StaticPageForm).from_params(form_params)
|
46
47
|
|
47
48
|
UpdateStaticPage.call(page, @form) do
|
@@ -58,11 +59,11 @@ module Decidim
|
|
58
59
|
end
|
59
60
|
|
60
61
|
def show
|
61
|
-
|
62
|
+
enforce_permission_to :read, :static_page
|
62
63
|
end
|
63
64
|
|
64
65
|
def destroy
|
65
|
-
|
66
|
+
enforce_permission_to :destroy, :static_page, static_page: page
|
66
67
|
|
67
68
|
DestroyStaticPage.call(page, current_user) do
|
68
69
|
on(:ok) do
|
@@ -92,6 +93,14 @@ module Decidim
|
|
92
93
|
def collection
|
93
94
|
current_organization.static_pages
|
94
95
|
end
|
96
|
+
|
97
|
+
def tos_version
|
98
|
+
current_organization.tos_version
|
99
|
+
end
|
100
|
+
|
101
|
+
def tos_version_formatted
|
102
|
+
@tos_version_formatted ||= l(tos_version, format: :short) if tos_version.present?
|
103
|
+
end
|
95
104
|
end
|
96
105
|
end
|
97
106
|
end
|