decidim-admin 0.0.1 → 0.0.2
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/Rakefile +1 -1
- data/app/assets/javascripts/decidim/admin/application.js.es6 +0 -1
- data/app/assets/stylesheets/decidim/admin/_foundation_and_overrides.scss +1 -0
- data/app/assets/stylesheets/decidim/admin/_icons.scss +9 -0
- data/app/assets/stylesheets/decidim/admin/application.scss +1 -0
- data/app/commands/decidim/admin/create_feature.rb +3 -1
- data/app/commands/decidim/admin/create_participatory_process.rb +26 -14
- data/app/commands/decidim/admin/destroy_feature.rb +5 -0
- data/app/commands/decidim/admin/destroy_participatory_process_step.rb +29 -0
- data/app/commands/decidim/admin/update_feature.rb +47 -0
- data/app/commands/decidim/admin/update_organization.rb +3 -1
- data/app/controllers/decidim/admin/features_controller.rb +37 -2
- data/app/controllers/decidim/admin/participatory_process_step_activations_controller.rb +0 -16
- data/app/controllers/decidim/admin/participatory_process_steps_controller.rb +10 -3
- data/app/controllers/decidim/admin/static_pages_controller.rb +4 -4
- data/app/controllers/decidim/admin/user_groups_controller.rb +32 -0
- data/app/controllers/decidim/admin/users_controller.rb +87 -0
- data/app/forms/decidim/admin/category_form.rb +1 -7
- data/app/forms/decidim/admin/feature_form.rb +26 -0
- data/app/forms/decidim/admin/organization_form.rb +2 -0
- data/app/forms/decidim/admin/participatory_process_step_form.rb +1 -1
- data/app/forms/decidim/admin/static_page_form.rb +2 -3
- data/app/models/decidim/admin/abilities/admin_user.rb +6 -0
- data/app/views/decidim/admin/features/_feature.html.erb +4 -1
- data/app/views/decidim/admin/features/_form.html.erb +49 -0
- data/app/views/decidim/admin/features/_settings_fields.html.erb +5 -0
- data/app/views/decidim/admin/features/edit.html.erb +9 -0
- data/app/views/decidim/admin/features/index.html.erb +6 -0
- data/app/views/decidim/admin/features/new.html.erb +1 -1
- data/app/views/decidim/admin/organization/_form.html.erb +8 -0
- data/app/views/decidim/admin/participatory_process_attachments/_form.html.erb +1 -1
- data/app/views/decidim/admin/participatory_process_steps/index.html.erb +2 -6
- data/app/views/decidim/admin/user_groups/index.html.erb +32 -0
- data/app/views/decidim/admin/users/_form.html.erb +6 -0
- data/app/views/decidim/admin/users/index.html.erb +54 -0
- data/app/views/decidim/admin/users/new.html.erb +11 -0
- data/app/views/layouts/decidim/admin/_sidebar.html.erb +2 -0
- data/app/views/layouts/decidim/admin/participatory_process.html.erb +1 -1
- data/config/i18n-tasks.yml +1 -0
- data/config/locales/ca.yml +103 -5
- data/config/locales/en.yml +57 -4
- data/config/locales/es.yml +103 -5
- data/config/routes.rb +11 -0
- data/lib/decidim/admin/features/base_controller.rb +7 -3
- data/lib/decidim/admin/test/factories.rb +8 -0
- metadata +23 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43ab0a410b437196f1663001c22cf03810aed689
|
4
|
+
data.tar.gz: 9b110d4bc37e0483b6e6c9756448701115261fb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9abf94828b7d759eb50dbb978b7d53c6262c7f37dd78f18d4ad64cca1513c5ca8433d3acd6a75bb8839b49a945e3f88b363522e7a7e91e322d570299240f71f1
|
7
|
+
data.tar.gz: f45d28ff90b26b40234b2a4371d90e30ae7c900171a8278fc08d30e595996458d45fb45f680313b84ac2c05a3eadd4c5d7d67e8630ace71ee5828aa0cefe6b6c
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require "decidim/common_rake"
|
2
|
+
require "decidim/dev/common_rake"
|
@@ -36,7 +36,9 @@ module Decidim
|
|
36
36
|
@feature = Feature.create!(
|
37
37
|
manifest_name: manifest.name,
|
38
38
|
name: form.name,
|
39
|
-
participatory_process: participatory_process
|
39
|
+
participatory_process: participatory_process,
|
40
|
+
settings: @form.settings,
|
41
|
+
step_settings: form.step_settings
|
40
42
|
)
|
41
43
|
end
|
42
44
|
|
@@ -20,8 +20,8 @@ module Decidim
|
|
20
20
|
def call
|
21
21
|
return broadcast(:invalid) if form.invalid?
|
22
22
|
|
23
|
-
create_participatory_process
|
24
|
-
broadcast(:ok)
|
23
|
+
process = create_participatory_process
|
24
|
+
broadcast(:ok, process)
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
@@ -29,18 +29,30 @@ module Decidim
|
|
29
29
|
attr_reader :form
|
30
30
|
|
31
31
|
def create_participatory_process
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
32
|
+
transaction do
|
33
|
+
process = ParticipatoryProcess.create!(
|
34
|
+
title: form.title,
|
35
|
+
subtitle: form.subtitle,
|
36
|
+
slug: form.slug,
|
37
|
+
hashtag: form.hashtag,
|
38
|
+
description: form.description,
|
39
|
+
short_description: form.short_description,
|
40
|
+
hero_image: form.hero_image,
|
41
|
+
banner_image: form.banner_image,
|
42
|
+
promoted: form.promoted,
|
43
|
+
organization: form.current_organization
|
44
|
+
)
|
45
|
+
|
46
|
+
process.steps.create!(
|
47
|
+
title: TranslationsHelper.multi_translation(
|
48
|
+
"decidim.admin.participatory_process_steps.default_title",
|
49
|
+
form.current_organization.available_locales
|
50
|
+
),
|
51
|
+
active: true
|
52
|
+
)
|
53
|
+
|
54
|
+
process
|
55
|
+
end
|
44
56
|
end
|
45
57
|
end
|
46
58
|
end
|
@@ -26,11 +26,16 @@ module Decidim
|
|
26
26
|
|
27
27
|
def destroy_feature
|
28
28
|
transaction do
|
29
|
+
run_before_hooks
|
29
30
|
@feature.destroy!
|
30
31
|
run_hooks
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
35
|
+
def run_before_hooks
|
36
|
+
@feature.manifest.run_hooks(:before_destroy, @feature)
|
37
|
+
end
|
38
|
+
|
34
39
|
def run_hooks
|
35
40
|
@feature.manifest.run_hooks(:destroy, @feature)
|
36
41
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Admin
|
4
|
+
# A command that sets all steps in a participatory process as inactive
|
5
|
+
class DestroyParticipatoryProcessStep < Rectify::Command
|
6
|
+
# Public: Initializes the command.
|
7
|
+
#
|
8
|
+
# step - A ParticipatoryProcessStep that will be deactivated
|
9
|
+
def initialize(step)
|
10
|
+
@step = step
|
11
|
+
@participatory_process = step.participatory_process
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes the command. Broadcasts these events:
|
15
|
+
#
|
16
|
+
# - :ok when everything is valid.
|
17
|
+
# - :invalid if the data wasn't valid and we couldn't proceed.
|
18
|
+
#
|
19
|
+
# Returns nothing.
|
20
|
+
def call
|
21
|
+
return broadcast(:invalid, :last_step) if @participatory_process.steps.count == 1
|
22
|
+
return broadcast(:invalid, :active_step) if @step.active?
|
23
|
+
|
24
|
+
@step.destroy!
|
25
|
+
broadcast(:ok)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Admin
|
4
|
+
# This command gets called when a feature is created from the admin panel.
|
5
|
+
class UpdateFeature < Rectify::Command
|
6
|
+
attr_reader :form, :feature
|
7
|
+
|
8
|
+
# Public: Initializes the command.
|
9
|
+
#
|
10
|
+
# form - The form from which the data in this feature comes from.
|
11
|
+
# feature - The feature to update.
|
12
|
+
def initialize(form, feature)
|
13
|
+
@manifest = feature.manifest
|
14
|
+
@form = form
|
15
|
+
@feature = feature
|
16
|
+
end
|
17
|
+
|
18
|
+
# Public: Creates the Feature.
|
19
|
+
#
|
20
|
+
# Broadcasts :ok if created, :invalid otherwise.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if form.invalid?
|
23
|
+
|
24
|
+
transaction do
|
25
|
+
update_feature
|
26
|
+
run_hooks
|
27
|
+
end
|
28
|
+
|
29
|
+
broadcast(:ok)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def update_feature
|
35
|
+
@feature.update_attributes(
|
36
|
+
name: form.name,
|
37
|
+
settings: form.settings,
|
38
|
+
step_settings: form.step_settings
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def run_hooks
|
43
|
+
@manifest.run_hooks(:update, @feature)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -37,11 +37,13 @@ module Decidim
|
|
37
37
|
def attributes
|
38
38
|
{
|
39
39
|
name: form.name,
|
40
|
+
twitter_handler: form.twitter_handler,
|
40
41
|
description: form.description,
|
41
42
|
welcome_text: form.welcome_text,
|
42
43
|
homepage_image: form.homepage_image || organization.homepage_image,
|
43
44
|
logo: form.logo || organization.logo,
|
44
|
-
default_locale: form.default_locale
|
45
|
+
default_locale: form.default_locale,
|
46
|
+
show_statistics: form.show_statistics
|
45
47
|
}
|
46
48
|
end
|
47
49
|
end
|
@@ -20,7 +20,13 @@ module Decidim
|
|
20
20
|
def new
|
21
21
|
authorize! :create, Feature
|
22
22
|
|
23
|
-
@
|
23
|
+
@feature = Feature.new(
|
24
|
+
name: default_name(manifest),
|
25
|
+
manifest_name: params[:type],
|
26
|
+
participatory_process: participatory_process
|
27
|
+
)
|
28
|
+
|
29
|
+
@form = form(FeatureForm).from_model(@feature)
|
24
30
|
end
|
25
31
|
|
26
32
|
def create
|
@@ -40,8 +46,33 @@ module Decidim
|
|
40
46
|
end
|
41
47
|
end
|
42
48
|
|
49
|
+
def edit
|
50
|
+
@feature = query_scope.find(params[:id])
|
51
|
+
authorize! :update, @feature
|
52
|
+
|
53
|
+
@form = form(FeatureForm).from_model(@feature)
|
54
|
+
end
|
55
|
+
|
56
|
+
def update
|
57
|
+
@feature = query_scope.find(params[:id])
|
58
|
+
@form = form(FeatureForm).from_params(params)
|
59
|
+
authorize! :update, @feature
|
60
|
+
|
61
|
+
UpdateFeature.call(@form, @feature) do
|
62
|
+
on(:ok) do
|
63
|
+
flash[:notice] = I18n.t("features.update.success", scope: "decidim.admin")
|
64
|
+
redirect_to action: :index
|
65
|
+
end
|
66
|
+
|
67
|
+
on(:invalid) do
|
68
|
+
flash.now[:alert] = I18n.t("features.update.error", scope: "decidim.admin")
|
69
|
+
render action: "new"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
43
74
|
def destroy
|
44
|
-
@feature =
|
75
|
+
@feature = query_scope.find(params[:id])
|
45
76
|
authorize! :destroy, @feature
|
46
77
|
|
47
78
|
DestroyFeature.call(@feature) do
|
@@ -59,6 +90,10 @@ module Decidim
|
|
59
90
|
|
60
91
|
private
|
61
92
|
|
93
|
+
def query_scope
|
94
|
+
participatory_process.features
|
95
|
+
end
|
96
|
+
|
62
97
|
def manifest
|
63
98
|
Decidim.find_feature_manifest(params[:type])
|
64
99
|
end
|
@@ -24,22 +24,6 @@ module Decidim
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def destroy
|
28
|
-
authorize! :deactivate, process_step
|
29
|
-
|
30
|
-
DeactivateParticipatoryProcessStep.call(process_step) do
|
31
|
-
on(:ok) do
|
32
|
-
flash[:notice] = I18n.t("participatory_process_step_activations.destroy.success", scope: "decidim.admin")
|
33
|
-
end
|
34
|
-
|
35
|
-
on(:invalid) do
|
36
|
-
flash.now[:alert] = I18n.t("participatory_process_step_activations.destroy.error", scope: "decidim.admin")
|
37
|
-
end
|
38
|
-
|
39
|
-
redirect_to participatory_process_steps_path(participatory_process)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
27
|
private
|
44
28
|
|
45
29
|
def process_step
|
@@ -66,11 +66,18 @@ module Decidim
|
|
66
66
|
def destroy
|
67
67
|
@participatory_process_step = collection.find(params[:id])
|
68
68
|
authorize! :destroy, @participatory_process_step
|
69
|
-
@participatory_process_step.destroy!
|
70
69
|
|
71
|
-
|
70
|
+
DestroyParticipatoryProcessStep.call(@participatory_process_step) do
|
71
|
+
on(:ok) do
|
72
|
+
flash[:notice] = I18n.t("participatory_process_steps.destroy.success", scope: "decidim.admin")
|
73
|
+
redirect_to participatory_process_steps_path(participatory_process)
|
74
|
+
end
|
72
75
|
|
73
|
-
|
76
|
+
on(:invalid) do |reason|
|
77
|
+
flash[:alert] = I18n.t("participatory_process_steps.destroy.error.#{reason}", scope: "decidim.admin")
|
78
|
+
redirect_to participatory_process_steps_path(participatory_process)
|
79
|
+
end
|
80
|
+
end
|
74
81
|
end
|
75
82
|
|
76
83
|
private
|
@@ -13,12 +13,12 @@ module Decidim
|
|
13
13
|
|
14
14
|
def new
|
15
15
|
authorize! :new, StaticPage
|
16
|
-
@form = StaticPageForm.
|
16
|
+
@form = form(StaticPageForm).instance
|
17
17
|
end
|
18
18
|
|
19
19
|
def create
|
20
20
|
authorize! :new, StaticPage
|
21
|
-
@form = StaticPageForm.from_params(form_params)
|
21
|
+
@form = form(StaticPageForm).from_params(form_params)
|
22
22
|
|
23
23
|
CreateStaticPage.call(@form) do
|
24
24
|
on(:ok) do
|
@@ -35,13 +35,13 @@ module Decidim
|
|
35
35
|
|
36
36
|
def edit
|
37
37
|
authorize! :update, page
|
38
|
-
@form = StaticPageForm.from_model(page)
|
38
|
+
@form = form(StaticPageForm).from_model(page)
|
39
39
|
end
|
40
40
|
|
41
41
|
def update
|
42
42
|
@page = collection.find(params[:id])
|
43
43
|
authorize! :update, page
|
44
|
-
@form = StaticPageForm.from_params(form_params)
|
44
|
+
@form = form(StaticPageForm).from_params(form_params)
|
45
45
|
|
46
46
|
UpdateStaticPage.call(page, @form) do
|
47
47
|
on(:ok) do
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# Controller that allows managing user groups at the admin panel.
|
6
|
+
#
|
7
|
+
class UserGroupsController < ApplicationController
|
8
|
+
def index
|
9
|
+
authorize! :index, UserGroup
|
10
|
+
@user_groups = collection
|
11
|
+
end
|
12
|
+
|
13
|
+
def verify
|
14
|
+
@user_group = collection.find(params[:id])
|
15
|
+
authorize! :verify, @user_group
|
16
|
+
|
17
|
+
@user_group.verify!
|
18
|
+
|
19
|
+
flash[:notice] = I18n.t("user_groups.verify.success", scope: "decidim.admin")
|
20
|
+
redirect_to decidim_admin.user_groups_path
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def collection
|
26
|
+
UserGroup
|
27
|
+
.includes(:memberships)
|
28
|
+
.where(decidim_user_group_memberships: { decidim_user_id: current_organization.users })
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency "decidim/admin/application_controller"
|
3
|
+
|
4
|
+
module Decidim
|
5
|
+
module Admin
|
6
|
+
# Controller that allows managing all admins at the admin panel.
|
7
|
+
#
|
8
|
+
class UsersController < Admin::ApplicationController
|
9
|
+
def index
|
10
|
+
authorize! :index, User
|
11
|
+
@users = collection
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
authorize! :new, User
|
16
|
+
@form = form(InviteAdminForm).instance
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
authorize! :new, User
|
21
|
+
|
22
|
+
default_params = {
|
23
|
+
organization: current_organization,
|
24
|
+
invitation_instructions: "invite_admin",
|
25
|
+
roles: %w(admin),
|
26
|
+
invited_by: current_user
|
27
|
+
}
|
28
|
+
|
29
|
+
@form = form(InviteAdminForm).from_params(params.merge(default_params))
|
30
|
+
|
31
|
+
InviteUser.call(@form) do
|
32
|
+
on(:ok) do
|
33
|
+
flash[:notice] = I18n.t("users.create.success", scope: "decidim.admin")
|
34
|
+
redirect_to users_path
|
35
|
+
end
|
36
|
+
|
37
|
+
on(:invalid) do
|
38
|
+
flash.now[:alert] = I18n.t("users.create.error", scope: "decidim.admin")
|
39
|
+
render :new
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def resend_invitation
|
45
|
+
authorize! :invite, user
|
46
|
+
|
47
|
+
InviteUserAgain.call(user, "invite_admin") do
|
48
|
+
on(:ok) do
|
49
|
+
flash[:notice] = I18n.t("users.resend_invitation.success", scope: "decidim.admin")
|
50
|
+
end
|
51
|
+
|
52
|
+
on(:invalid) do
|
53
|
+
flash[:alert] = I18n.t("users.resend_invitation.error", scope: "decidim.admin")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
redirect_to users_path
|
58
|
+
end
|
59
|
+
|
60
|
+
def destroy
|
61
|
+
authorize! :destroy, user
|
62
|
+
|
63
|
+
RemoveUserRole.call(user, "admin") do
|
64
|
+
on(:ok) do
|
65
|
+
flash[:notice] = I18n.t("users.destroy.success", scope: "decidim.admin")
|
66
|
+
end
|
67
|
+
|
68
|
+
on(:invalid) do
|
69
|
+
flash[:alert] = I18n.t("users.destroy.error", scope: "decidim.admin")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
redirect_to users_path
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def user
|
79
|
+
@user ||= collection.find(params[:id])
|
80
|
+
end
|
81
|
+
|
82
|
+
def collection
|
83
|
+
@collection ||= current_organization.admins
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -13,15 +13,9 @@ module Decidim
|
|
13
13
|
mimic :category
|
14
14
|
|
15
15
|
validates :name, :description, translatable_presence: true
|
16
|
-
validates :current_process, presence: true
|
17
16
|
validates :parent_id, inclusion: { in: :parent_categories_ids }, allow_blank: true
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
def initialize(attributes = {})
|
22
|
-
@current_process = attributes.delete("current_process") || attributes.delete(:current_process)
|
23
|
-
super
|
24
|
-
end
|
18
|
+
delegate :current_process, to: :context, prefix: false
|
25
19
|
|
26
20
|
def parent_categories
|
27
21
|
@parent_categories ||= current_process.categories.first_class.where.not(id: id)
|
@@ -11,6 +11,32 @@ module Decidim
|
|
11
11
|
|
12
12
|
translatable_attribute :name, String
|
13
13
|
validates :name, translatable_presence: true
|
14
|
+
|
15
|
+
attribute :settings, Object
|
16
|
+
attribute :manifest
|
17
|
+
|
18
|
+
attribute :step_settings, Hash[String => Object]
|
19
|
+
attribute :participatory_process
|
20
|
+
|
21
|
+
def map_model(model)
|
22
|
+
self.attributes = model.attributes
|
23
|
+
self.settings = model.settings
|
24
|
+
end
|
25
|
+
|
26
|
+
def settings?
|
27
|
+
settings.manifest.attributes.any?
|
28
|
+
end
|
29
|
+
|
30
|
+
def step_settings?
|
31
|
+
return false unless participatory_process.steps.any?
|
32
|
+
|
33
|
+
step_settings
|
34
|
+
.values
|
35
|
+
.map(&:manifest)
|
36
|
+
.flat_map(&:attributes)
|
37
|
+
.flat_map(&:keys)
|
38
|
+
.any?
|
39
|
+
end
|
14
40
|
end
|
15
41
|
end
|
16
42
|
end
|
@@ -10,9 +10,11 @@ module Decidim
|
|
10
10
|
mimic :organization
|
11
11
|
|
12
12
|
attribute :name, String
|
13
|
+
attribute :twitter_handler, String
|
13
14
|
attribute :default_locale, String
|
14
15
|
attribute :homepage_image
|
15
16
|
attribute :logo
|
17
|
+
attribute :show_statistics
|
16
18
|
|
17
19
|
translatable_attribute :description, String
|
18
20
|
translatable_attribute :welcome_text, String
|
@@ -16,7 +16,7 @@ module Decidim
|
|
16
16
|
attribute :start_date, DateTime
|
17
17
|
attribute :end_date, DateTime
|
18
18
|
|
19
|
-
validates :title,
|
19
|
+
validates :title, translatable_presence: true
|
20
20
|
|
21
21
|
validates :start_date, date: { before: :end_date, allow_blank: true, if: proc { |obj| obj.end_date.present? } }
|
22
22
|
validates :end_date, date: { after: :start_date, allow_blank: true, if: proc { |obj| obj.start_date.present? } }
|
@@ -6,17 +6,16 @@ module Decidim
|
|
6
6
|
include TranslatableAttributes
|
7
7
|
|
8
8
|
attribute :slug, String
|
9
|
-
attribute :organization, Decidim::Organization
|
10
9
|
translatable_attribute :title, String
|
11
10
|
translatable_attribute :content, String
|
12
11
|
|
13
12
|
mimic :static_page
|
14
13
|
|
15
|
-
validates :slug,
|
14
|
+
validates :slug, presence: true
|
16
15
|
validates :title, :content, translatable_presence: true
|
17
16
|
validate :slug, :slug_uniqueness
|
18
17
|
|
19
|
-
alias current_organization
|
18
|
+
alias organization current_organization
|
20
19
|
|
21
20
|
private
|
22
21
|
|
@@ -27,6 +27,12 @@ module Decidim
|
|
27
27
|
can :read, :admin_dashboard
|
28
28
|
can :manage, ParticipatoryProcessAttachment
|
29
29
|
can :manage, Scope
|
30
|
+
can [:create, :index, :new, :read, :invite], User
|
31
|
+
can [:destroy], [User] do |user_to_destroy|
|
32
|
+
user != user_to_destroy
|
33
|
+
end
|
34
|
+
|
35
|
+
can [:index, :verify], UserGroup
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
<td>
|
3
3
|
<%= link_to decidim.feature_path(participatory_process, feature), target: "_blank" do %>
|
4
4
|
<%= translated_attribute feature.name %>
|
5
|
+
<%= icon "external-link" %>
|
5
6
|
<% end %>
|
6
7
|
</td>
|
7
8
|
<td>
|
@@ -11,10 +12,12 @@
|
|
11
12
|
|
12
13
|
<% if feature.manifest.admin_engine %>
|
13
14
|
<%= link_to manage_feature_path(participatory_process, feature), class: "button small" do %>
|
14
|
-
<%= t "actions.
|
15
|
+
<%= t "actions.manage", scope: "decidim.admin" %>
|
15
16
|
<% end %>
|
16
17
|
<% end %>
|
17
18
|
|
19
|
+
<%= link_to t("actions.configure", scope: "decidim.admin"), url_for(action: :edit, id: feature, controller: "features"), class: "small button" if can? :update, feature %>
|
20
|
+
|
18
21
|
<%= link_to t("actions.destroy", scope: "decidim.admin"), url_for(action: :destroy, id: feature, controller: "features"), method: :delete, class: "small alert button", data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } if can? :destroy, feature %>
|
19
22
|
</td>
|
20
23
|
</tr>
|
@@ -1,3 +1,52 @@
|
|
1
1
|
<div class="field">
|
2
2
|
<%= form.translated :text_field, :name, autofocus: true %>
|
3
|
+
|
4
|
+
<% if form.object.settings? %>
|
5
|
+
<fieldset class="global-settings">
|
6
|
+
<div class="card">
|
7
|
+
<div class="card-divider">
|
8
|
+
<legend><%= t ".global_settings" %></legend>
|
9
|
+
</div>
|
10
|
+
<div class="card-section">
|
11
|
+
<%= form.fields_for :settings, form.object.settings do |settings_fields| %>
|
12
|
+
<%= render partial: "decidim/admin/features/settings_fields",
|
13
|
+
locals: {
|
14
|
+
form: settings_fields,
|
15
|
+
feature: @feature,
|
16
|
+
settings_name: "global"
|
17
|
+
} %>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</fieldset>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<% if form.object.step_settings? %>
|
25
|
+
<fieldset class="step-settings">
|
26
|
+
<div class="card">
|
27
|
+
<div class="card-divider">
|
28
|
+
<legend><%= t ".step_settings" %></legend>
|
29
|
+
</div>
|
30
|
+
<div class="card-section">
|
31
|
+
<% participatory_process.steps.each do |step| %>
|
32
|
+
<fieldset class="step-settings-<%= step.id %>">
|
33
|
+
<legend><%= step.position + 1 %>. <%= translated_attribute step.title %></legend>
|
34
|
+
<% step_settings = form.object.step_settings[step.id.to_s] %>
|
35
|
+
|
36
|
+
<%= form.fields_for "step_settings", nil do |settings_fields| %>
|
37
|
+
<%= settings_fields.fields_for step.id.to_s, step_settings do |settings_fields| %>
|
38
|
+
<%= render partial: "decidim/admin/features/settings_fields",
|
39
|
+
locals: {
|
40
|
+
form: settings_fields,
|
41
|
+
feature: feature,
|
42
|
+
settings_name: "step"
|
43
|
+
} %>
|
44
|
+
<% end %>
|
45
|
+
<% end %>
|
46
|
+
</fieldset>
|
47
|
+
<% end %>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
</fieldset>
|
51
|
+
<% end %>
|
3
52
|
</div>
|