decidim-admin 0.3.2 → 0.4.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/stylesheets/decidim/admin/extra/_label-required.scss +3 -0
- data/app/assets/stylesheets/decidim/admin/extra/_title_bar.scss +57 -1
- data/app/commands/decidim/admin/create_participatory_process_admin.rb +28 -7
- data/app/commands/decidim/admin/create_participatory_process_step.rb +2 -1
- data/app/commands/decidim/admin/destroy_participatory_process_step.rb +5 -2
- data/app/commands/decidim/admin/update_feature.rb +1 -0
- data/app/commands/decidim/admin/update_organization.rb +10 -5
- data/app/commands/decidim/admin/update_participatory_process.rb +4 -2
- data/app/controllers/decidim/admin/application_controller.rb +2 -0
- data/app/controllers/decidim/admin/concerns/has_attachments.rb +10 -1
- data/app/controllers/decidim/admin/concerns/participatory_process_admin.rb +0 -5
- data/app/controllers/decidim/admin/features/base_controller.rb +0 -1
- data/app/controllers/decidim/admin/moderations_controller.rb +7 -4
- data/app/controllers/decidim/admin/organization_controller.rb +9 -3
- data/app/controllers/decidim/admin/participatory_process_user_roles_controller.rb +17 -0
- data/app/controllers/decidim/admin/participatory_processes_controller.rb +11 -3
- data/app/forms/decidim/admin/feature_form.rb +6 -0
- data/app/forms/decidim/admin/organization_form.rb +5 -0
- data/app/forms/decidim/admin/participatory_process_copy_form.rb +2 -3
- data/app/forms/decidim/admin/participatory_process_form.rb +2 -0
- data/app/forms/decidim/admin/static_page_form.rb +6 -0
- data/app/helpers/decidim/admin/menu_helper.rb +1 -1
- data/app/jobs/decidim/admin/newsletter_job.rb +9 -5
- data/app/views/decidim/admin/attachments/_form.html.erb +1 -12
- data/app/views/decidim/admin/features/_feature.html.erb +2 -2
- data/app/views/decidim/admin/features/_form.html.erb +18 -0
- data/app/views/decidim/admin/moderations/_report.html.erb +2 -2
- data/app/views/decidim/admin/organization/_form.html.erb +5 -35
- data/app/views/decidim/admin/participatory_process_groups/_form.html.erb +1 -1
- data/app/views/decidim/admin/participatory_process_user_roles/index.html.erb +16 -0
- data/app/views/decidim/admin/participatory_processes/_form.html.erb +2 -14
- data/app/views/layouts/decidim/admin/_title_bar.html.erb +26 -19
- data/app/views/layouts/decidim/admin/participatory_process.html.erb +2 -2
- data/config/i18n-tasks.yml +2 -0
- data/config/locales/ca.yml +9 -5
- data/config/locales/en.yml +9 -5
- data/config/locales/es.yml +11 -5
- data/config/locales/eu.yml +0 -5
- data/config/locales/fr.yml +18 -23
- data/config/locales/it.yml +0 -5
- data/config/routes.rb +5 -3
- data/lib/decidim/admin/test/manage_attachments_examples.rb +1 -2
- metadata +7 -7
- data/app/assets/stylesheets/decidim/admin/extra/_language-chooser.scss +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47c26318821b198a5abef8cc9514114d9be1a543
|
4
|
+
data.tar.gz: b78c4f9d445ee587ffc20fad6cdd935884f8ae2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbb45517bed3f266030d3ac5ece8adc8cd387040bf34def83bc72bebde4eb6457d989ac6d591a7d42fc08264251b40a2d626a0f03c868ab6ef3af0f7b9680c20
|
7
|
+
data.tar.gz: 0e26714cb55d3f073cf0dbeb58584d2413016b2fbb9edd49fcf861bd9e0d2737f73a252334c2b1f853fb8c4c2b1457d9f6fe49824d05958eabc6b8b5b1d98b0c
|
@@ -2,4 +2,60 @@
|
|
2
2
|
a.logo {
|
3
3
|
color: #fff;
|
4
4
|
}
|
5
|
-
|
5
|
+
@include breakpoint(smallmedium down){
|
6
|
+
border-top: 2.125rem solid darken($dark-gray, 15%);
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
.tool-bar{
|
11
|
+
text-align: right;
|
12
|
+
position: absolute;
|
13
|
+
right: 2rem;
|
14
|
+
vertical-align: middle;
|
15
|
+
@include breakpoint(smallmedium down){
|
16
|
+
position: initial;
|
17
|
+
}
|
18
|
+
.user-login{
|
19
|
+
vertical-align: middle;
|
20
|
+
position: initial;
|
21
|
+
text-align: left;
|
22
|
+
display: inline-block;
|
23
|
+
margin-top: 0px;
|
24
|
+
@include breakpoint(smallmedium down){
|
25
|
+
position: absolute;
|
26
|
+
right: 2rem;
|
27
|
+
margin-top: -1.2rem;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
.language-choose{
|
31
|
+
position: initial;
|
32
|
+
vertical-align: middle;
|
33
|
+
text-align: left;
|
34
|
+
display: inline-block;
|
35
|
+
vertical-align: middle;
|
36
|
+
.is-dropdown-submenu-parent a{
|
37
|
+
color: #fff;
|
38
|
+
&:after{
|
39
|
+
border-color: #fff transparent transparent !important;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
.is-dropdown-submenu li > a {
|
43
|
+
color: $dark-gray;
|
44
|
+
&:hover{
|
45
|
+
background-color: lighten($medium-gray, 30%)
|
46
|
+
}
|
47
|
+
}
|
48
|
+
@include breakpoint(smallmedium down){
|
49
|
+
font-size: .8rem;
|
50
|
+
position: absolute;
|
51
|
+
top: -2.2rem;
|
52
|
+
left: .5rem;
|
53
|
+
margin-left: 0;
|
54
|
+
.dropdown.menu > li.is-dropdown-submenu-parent > a::after{
|
55
|
+
border-width: 3px;
|
56
|
+
right: 10px;
|
57
|
+
margin-top: 0;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
@@ -24,9 +24,12 @@ module Decidim
|
|
24
24
|
# Returns nothing.
|
25
25
|
def call
|
26
26
|
return broadcast(:invalid) if form.invalid?
|
27
|
-
return broadcast(:invalid) unless user
|
28
27
|
|
29
|
-
|
28
|
+
ActiveRecord::Base.transaction do
|
29
|
+
create_or_invite_user
|
30
|
+
create_role
|
31
|
+
end
|
32
|
+
|
30
33
|
broadcast(:ok)
|
31
34
|
rescue ActiveRecord::RecordInvalid
|
32
35
|
form.errors.add(:email, :taken)
|
@@ -35,21 +38,39 @@ module Decidim
|
|
35
38
|
|
36
39
|
private
|
37
40
|
|
38
|
-
attr_reader :form, :participatory_process, :current_user
|
41
|
+
attr_reader :form, :participatory_process, :current_user, :user
|
39
42
|
|
40
43
|
def create_role
|
41
|
-
ParticipatoryProcessUserRole.
|
44
|
+
ParticipatoryProcessUserRole.find_or_create_by!(
|
42
45
|
role: form.role.to_sym,
|
43
46
|
user: user,
|
44
47
|
participatory_process: @participatory_process
|
45
48
|
)
|
46
49
|
end
|
47
50
|
|
48
|
-
def
|
49
|
-
@user ||=
|
51
|
+
def create_or_invite_user
|
52
|
+
@user ||= existing_user || new_user
|
53
|
+
end
|
54
|
+
|
55
|
+
def existing_user
|
56
|
+
return @existing_user if defined?(@existing_user)
|
57
|
+
|
58
|
+
@existing_user = User.where(
|
50
59
|
email: form.email,
|
51
60
|
organization: participatory_process.organization
|
52
|
-
).first
|
61
|
+
).first
|
62
|
+
|
63
|
+
if @existing_user && !@existing_user.invitation_accepted?
|
64
|
+
InviteUserAgain.call(@existing_user, invitation_instructions)
|
65
|
+
end
|
66
|
+
|
67
|
+
@existing_user
|
68
|
+
end
|
69
|
+
|
70
|
+
def new_user
|
71
|
+
new_user_form = user_form.dup
|
72
|
+
new_user_form.roles = []
|
73
|
+
@new_user ||= InviteUser.call(new_user_form) do
|
53
74
|
on(:ok) do |user|
|
54
75
|
return user
|
55
76
|
end
|
@@ -38,7 +38,8 @@ module Decidim
|
|
38
38
|
description: form.description,
|
39
39
|
start_date: form.start_date,
|
40
40
|
end_date: form.end_date,
|
41
|
-
participatory_process: @participatory_process
|
41
|
+
participatory_process: @participatory_process,
|
42
|
+
active: @participatory_process.steps.empty?
|
42
43
|
)
|
43
44
|
end
|
44
45
|
end
|
@@ -19,8 +19,7 @@ module Decidim
|
|
19
19
|
#
|
20
20
|
# Returns nothing.
|
21
21
|
def call
|
22
|
-
return broadcast(:invalid, :
|
23
|
-
return broadcast(:invalid, :active_step) if @step.active?
|
22
|
+
return broadcast(:invalid, :active_step) if active_step?
|
24
23
|
|
25
24
|
@step.destroy!
|
26
25
|
reorder_steps
|
@@ -29,6 +28,10 @@ module Decidim
|
|
29
28
|
|
30
29
|
private
|
31
30
|
|
31
|
+
def active_step?
|
32
|
+
@participatory_process.steps.count > 1 && @step.active?
|
33
|
+
end
|
34
|
+
|
32
35
|
def reorder_steps
|
33
36
|
steps = @participatory_process.steps.reload
|
34
37
|
|
@@ -53,12 +53,17 @@ module Decidim
|
|
53
53
|
github_handler: form.github_handler,
|
54
54
|
description: form.description,
|
55
55
|
welcome_text: form.welcome_text,
|
56
|
-
homepage_image: form.homepage_image
|
57
|
-
|
58
|
-
|
56
|
+
homepage_image: form.homepage_image,
|
57
|
+
remove_homepage_image: form.remove_homepage_image,
|
58
|
+
logo: form.logo,
|
59
|
+
remove_logo: form.remove_logo,
|
60
|
+
favicon: form.favicon,
|
61
|
+
remove_favicon: form.remove_favicon,
|
59
62
|
default_locale: form.default_locale,
|
60
|
-
official_img_header: form.official_img_header
|
61
|
-
|
63
|
+
official_img_header: form.official_img_header,
|
64
|
+
remove_official_img_header: form.remove_official_img_header,
|
65
|
+
official_img_footer: form.official_img_footer,
|
66
|
+
remove_official_img_footer: form.remove_official_img_footer,
|
62
67
|
official_url: form.official_url,
|
63
68
|
show_statistics: form.show_statistics
|
64
69
|
}
|
@@ -48,8 +48,10 @@ module Decidim
|
|
48
48
|
subtitle: form.subtitle,
|
49
49
|
slug: form.slug,
|
50
50
|
hashtag: form.hashtag,
|
51
|
-
hero_image: form.hero_image
|
52
|
-
|
51
|
+
hero_image: form.hero_image,
|
52
|
+
remove_hero_image: form.remove_hero_image,
|
53
|
+
banner_image: form.banner_image,
|
54
|
+
remove_banner_image: form.remove_banner_image,
|
53
55
|
promoted: form.promoted,
|
54
56
|
description: form.description,
|
55
57
|
short_description: form.short_description,
|
@@ -9,6 +9,7 @@ module Decidim
|
|
9
9
|
include FormFactory
|
10
10
|
include LocaleSwitcher
|
11
11
|
include PayloadInfo
|
12
|
+
|
12
13
|
helper Decidim::Admin::ApplicationHelper
|
13
14
|
helper Decidim::Admin::AttributesDisplayHelper
|
14
15
|
helper Decidim::Admin::FeatureSettingsHelper
|
@@ -21,6 +22,7 @@ module Decidim
|
|
21
22
|
helper Decidim::OrganizationScopesHelper
|
22
23
|
helper Decidim::TranslationsHelper
|
23
24
|
helper Decidim::LanguageChooserHelper
|
25
|
+
helper Decidim::FeaturePathHelper
|
24
26
|
|
25
27
|
protect_from_forgery with: :exception, prepend: true
|
26
28
|
|
@@ -54,7 +54,7 @@ module Decidim
|
|
54
54
|
def update
|
55
55
|
@attachment = collection.find(params[:id])
|
56
56
|
authorize! :update, authorization_object
|
57
|
-
@form = form(AttachmentForm).from_params(
|
57
|
+
@form = form(AttachmentForm).from_params(attachment_params)
|
58
58
|
|
59
59
|
UpdateAttachment.call(@attachment, @form) do
|
60
60
|
on(:ok) do
|
@@ -110,6 +110,15 @@ module Decidim
|
|
110
110
|
def collection
|
111
111
|
@collection ||= attached_to.attachments
|
112
112
|
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def attachment_params
|
117
|
+
{
|
118
|
+
id: params[:id],
|
119
|
+
file: @attachment.file
|
120
|
+
}.merge(params[:attachment].to_unsafe_h)
|
121
|
+
end
|
113
122
|
end
|
114
123
|
end
|
115
124
|
end
|
@@ -11,7 +11,6 @@ module Decidim
|
|
11
11
|
|
12
12
|
included do
|
13
13
|
helper_method :participatory_process
|
14
|
-
before_action :ensure_participatory_process
|
15
14
|
|
16
15
|
layout "decidim/admin/participatory_process"
|
17
16
|
end
|
@@ -22,10 +21,6 @@ module Decidim
|
|
22
21
|
@participatory_process ||=
|
23
22
|
current_organization.participatory_processes.find(params[:participatory_process_id])
|
24
23
|
end
|
25
|
-
|
26
|
-
def ensure_participatory_process
|
27
|
-
raise ActionController::RoutingError, "Not Found" unless participatory_process
|
28
|
-
end
|
29
24
|
end
|
30
25
|
end
|
31
26
|
end
|
@@ -48,17 +48,20 @@ module Decidim
|
|
48
48
|
|
49
49
|
def moderations
|
50
50
|
@moderations ||= begin
|
51
|
-
moderations = Decidim::Moderation.where(participatory_process: participatory_process)
|
52
51
|
if params[:hidden]
|
53
|
-
|
52
|
+
participatory_process_moderations.where.not(hidden_at: nil)
|
54
53
|
else
|
55
|
-
|
54
|
+
participatory_process_moderations.where(hidden_at: nil)
|
56
55
|
end
|
57
56
|
end
|
58
57
|
end
|
59
58
|
|
60
59
|
def reportable
|
61
|
-
@reportable ||=
|
60
|
+
@reportable ||= participatory_process_moderations.find(params[:id]).reportable
|
61
|
+
end
|
62
|
+
|
63
|
+
def participatory_process_moderations
|
64
|
+
@participatory_process_moderations ||= Decidim::Moderation.where(participatory_process: participatory_process)
|
62
65
|
end
|
63
66
|
end
|
64
67
|
end
|
@@ -16,7 +16,7 @@ module Decidim
|
|
16
16
|
|
17
17
|
def update
|
18
18
|
authorize! :update, current_organization
|
19
|
-
@form = form(OrganizationForm).from_params(
|
19
|
+
@form = form(OrganizationForm).from_params(organization_params)
|
20
20
|
|
21
21
|
UpdateOrganization.call(current_organization, @form) do
|
22
22
|
on(:ok) do
|
@@ -33,10 +33,16 @@ module Decidim
|
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
-
def
|
36
|
+
def organization_params
|
37
37
|
params[:organization] ||= {}
|
38
38
|
params[:organization][:id] ||= current_organization.id
|
39
|
-
|
39
|
+
{
|
40
|
+
homepage_image: current_organization.homepage_image,
|
41
|
+
logo: current_organization.logo,
|
42
|
+
favicon: current_organization.favicon,
|
43
|
+
official_img_header: current_organization.official_img_header,
|
44
|
+
official_img_footer: current_organization.official_img_footer
|
45
|
+
}.merge(params[:organization].to_unsafe_h)
|
40
46
|
end
|
41
47
|
end
|
42
48
|
end
|
@@ -70,6 +70,23 @@ module Decidim
|
|
70
70
|
redirect_to participatory_process_user_roles_path(@participatory_process_user_role.participatory_process)
|
71
71
|
end
|
72
72
|
|
73
|
+
def resend_invitation
|
74
|
+
@user_role = collection.find(params[:id])
|
75
|
+
authorize! :invite, @user_role
|
76
|
+
|
77
|
+
InviteUserAgain.call(@user_role.user, "invite_admin") do
|
78
|
+
on(:ok) do
|
79
|
+
flash[:notice] = I18n.t("users.resend_invitation.success", scope: "decidim.admin")
|
80
|
+
end
|
81
|
+
|
82
|
+
on(:invalid) do
|
83
|
+
flash[:alert] = I18n.t("users.resend_invitation.error", scope: "decidim.admin")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
redirect_to participatory_process_user_roles_path(participatory_process)
|
88
|
+
end
|
89
|
+
|
73
90
|
private
|
74
91
|
|
75
92
|
def collection
|
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
CreateParticipatoryProcess.call(@form) do
|
28
28
|
on(:ok) do |participatory_process|
|
29
29
|
flash[:notice] = I18n.t("participatory_processes.create.success", scope: "decidim.admin")
|
30
|
-
redirect_to
|
30
|
+
redirect_to participatory_process_steps_path(participatory_process)
|
31
31
|
end
|
32
32
|
|
33
33
|
on(:invalid) do
|
@@ -47,7 +47,7 @@ module Decidim
|
|
47
47
|
def update
|
48
48
|
@participatory_process = collection.find(params[:id])
|
49
49
|
authorize! :update, @participatory_process
|
50
|
-
@form = form(ParticipatoryProcessForm).from_params(
|
50
|
+
@form = form(ParticipatoryProcessForm).from_params(participatory_process_params)
|
51
51
|
|
52
52
|
UpdateParticipatoryProcess.call(@participatory_process, @form) do
|
53
53
|
on(:ok) do |participatory_process|
|
@@ -57,7 +57,7 @@ module Decidim
|
|
57
57
|
|
58
58
|
on(:invalid) do
|
59
59
|
flash.now[:alert] = I18n.t("participatory_processes.update.error", scope: "decidim.admin")
|
60
|
-
render :edit
|
60
|
+
render :edit, layout: "decidim/admin/participatory_process"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -88,6 +88,14 @@ module Decidim
|
|
88
88
|
def collection
|
89
89
|
@collection ||= ManageableParticipatoryProcessesForUser.for(current_user)
|
90
90
|
end
|
91
|
+
|
92
|
+
def participatory_process_params
|
93
|
+
{
|
94
|
+
id: params[:id],
|
95
|
+
hero_image: @participatory_process.hero_image,
|
96
|
+
banner_image: @participatory_process.banner_image
|
97
|
+
}.merge(params[:participatory_process].to_unsafe_h)
|
98
|
+
end
|
91
99
|
end
|
92
100
|
end
|
93
101
|
end
|
@@ -14,6 +14,7 @@ module Decidim
|
|
14
14
|
validates :name, translatable_presence: true
|
15
15
|
|
16
16
|
attribute :settings, Object
|
17
|
+
attribute :default_step_settings, Object
|
17
18
|
attribute :manifest
|
18
19
|
attribute :weight, Integer, default: 0
|
19
20
|
|
@@ -23,12 +24,17 @@ module Decidim
|
|
23
24
|
def map_model(model)
|
24
25
|
self.attributes = model.attributes
|
25
26
|
self.settings = model.settings
|
27
|
+
self.default_step_settings = model.default_step_settings
|
26
28
|
end
|
27
29
|
|
28
30
|
def settings?
|
29
31
|
settings.manifest.attributes.any?
|
30
32
|
end
|
31
33
|
|
34
|
+
def default_step_settings?
|
35
|
+
default_step_settings.manifest.attributes.any?
|
36
|
+
end
|
37
|
+
|
32
38
|
def step_settings?
|
33
39
|
return false unless participatory_process.steps.any?
|
34
40
|
|
@@ -19,11 +19,16 @@ module Decidim
|
|
19
19
|
attribute :github_handler, String
|
20
20
|
attribute :default_locale, String
|
21
21
|
attribute :homepage_image
|
22
|
+
attribute :remove_homepage_image
|
22
23
|
attribute :logo
|
24
|
+
attribute :remove_logo
|
23
25
|
attribute :favicon
|
26
|
+
attribute :remove_favicon
|
24
27
|
attribute :official_url
|
25
28
|
attribute :official_img_header
|
29
|
+
attribute :remove_official_img_header
|
26
30
|
attribute :official_img_footer
|
31
|
+
attribute :remove_official_img_footer
|
27
32
|
attribute :show_statistics
|
28
33
|
|
29
34
|
translatable_attribute :description, String
|