decidim-admin 0.4.4 → 0.5.0
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 +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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 516f2d4eb6dd6d58c1f0be4f006e82b9a861dfa2
|
4
|
+
data.tar.gz: 6efae3c2a6f0ad25183ce8b83614a4e60c3dbc30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b527b5374e8b45bd49ba6ecbbee30178fe2d05af25ab7b9e19ec44a9cc3b8ebe0f1908c4d7b73402ec7d4f814cd500e9746ca98a9f2a28d79656dd49b002d316
|
7
|
+
data.tar.gz: 558e8cb6200ff1e907163b9e3d1922994cb4437a5ae937006cb2acd44f80c0199f9ac24901a68a170b1ffa15d5133be4190a2d0d9c8f4412ecabb0b229e79016
|
@@ -0,0 +1,12 @@
|
|
1
|
+
$(() => {
|
2
|
+
const $participatoryProcessScopeEnabled = $('#participatory_process_scopes_enabled');
|
3
|
+
const $participatoryProcessScopeId = $("#participatory_process_scope_id");
|
4
|
+
|
5
|
+
if ($('.edit_participatory_process').length > 0) {
|
6
|
+
$participatoryProcessScopeEnabled.on('change', (event) => {
|
7
|
+
const checked = event.target.checked;
|
8
|
+
$participatoryProcessScopeId.attr("disabled", !checked);
|
9
|
+
})
|
10
|
+
$participatoryProcessScopeId.attr("disabled", !$participatoryProcessScopeEnabled.prop('checked'));
|
11
|
+
}
|
12
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$(() => {
|
2
|
+
const selectedLang = $("html").attr('lang') || 'en';
|
3
|
+
$(".select2").each(function(index, select) {
|
4
|
+
let $element = $(select);
|
5
|
+
let options = {
|
6
|
+
language: selectedLang,
|
7
|
+
multiple: $element.attr("multiple")==="multiple",
|
8
|
+
width: "100%",
|
9
|
+
allowClear: true
|
10
|
+
};
|
11
|
+
if ($element.data("remote-path")) {
|
12
|
+
options.ajax = {
|
13
|
+
url: $element.data("remote-path"),
|
14
|
+
delay: 250,
|
15
|
+
cache: true
|
16
|
+
};
|
17
|
+
}
|
18
|
+
$element.select2(options);
|
19
|
+
});
|
20
|
+
});
|
@@ -1,3 +1,5 @@
|
|
1
|
+
$card-padding-small: 1rem;
|
2
|
+
|
1
3
|
.card-title{
|
2
4
|
@include smallcaps;
|
3
5
|
font-size: 1rem;
|
@@ -27,3 +29,48 @@
|
|
27
29
|
display: block;
|
28
30
|
}
|
29
31
|
}
|
32
|
+
|
33
|
+
.card--list__item{
|
34
|
+
display: flex;
|
35
|
+
align-items: center;
|
36
|
+
padding-left: $card-padding-small;
|
37
|
+
.card--list--mini &{
|
38
|
+
padding-left: $card-padding-small;
|
39
|
+
}
|
40
|
+
@include breakpoint(medium){
|
41
|
+
padding-left: $card-padding;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
.card--list__icon{
|
46
|
+
display: none;
|
47
|
+
fill: $anchor-color;
|
48
|
+
@include breakpoint(medium){
|
49
|
+
margin-right: 1rem;
|
50
|
+
display: block;
|
51
|
+
width: 30px;
|
52
|
+
height: 30px;
|
53
|
+
flex-shrink: 0;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
.card--list__text{
|
58
|
+
flex-grow: 1;
|
59
|
+
flex-shrink: 1;
|
60
|
+
display: inline-flex;
|
61
|
+
overflow: hidden;
|
62
|
+
align-items: center;
|
63
|
+
padding: 1rem 1rem 1rem 0;
|
64
|
+
.card--list--mini &{
|
65
|
+
padding: .5rem .5rem .5rem 0;
|
66
|
+
}
|
67
|
+
.author{
|
68
|
+
margin-top: .3rem;
|
69
|
+
margin-right: 1rem;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
.card--list__heading{
|
74
|
+
margin-bottom: 0;
|
75
|
+
display: block;
|
76
|
+
}
|
@@ -74,13 +74,13 @@ $process-title-height: 3rem;
|
|
74
74
|
}
|
75
75
|
|
76
76
|
|
77
|
-
.process-title{
|
77
|
+
.process-title {
|
78
78
|
@include breakpoint(large){
|
79
79
|
margin-bottom: $process-title-height;
|
80
80
|
}
|
81
81
|
}
|
82
82
|
|
83
|
-
.process-title-content{
|
83
|
+
.process-title-content {
|
84
84
|
@include breakpoint(large){
|
85
85
|
position: absolute;
|
86
86
|
left: 120px;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
.select2-container {
|
2
|
+
width: 100%;
|
3
|
+
&.select2 {
|
4
|
+
margin-bottom: 1.5rem;
|
5
|
+
}
|
6
|
+
.select2-dropdown {
|
7
|
+
box-shadow: inset 0 -1px 2px rgba(26, 24, 29, 0.1);
|
8
|
+
border-color: #eee;
|
9
|
+
}
|
10
|
+
.select2-selection {
|
11
|
+
box-shadow: inset 0 1px 2px rgba(26, 24, 29, 0.1);
|
12
|
+
border-color: #eee;
|
13
|
+
}
|
14
|
+
.select2-selection--single {
|
15
|
+
margin-top: 5px;
|
16
|
+
height: 48px;
|
17
|
+
.select2-selection__rendered {
|
18
|
+
line-height: 46px;
|
19
|
+
padding-right: 23px;
|
20
|
+
font-weight: normal;
|
21
|
+
}
|
22
|
+
.select2-selection__arrow {
|
23
|
+
height: 54px;
|
24
|
+
right: 4px;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic to close a current impersonation session.
|
6
|
+
class CloseSessionManagedUser < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# user - The user impersonated.
|
10
|
+
# current_user - The current user doing the impersonation.
|
11
|
+
def initialize(user, current_user)
|
12
|
+
@user = user
|
13
|
+
@current_user = current_user
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if the impersonation is not valid.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
return broadcast(:invalid) unless impersonation_log.present?
|
24
|
+
|
25
|
+
close_session
|
26
|
+
|
27
|
+
broadcast(:ok)
|
28
|
+
end
|
29
|
+
|
30
|
+
attr_reader :current_user, :user
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def impersonation_log
|
35
|
+
@impersonation_log ||= Decidim::ImpersonationLog.where(admin: current_user, user: user).active.first
|
36
|
+
end
|
37
|
+
|
38
|
+
def close_session
|
39
|
+
impersonation_log.ended_at = Time.current
|
40
|
+
impersonation_log.save!
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -38,7 +38,8 @@ module Decidim
|
|
38
38
|
manifest_name: manifest.name,
|
39
39
|
name: form.name,
|
40
40
|
participatory_process: participatory_process,
|
41
|
-
settings:
|
41
|
+
settings: form.settings,
|
42
|
+
default_step_settings: form.default_step_settings,
|
42
43
|
step_settings: form.step_settings
|
43
44
|
)
|
44
45
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic to create a new managed user in the
|
6
|
+
# admin panel.
|
7
|
+
class CreateManagedUser < Rectify::Command
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# form - A form object with the params.
|
11
|
+
def initialize(form)
|
12
|
+
@form = form
|
13
|
+
end
|
14
|
+
|
15
|
+
# Executes the command. Broadcasts these events:
|
16
|
+
#
|
17
|
+
# - :ok when everything is valid.
|
18
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
transaction do
|
25
|
+
create_managed_user
|
26
|
+
raise ActiveRecord::Rollback unless authorized_user?
|
27
|
+
end
|
28
|
+
|
29
|
+
broadcast(:ok)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :form, :user
|
35
|
+
|
36
|
+
def create_managed_user
|
37
|
+
@user = Decidim::User.create!(
|
38
|
+
name: form.name,
|
39
|
+
organization: form.current_organization,
|
40
|
+
admin: false,
|
41
|
+
managed: true,
|
42
|
+
comments_notifications: true,
|
43
|
+
replies_notifications: true,
|
44
|
+
tos_agreement: true
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def authorized_user?
|
49
|
+
form.authorization.user = @user
|
50
|
+
AuthorizeUser.call(form.authorization) do
|
51
|
+
on(:ok) do
|
52
|
+
return true
|
53
|
+
end
|
54
|
+
on(:invalid) do
|
55
|
+
return false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -7,8 +7,10 @@ module Decidim
|
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
9
|
# form - A form object with the params.
|
10
|
-
|
10
|
+
# parent_scope - A parent scope for the scope to be created
|
11
|
+
def initialize(form, parent_scope = nil)
|
11
12
|
@form = form
|
13
|
+
@parent_scope = parent_scope
|
12
14
|
end
|
13
15
|
|
14
16
|
# Executes the command. Broadcasts these events:
|
@@ -31,7 +33,10 @@ module Decidim
|
|
31
33
|
def create_scope
|
32
34
|
Scope.create!(
|
33
35
|
name: form.name,
|
34
|
-
organization: form.organization
|
36
|
+
organization: form.organization,
|
37
|
+
code: form.code,
|
38
|
+
scope_type: form.scope_type,
|
39
|
+
parent: @parent_scope
|
35
40
|
)
|
36
41
|
end
|
37
42
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic when creating a scope type.
|
6
|
+
class CreateScopeType < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - A form object with the params.
|
10
|
+
def initialize(form)
|
11
|
+
@form = form
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes the command. Broadcasts these events:
|
15
|
+
#
|
16
|
+
# - :ok when everything is valid.
|
17
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
18
|
+
#
|
19
|
+
# Returns nothing.
|
20
|
+
def call
|
21
|
+
return broadcast(:invalid) if form.invalid?
|
22
|
+
|
23
|
+
create_scope_type
|
24
|
+
broadcast(:ok)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :form
|
30
|
+
|
31
|
+
def create_scope_type
|
32
|
+
ScopeType.create!(
|
33
|
+
name: form.name,
|
34
|
+
organization: form.organization,
|
35
|
+
plural: form.plural
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic to impersonate a managed user.
|
6
|
+
class ImpersonateManagedUser < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# form - The form with the authorization info
|
10
|
+
# user - The user to impersonate
|
11
|
+
# current_user - The current user doing the impersonation.
|
12
|
+
def initialize(form, user, current_user)
|
13
|
+
@form = form
|
14
|
+
@user = user
|
15
|
+
@current_user = current_user
|
16
|
+
end
|
17
|
+
|
18
|
+
# Executes the command. Broadcasts these events:
|
19
|
+
#
|
20
|
+
# - :ok when everything is valid.
|
21
|
+
# - :invalid if the impersonation is not valid.
|
22
|
+
#
|
23
|
+
# Returns nothing.
|
24
|
+
def call
|
25
|
+
return broadcast(:invalid) if !user.managed? || !authorization_valid?
|
26
|
+
|
27
|
+
create_impersonation_log
|
28
|
+
enque_expire_job
|
29
|
+
|
30
|
+
broadcast(:ok)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
attr_reader :current_user, :user, :form
|
36
|
+
|
37
|
+
def authorization_valid?
|
38
|
+
return false unless form.valid?
|
39
|
+
Decidim::Authorization.where(
|
40
|
+
user: user,
|
41
|
+
name: form.authorization.handler_name,
|
42
|
+
unique_id: form.authorization.unique_id
|
43
|
+
).any?
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_impersonation_log
|
47
|
+
Decidim::ImpersonationLog.create!(
|
48
|
+
admin: current_user,
|
49
|
+
user: user,
|
50
|
+
started_at: Time.current
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def enque_expire_job
|
55
|
+
Decidim::Admin::ExpireImpersonationJob
|
56
|
+
.set(wait: Decidim::ImpersonationLog::SESSION_TIME_IN_MINUTES.minutes)
|
57
|
+
.perform_later(user, current_user)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|