decidim-participatory_processes 0.28.2 → 0.29.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/participatory_process_groups/content_blocks/extra_data_cell.rb +4 -4
- data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb +0 -2
- data/app/cells/decidim/participatory_processes/content_blocks/stats_cell.rb +1 -1
- data/app/cells/decidim/participatory_processes/process_filters/filter_tabs.erb +2 -2
- data/app/cells/decidim/participatory_processes/process_filters/show.erb +1 -1
- data/app/cells/decidim/participatory_processes/process_filters/type_filter.erb +1 -1
- data/app/cells/decidim/participatory_processes/process_filters_cell.rb +1 -2
- data/app/cells/decidim/participatory_processes/process_group_s_cell.rb +5 -1
- data/app/commands/decidim/participatory_processes/admin/copy_participatory_process.rb +5 -7
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +27 -99
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process_group.rb +10 -53
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process_step.rb +9 -36
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process_type.rb +4 -34
- data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_step.rb +6 -37
- data/app/commands/decidim/participatory_processes/admin/import_participatory_process.rb +5 -4
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +10 -80
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process_group.rb +6 -55
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb +8 -52
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb +2 -38
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_copies_controller.rb +1 -1
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_groups_controller.rb +2 -2
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_steps_controller.rb +2 -2
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_types_controller.rb +2 -2
- data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb +1 -1
- data/app/controllers/decidim/participatory_processes/admin/participatory_space_private_users_controller.rb +1 -1
- data/app/controllers/decidim/participatory_processes/application_controller.rb +3 -0
- data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +1 -6
- data/app/events/decidim/participatory_process_role_assigned_event.rb +0 -5
- data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +0 -5
- data/app/models/decidim/participatory_process.rb +0 -3
- data/app/models/decidim/participatory_process_step.rb +1 -1
- data/app/permissions/decidim/participatory_processes/permissions.rb +1 -1
- data/app/presenters/decidim/participatory_processes/participatory_process_presenter.rb +0 -4
- data/app/queries/decidim/participatory_processes/stats_participants_count.rb +4 -4
- data/app/serializers/decidim/participatory_processes/participatory_process_importer.rb +2 -5
- data/app/serializers/decidim/participatory_processes/participatory_process_serializer.rb +0 -3
- data/app/views/decidim/participatory_processes/admin/participatory_process_steps/index.html.erb +1 -1
- data/app/views/decidim/participatory_processes/admin/participatory_process_steps/show.html.erb +1 -1
- data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/index.html.erb +1 -1
- data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +5 -17
- data/app/views/decidim/participatory_processes/participatory_processes/all_metrics.html.erb +4 -1
- data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +23 -19
- data/config/locales/ar.yml +0 -3
- data/config/locales/bg.yml +1 -4
- data/config/locales/ca.yml +1 -4
- data/config/locales/cs.yml +1 -4
- data/config/locales/de.yml +1 -4
- data/config/locales/el.yml +0 -4
- data/config/locales/en.yml +1 -4
- data/config/locales/es-MX.yml +1 -4
- data/config/locales/es-PY.yml +1 -4
- data/config/locales/es.yml +1 -4
- data/config/locales/eu.yml +1 -4
- data/config/locales/fi-plain.yml +1 -4
- data/config/locales/fi.yml +1 -4
- data/config/locales/fr-CA.yml +1 -4
- data/config/locales/fr.yml +1 -4
- data/config/locales/gl.yml +0 -4
- data/config/locales/hu.yml +0 -4
- data/config/locales/id-ID.yml +0 -2
- data/config/locales/is-IS.yml +0 -2
- data/config/locales/it.yml +0 -4
- data/config/locales/ja.yml +1 -4
- data/config/locales/lb.yml +0 -3
- data/config/locales/lt.yml +0 -4
- data/config/locales/lv.yml +0 -3
- data/config/locales/nl.yml +0 -4
- data/config/locales/no.yml +0 -4
- data/config/locales/pl.yml +1 -4
- data/config/locales/pt-BR.yml +0 -4
- data/config/locales/pt.yml +0 -4
- data/config/locales/ro-RO.yml +0 -4
- data/config/locales/ru.yml +0 -2
- data/config/locales/sk.yml +0 -3
- data/config/locales/sr-CS.yml +0 -1
- data/config/locales/sv.yml +0 -4
- data/config/locales/tr-TR.yml +0 -4
- data/config/locales/uk.yml +0 -2
- data/config/locales/zh-CN.yml +0 -3
- data/config/locales/zh-TW.yml +0 -4
- data/db/migrate/20240529161054_add_link_to_decidim_attachments.rb +7 -0
- data/decidim-participatory_processes.gemspec +1 -1
- data/lib/decidim/api/participatory_process_type.rb +0 -7
- data/lib/decidim/participatory_processes/content_blocks/registry_manager.rb +1 -1
- data/lib/decidim/participatory_processes/engine.rb +1 -0
- data/lib/decidim/participatory_processes/menu.rb +11 -0
- data/lib/decidim/participatory_processes/seeds.rb +4 -12
- data/lib/decidim/participatory_processes/test/factories.rb +0 -3
- data/lib/decidim/participatory_processes/version.rb +1 -1
- data/lib/tasks/decidim_participatory_processes.rake +1 -1
- metadata +14 -18
- data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb +0 -46
- data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_type.rb +0 -49
- data/app/views/decidim/participatory_processes/participatory_processes/_statistics.html.erb +0 -0
- data/app/views/layouts/decidim/_process_header.html.erb +0 -17
- data/app/views/layouts/decidim/participatory_process.html.erb +0 -18
@@ -3,95 +3,25 @@
|
|
3
3
|
module Decidim
|
4
4
|
module ParticipatoryProcesses
|
5
5
|
module Admin
|
6
|
-
# A command with all the business logic when
|
6
|
+
# A command with all the business logic when updating a participatory
|
7
7
|
# process in the system.
|
8
|
-
class UpdateParticipatoryProcess < Decidim::
|
9
|
-
|
8
|
+
class UpdateParticipatoryProcess < Decidim::Commands::UpdateResource
|
9
|
+
fetch_file_attributes :hero_image
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@participatory_process = participatory_process
|
17
|
-
@form = form
|
18
|
-
end
|
19
|
-
|
20
|
-
# Executes the command. Broadcasts these events:
|
21
|
-
#
|
22
|
-
# - :ok when everything is valid.
|
23
|
-
# - :invalid if the form was not valid and we could not proceed.
|
24
|
-
#
|
25
|
-
# Returns nothing.
|
26
|
-
def call
|
27
|
-
return broadcast(:invalid) if form.invalid?
|
28
|
-
|
29
|
-
update_participatory_process
|
30
|
-
|
31
|
-
if @participatory_process.valid?
|
32
|
-
broadcast(:ok, @participatory_process)
|
33
|
-
else
|
34
|
-
form.errors.add(:hero_image, @participatory_process.errors[:hero_image]) if @participatory_process.errors.include? :hero_image
|
35
|
-
form.errors.add(:banner_image, @participatory_process.errors[:banner_image]) if @participatory_process.errors.include? :banner_image
|
36
|
-
broadcast(:invalid)
|
37
|
-
end
|
38
|
-
end
|
11
|
+
fetch_form_attributes :title, :subtitle, :weight, :slug, :hashtag, :promoted, :description,
|
12
|
+
:short_description, :scopes_enabled, :scope, :scope_type_max_depth,
|
13
|
+
:private_space, :developer_group, :local_area, :area, :target, :participatory_scope,
|
14
|
+
:participatory_structure, :meta_scope, :start_date, :end_date, :participatory_process_group,
|
15
|
+
:participatory_process_type, :announcement
|
39
16
|
|
40
17
|
private
|
41
18
|
|
42
|
-
attr_reader :form, :participatory_process
|
43
|
-
|
44
|
-
def update_participatory_process
|
45
|
-
@participatory_process.assign_attributes(attributes)
|
46
|
-
return unless @participatory_process.valid?
|
47
|
-
|
48
|
-
@participatory_process.save!
|
49
|
-
|
50
|
-
Decidim.traceability.perform_action!(:update, @participatory_process, form.current_user) do
|
51
|
-
@participatory_process
|
52
|
-
end
|
53
|
-
link_related_processes
|
54
|
-
end
|
55
|
-
|
56
|
-
def attributes
|
57
|
-
{
|
58
|
-
title: form.title,
|
59
|
-
subtitle: form.subtitle,
|
60
|
-
weight: form.weight,
|
61
|
-
slug: form.slug,
|
62
|
-
hashtag: form.hashtag,
|
63
|
-
promoted: form.promoted,
|
64
|
-
description: form.description,
|
65
|
-
short_description: form.short_description,
|
66
|
-
scopes_enabled: form.scopes_enabled,
|
67
|
-
scope: form.scope,
|
68
|
-
scope_type_max_depth: form.scope_type_max_depth,
|
69
|
-
private_space: form.private_space,
|
70
|
-
developer_group: form.developer_group,
|
71
|
-
local_area: form.local_area,
|
72
|
-
area: form.area,
|
73
|
-
target: form.target,
|
74
|
-
participatory_scope: form.participatory_scope,
|
75
|
-
participatory_structure: form.participatory_structure,
|
76
|
-
meta_scope: form.meta_scope,
|
77
|
-
start_date: form.start_date,
|
78
|
-
end_date: form.end_date,
|
79
|
-
participatory_process_group: form.participatory_process_group,
|
80
|
-
participatory_process_type: form.participatory_process_type,
|
81
|
-
show_metrics: form.show_metrics,
|
82
|
-
show_statistics: form.show_statistics,
|
83
|
-
announcement: form.announcement
|
84
|
-
}.merge(
|
85
|
-
attachment_attributes(:hero_image, :banner_image)
|
86
|
-
)
|
87
|
-
end
|
88
|
-
|
89
19
|
def related_processes
|
90
20
|
@related_processes ||= Decidim::ParticipatoryProcess.where(id: form.related_process_ids)
|
91
21
|
end
|
92
22
|
|
93
|
-
def
|
94
|
-
|
23
|
+
def run_after_hooks
|
24
|
+
resource.link_participatory_space_resources(related_processes, "related_processes")
|
95
25
|
end
|
96
26
|
end
|
97
27
|
end
|
data/app/commands/decidim/participatory_processes/admin/update_participatory_process_group.rb
CHANGED
@@ -3,69 +3,20 @@
|
|
3
3
|
module Decidim
|
4
4
|
module ParticipatoryProcesses
|
5
5
|
module Admin
|
6
|
-
# A command with all the business logic when
|
6
|
+
# A command with all the business logic when updating a participatory
|
7
7
|
# process group in the system.
|
8
|
-
class UpdateParticipatoryProcessGroup < Decidim::
|
9
|
-
|
8
|
+
class UpdateParticipatoryProcessGroup < Decidim::Commands::UpdateResource
|
9
|
+
fetch_file_attributes :hero_image
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
# participatory_process_group - the ParticipatoryProcessGroup to update
|
14
|
-
# form - A form object with the params.
|
15
|
-
def initialize(participatory_process_group, form)
|
16
|
-
@participatory_process_group = participatory_process_group
|
17
|
-
@form = form
|
18
|
-
end
|
19
|
-
|
20
|
-
# Executes the command. Broadcasts these events:
|
21
|
-
#
|
22
|
-
# - :ok when everything is valid.
|
23
|
-
# - :invalid if the form was not valid and we could not proceed.
|
24
|
-
#
|
25
|
-
# Returns nothing.
|
26
|
-
def call
|
27
|
-
return broadcast(:invalid) if form.invalid?
|
28
|
-
|
29
|
-
update_participatory_process_group
|
30
|
-
|
31
|
-
if @participatory_process_group.valid?
|
32
|
-
broadcast(:ok, @participatory_process_group)
|
33
|
-
else
|
34
|
-
form.errors.add(:hero_image, @participatory_process_group.errors[:hero_image]) if @participatory_process_group.errors.include? :hero_image
|
35
|
-
broadcast(:invalid)
|
36
|
-
end
|
37
|
-
end
|
11
|
+
fetch_form_attributes :title, :description, :hashtag, :group_url, :developer_group, :local_area,
|
12
|
+
:meta_scope, :participatory_scope, :participatory_structure, :target, :promoted
|
38
13
|
|
39
14
|
private
|
40
15
|
|
41
16
|
attr_reader :form
|
42
17
|
|
43
|
-
def update_participatory_process_group
|
44
|
-
Decidim.traceability.perform_action!(
|
45
|
-
"update",
|
46
|
-
@participatory_process_group,
|
47
|
-
form.current_user
|
48
|
-
) do
|
49
|
-
@participatory_process_group.assign_attributes(attributes)
|
50
|
-
@participatory_process_group.save! if @participatory_process_group.valid?
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
18
|
def attributes
|
55
|
-
{
|
56
|
-
title: form.title,
|
57
|
-
description: form.description,
|
58
|
-
hashtag: form.hashtag,
|
59
|
-
group_url: form.group_url,
|
60
|
-
participatory_processes:,
|
61
|
-
developer_group: form.developer_group,
|
62
|
-
local_area: form.local_area,
|
63
|
-
meta_scope: form.meta_scope,
|
64
|
-
participatory_scope: form.participatory_scope,
|
65
|
-
participatory_structure: form.participatory_structure,
|
66
|
-
target: form.target,
|
67
|
-
promoted: form.promoted
|
68
|
-
}.merge(attachment_attributes(:hero_image))
|
19
|
+
super.merge({ participatory_processes: })
|
69
20
|
end
|
70
21
|
|
71
22
|
def participatory_processes
|
data/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
CHANGED
@@ -3,65 +3,21 @@
|
|
3
3
|
module Decidim
|
4
4
|
module ParticipatoryProcesses
|
5
5
|
module Admin
|
6
|
-
# A command with all the business logic when
|
7
|
-
# process in the system.
|
8
|
-
class UpdateParticipatoryProcessStep < Decidim::
|
9
|
-
|
10
|
-
|
11
|
-
# Public: Initializes the command.
|
12
|
-
#
|
13
|
-
# step - the ParticipatoryProcessStep to update
|
14
|
-
# form - A form object with the params.
|
15
|
-
def initialize(step, form)
|
16
|
-
@step = step
|
17
|
-
@form = form
|
18
|
-
end
|
19
|
-
|
20
|
-
# Executes the command. Broadcasts these events:
|
21
|
-
#
|
22
|
-
# - :ok when everything is valid.
|
23
|
-
# - :invalid if the form was not valid and we could not proceed.
|
24
|
-
#
|
25
|
-
# Returns nothing.
|
26
|
-
def call
|
27
|
-
return broadcast(:invalid) if form.invalid?
|
28
|
-
|
29
|
-
update_step
|
30
|
-
notify_followers
|
31
|
-
broadcast(:ok)
|
32
|
-
end
|
6
|
+
# A command with all the business logic when updating a participatory
|
7
|
+
# process step in the system.
|
8
|
+
class UpdateParticipatoryProcessStep < Decidim::Commands::UpdateResource
|
9
|
+
fetch_form_attributes :cta_path, :cta_text, :title, :start_date, :end_date, :description
|
33
10
|
|
34
11
|
private
|
35
12
|
|
36
|
-
|
37
|
-
|
38
|
-
def update_step
|
39
|
-
Decidim.traceability.update!(
|
40
|
-
step,
|
41
|
-
form.current_user,
|
42
|
-
attributes
|
43
|
-
)
|
44
|
-
end
|
45
|
-
|
46
|
-
def attributes
|
47
|
-
{
|
48
|
-
cta_path: form.cta_path,
|
49
|
-
cta_text: form.cta_text,
|
50
|
-
title: form.title,
|
51
|
-
start_date: form.start_date,
|
52
|
-
end_date: form.end_date,
|
53
|
-
description: form.description
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
def notify_followers
|
58
|
-
return unless step.saved_change_to_start_date || step.saved_change_to_end_date
|
13
|
+
def run_after_hooks
|
14
|
+
return unless resource.saved_change_to_start_date || resource.saved_change_to_end_date
|
59
15
|
|
60
16
|
Decidim::EventsManager.publish(
|
61
17
|
event: "decidim.events.participatory_process.step_changed",
|
62
18
|
event_class: Decidim::ParticipatoryProcessStepChangedEvent,
|
63
|
-
resource
|
64
|
-
followers:
|
19
|
+
resource:,
|
20
|
+
followers: resource.participatory_process.followers
|
65
21
|
)
|
66
22
|
end
|
67
23
|
end
|
data/app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb
CHANGED
@@ -5,44 +5,8 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when updating a participatory
|
7
7
|
# process type in the system.
|
8
|
-
class UpdateParticipatoryProcessType < Decidim::
|
9
|
-
|
10
|
-
#
|
11
|
-
# participatory_process_type - A participatory_process_type object to
|
12
|
-
# update
|
13
|
-
# form - A form object with the params.
|
14
|
-
def initialize(participatory_process_type, form)
|
15
|
-
@participatory_process_type = participatory_process_type
|
16
|
-
@form = form
|
17
|
-
end
|
18
|
-
|
19
|
-
# Executes the command. Broadcasts these events:
|
20
|
-
#
|
21
|
-
# - :ok when everything is valid.
|
22
|
-
# - :invalid if the form was not valid and we could not proceed.
|
23
|
-
#
|
24
|
-
# Returns nothing.
|
25
|
-
def call
|
26
|
-
return broadcast(:invalid) if form.invalid?
|
27
|
-
|
28
|
-
update_participatory_process_type!
|
29
|
-
|
30
|
-
broadcast(:ok)
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
attr_reader :form, :participatory_process_type
|
36
|
-
|
37
|
-
def update_participatory_process_type!
|
38
|
-
transaction do
|
39
|
-
Decidim.traceability.update!(
|
40
|
-
participatory_process_type,
|
41
|
-
form.current_user,
|
42
|
-
title: form.title
|
43
|
-
)
|
44
|
-
end
|
45
|
-
end
|
8
|
+
class UpdateParticipatoryProcessType < Decidim::Commands::UpdateResource
|
9
|
+
fetch_form_attributes :title
|
46
10
|
end
|
47
11
|
end
|
48
12
|
end
|
@@ -17,7 +17,7 @@ module Decidim
|
|
17
17
|
enforce_permission_to :create, :process
|
18
18
|
@form = form(ParticipatoryProcessCopyForm).from_params(params)
|
19
19
|
|
20
|
-
CopyParticipatoryProcess.call(@form, current_participatory_process
|
20
|
+
CopyParticipatoryProcess.call(@form, current_participatory_process) do
|
21
21
|
on(:ok) do
|
22
22
|
flash[:notice] = I18n.t("participatory_processes_copies.create.success", scope: "decidim.admin")
|
23
23
|
redirect_to participatory_processes_path
|
@@ -53,7 +53,7 @@ module Decidim
|
|
53
53
|
enforce_permission_to :update, :process_group, process_group: @participatory_process_group
|
54
54
|
@form = form(ParticipatoryProcessGroupForm).from_params(params)
|
55
55
|
|
56
|
-
UpdateParticipatoryProcessGroup.call(@
|
56
|
+
UpdateParticipatoryProcessGroup.call(@form, @participatory_process_group) do
|
57
57
|
on(:ok) do |participatory_process_group|
|
58
58
|
flash[:notice] = I18n.t("participatory_process_groups.update.success", scope: "decidim.admin")
|
59
59
|
redirect_to edit_participatory_process_group_path(participatory_process_group)
|
@@ -70,7 +70,7 @@ module Decidim
|
|
70
70
|
@participatory_process_group = collection.find(params[:id])
|
71
71
|
enforce_permission_to :destroy, :process_group, process_group: @participatory_process_group
|
72
72
|
|
73
|
-
|
73
|
+
Decidim::Commands::DestroyResource.call(@participatory_process_group, current_user) do
|
74
74
|
on(:ok) do
|
75
75
|
flash[:notice] = I18n.t("participatory_process_groups.destroy.success", scope: "decidim.admin")
|
76
76
|
redirect_to action: :index
|
data/app/controllers/decidim/participatory_processes/admin/participatory_process_steps_controller.rb
CHANGED
@@ -24,7 +24,7 @@ module Decidim
|
|
24
24
|
enforce_permission_to :create, :process_step
|
25
25
|
@form = form(ParticipatoryProcessStepForm).from_params(params)
|
26
26
|
|
27
|
-
CreateParticipatoryProcessStep.call(@form
|
27
|
+
CreateParticipatoryProcessStep.call(@form) do
|
28
28
|
on(:ok) do
|
29
29
|
flash[:notice] = I18n.t("participatory_process_steps.create.success", scope: "decidim.admin")
|
30
30
|
redirect_to participatory_process_steps_path(current_participatory_process)
|
@@ -46,7 +46,7 @@ module Decidim
|
|
46
46
|
enforce_permission_to :update, :process_step, process_step: @participatory_process_step
|
47
47
|
@form = form(ParticipatoryProcessStepForm).from_params(params)
|
48
48
|
|
49
|
-
UpdateParticipatoryProcessStep.call(@
|
49
|
+
UpdateParticipatoryProcessStep.call(@form, @participatory_process_step) do
|
50
50
|
on(:ok) do
|
51
51
|
flash[:notice] = I18n.t("participatory_process_steps.update.success", scope: "decidim.admin")
|
52
52
|
redirect_to participatory_process_steps_path(current_participatory_process)
|
data/app/controllers/decidim/participatory_processes/admin/participatory_process_types_controller.rb
CHANGED
@@ -57,7 +57,7 @@ module Decidim
|
|
57
57
|
@form = participatory_process_type_form
|
58
58
|
.from_params(params, participatory_process_type: current_participatory_process_type)
|
59
59
|
|
60
|
-
UpdateParticipatoryProcessType.call(
|
60
|
+
UpdateParticipatoryProcessType.call(@form, current_participatory_process_type) do
|
61
61
|
on(:ok) do
|
62
62
|
flash[:notice] = I18n.t("participatory_process_types.update.success", scope: "decidim.admin")
|
63
63
|
redirect_to participatory_process_types_path
|
@@ -74,7 +74,7 @@ module Decidim
|
|
74
74
|
def destroy
|
75
75
|
enforce_permission_to :destroy, :participatory_process_type, participatory_process_type: current_participatory_process_type
|
76
76
|
|
77
|
-
|
77
|
+
Decidim::Commands::DestroyResource.call(current_participatory_process_type, current_user) do
|
78
78
|
on(:ok) do
|
79
79
|
flash[:notice] = I18n.t("participatory_process_types.destroy.success", scope: "decidim.admin")
|
80
80
|
redirect_to participatory_process_types_path
|
data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb
CHANGED
@@ -60,7 +60,7 @@ module Decidim
|
|
60
60
|
process_id: current_participatory_process.id
|
61
61
|
)
|
62
62
|
|
63
|
-
UpdateParticipatoryProcess.call(
|
63
|
+
UpdateParticipatoryProcess.call(@form, current_participatory_process) do
|
64
64
|
on(:ok) do |participatory_process|
|
65
65
|
flash[:notice] = I18n.t("participatory_processes.update.success", scope: "decidim.admin")
|
66
66
|
redirect_to edit_participatory_process_path(participatory_process)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module ParticipatoryProcesses
|
5
5
|
module Admin
|
6
|
-
# Controller that allows managing participatory process
|
6
|
+
# Controller that allows managing participatory process private users
|
7
7
|
class ParticipatorySpacePrivateUsersController < Decidim::Admin::ApplicationController
|
8
8
|
include Concerns::ParticipatoryProcessAdmin
|
9
9
|
include Decidim::Admin::Concerns::HasPrivateUsers
|
@@ -2,11 +2,14 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module ParticipatoryProcesses
|
5
|
+
# The main application controller for participatory processes
|
6
|
+
#
|
5
7
|
# This controller is the abstract class from which all other controllers of
|
6
8
|
# this engine inherit.
|
7
9
|
class ApplicationController < Decidim::ApplicationController
|
8
10
|
helper Decidim::ParticipatoryProcesses::ApplicationHelper
|
9
11
|
helper ParticipatoryProcessHelper
|
12
|
+
|
10
13
|
include NeedsPermission
|
11
14
|
|
12
15
|
register_permissions(Decidim::ParticipatoryProcesses::ApplicationController,
|
@@ -6,7 +6,6 @@ module Decidim
|
|
6
6
|
# public layout.
|
7
7
|
class ParticipatoryProcessesController < Decidim::ParticipatoryProcesses::ApplicationController
|
8
8
|
include ParticipatorySpaceContext
|
9
|
-
participatory_space_layout only: [:show, :all_metrics]
|
10
9
|
include FilterResource
|
11
10
|
include Paginable
|
12
11
|
include HasParticipatorySpaceContentBlocks
|
@@ -33,11 +32,7 @@ module Decidim
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def all_metrics
|
36
|
-
|
37
|
-
enforce_permission_to :read, :process, process: current_participatory_space
|
38
|
-
else
|
39
|
-
render status: :not_found
|
40
|
-
end
|
35
|
+
enforce_permission_to :read, :process, process: current_participatory_space
|
41
36
|
end
|
42
37
|
|
43
38
|
private
|
@@ -2,13 +2,8 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
class ParticipatoryProcessRoleAssignedEvent < Decidim::Events::SimpleEvent
|
5
|
-
include Decidim::Events::NotificationEvent
|
6
5
|
include Decidim::Events::AuthorEvent
|
7
6
|
|
8
|
-
def notification_title
|
9
|
-
I18n.t("notification_title", **i18n_options).html_safe
|
10
|
-
end
|
11
|
-
|
12
7
|
def i18n_role
|
13
8
|
I18n.t(extra["role"], scope: "decidim.admin.models.participatory_process_user_role.roles", default: extra["role"])
|
14
9
|
end
|
@@ -37,16 +37,12 @@ module Decidim
|
|
37
37
|
attribute :private_space, Boolean
|
38
38
|
attribute :promoted, Boolean
|
39
39
|
attribute :scopes_enabled, Boolean
|
40
|
-
attribute :show_metrics, Boolean
|
41
|
-
attribute :show_statistics, Boolean
|
42
40
|
attribute :participatory_process_type_id, Integer
|
43
41
|
|
44
42
|
attribute :end_date, Decidim::Attributes::LocalizedDate
|
45
43
|
attribute :start_date, Decidim::Attributes::LocalizedDate
|
46
44
|
|
47
|
-
attribute :banner_image
|
48
45
|
attribute :hero_image
|
49
|
-
attribute :remove_banner_image, Boolean, default: false
|
50
46
|
attribute :remove_hero_image, Boolean, default: false
|
51
47
|
|
52
48
|
validates :area, presence: true, if: proc { |object| object.area_id.present? }
|
@@ -57,7 +53,6 @@ module Decidim
|
|
57
53
|
|
58
54
|
validates :title, :subtitle, :description, :short_description, translatable_presence: true
|
59
55
|
|
60
|
-
validates :banner_image, passthru: { to: Decidim::ParticipatoryProcess }
|
61
56
|
validates :hero_image, passthru: { to: Decidim::ParticipatoryProcess }
|
62
57
|
|
63
58
|
validates :weight, presence: true
|
@@ -71,9 +71,6 @@ module Decidim
|
|
71
71
|
has_one_attached :hero_image
|
72
72
|
validates_upload :hero_image, uploader: Decidim::HeroImageUploader
|
73
73
|
|
74
|
-
has_one_attached :banner_image
|
75
|
-
validates_upload :banner_image, uploader: Decidim::BannerImageUploader
|
76
|
-
|
77
74
|
scope :past, -> { where(arel_table[:end_date].lt(Date.current)) }
|
78
75
|
scope :upcoming, -> { where(arel_table[:start_date].gt(Date.current)) }
|
79
76
|
scope :active, -> { where(arel_table[:start_date].lteq(Date.current).and(arel_table[:end_date].gteq(Date.current).or(arel_table[:end_date].eq(nil)))) }
|
@@ -38,7 +38,7 @@ module Decidim
|
|
38
38
|
# set to the last step's position + 1.
|
39
39
|
#
|
40
40
|
# Note: This allows manual positioning, but there is a validation that
|
41
|
-
# forbids two steps from the same
|
41
|
+
# forbids two steps from the same process to have the same position. Take
|
42
42
|
# that into account. It would be best if you did not use manual
|
43
43
|
# positioning.
|
44
44
|
def set_position
|
@@ -217,7 +217,7 @@ module Decidim
|
|
217
217
|
allow! if permission_action.action == :export && permission_action.subject == :component_data
|
218
218
|
end
|
219
219
|
|
220
|
-
# Process admins can
|
220
|
+
# Process admins can perform everything *inside* that process. They cannot
|
221
221
|
# create a process or perform actions on process groups or other
|
222
222
|
# processes.
|
223
223
|
def process_admin_action?
|
@@ -7,10 +7,6 @@ module Decidim
|
|
7
7
|
process.attached_uploader(:hero_image).url(host: process.organization.host)
|
8
8
|
end
|
9
9
|
|
10
|
-
def banner_image_url
|
11
|
-
process.attached_uploader(:banner_image).url(host: process.organization.host)
|
12
|
-
end
|
13
|
-
|
14
10
|
def area_name
|
15
11
|
return if process.area.blank?
|
16
12
|
|
@@ -22,9 +22,9 @@ module Decidim
|
|
22
22
|
debates_query,
|
23
23
|
meetings_query,
|
24
24
|
endorsements_query,
|
25
|
-
|
25
|
+
project_votes_query,
|
26
26
|
proposals_query,
|
27
|
-
|
27
|
+
proposal_votes_query,
|
28
28
|
survey_answer_query
|
29
29
|
].flatten.uniq.count
|
30
30
|
end
|
@@ -93,7 +93,7 @@ module Decidim
|
|
93
93
|
.uniq
|
94
94
|
end
|
95
95
|
|
96
|
-
def
|
96
|
+
def proposal_votes_query
|
97
97
|
return [] unless Decidim.module_installed?(:proposals)
|
98
98
|
|
99
99
|
Decidim::Proposals::ProposalVote
|
@@ -105,7 +105,7 @@ module Decidim
|
|
105
105
|
.uniq
|
106
106
|
end
|
107
107
|
|
108
|
-
def
|
108
|
+
def project_votes_query
|
109
109
|
return [] unless Decidim.module_installed?(:budgets)
|
110
110
|
|
111
111
|
Decidim::Budgets::Order.joins(budget: [:component])
|
@@ -14,8 +14,8 @@ module Decidim
|
|
14
14
|
# attributes - The Hash of attributes to create the ParticipatoryProcess with.
|
15
15
|
# user - The user that performs the action.
|
16
16
|
# opts - The options MUST contain:
|
17
|
-
# - title: The +title+ for the new
|
18
|
-
# - slug: The +slug+ for the new
|
17
|
+
# - title: The +title+ for the new ParticipatoryProcess
|
18
|
+
# - slug: The +slug+ for the new ParticipatoryProcess
|
19
19
|
#
|
20
20
|
# Returns a ParticipatoryProcess.
|
21
21
|
def import(attributes, _user, opts)
|
@@ -42,13 +42,10 @@ module Decidim
|
|
42
42
|
announcement: attributes["announcement"],
|
43
43
|
private_space: attributes["private_space"],
|
44
44
|
scopes_enabled: attributes["scopes_enabled"],
|
45
|
-
show_metrics: attributes["show_metrics"],
|
46
|
-
show_statistics: attributes["show_statistics"],
|
47
45
|
participatory_process_group: import_process_group(attributes["participatory_process_group"]),
|
48
46
|
participatory_process_type: import_participatory_process_type(attributes["participatory_process_type"])
|
49
47
|
)
|
50
48
|
@imported_process.attached_uploader(:hero_image).remote_url = attributes["remote_hero_image_url"] if attributes["remote_hero_image_url"].present?
|
51
|
-
@imported_process.attached_uploader(:banner_image).remote_url = attributes["remote_banner_image_url"] if attributes["remote_banner_image_url"].present?
|
52
49
|
|
53
50
|
@imported_process.save!
|
54
51
|
@imported_process
|
@@ -28,7 +28,6 @@ module Decidim
|
|
28
28
|
start_date: participatory_process.start_date,
|
29
29
|
end_date: participatory_process.end_date,
|
30
30
|
remote_hero_image_url: Decidim::ParticipatoryProcesses::ParticipatoryProcessPresenter.new(participatory_process).hero_image_url,
|
31
|
-
remote_banner_image_url: Decidim::ParticipatoryProcesses::ParticipatoryProcessPresenter.new(participatory_process).banner_image_url,
|
32
31
|
developer_group: participatory_process.developer_group,
|
33
32
|
local_area: participatory_process.local_area,
|
34
33
|
meta_scope: participatory_process.meta_scope,
|
@@ -52,8 +51,6 @@ module Decidim
|
|
52
51
|
private_space: participatory_process.private_space,
|
53
52
|
promoted: participatory_process.promoted,
|
54
53
|
scopes_enabled: participatory_process.scopes_enabled,
|
55
|
-
show_metrics: participatory_process.show_metrics,
|
56
|
-
show_statistics: participatory_process.show_statistics,
|
57
54
|
participatory_process_type: {
|
58
55
|
id: participatory_process.participatory_process_type.try(:id),
|
59
56
|
title: participatory_process.participatory_process_type.try(:title) || empty_translatable
|
data/app/views/decidim/participatory_processes/admin/participatory_process_steps/index.html.erb
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
<th><%= t("models.participatory_process_step.fields.title", scope: "decidim.admin") %></th>
|
17
17
|
<th><%= t("models.participatory_process_step.fields.start_date", scope: "decidim.admin") %></th>
|
18
18
|
<th><%= t("models.participatory_process_step.fields.end_date", scope: "decidim.admin") %></th>
|
19
|
-
<th
|
19
|
+
<th></th>
|
20
20
|
</tr>
|
21
21
|
</thead>
|
22
22
|
<tbody class="sortable" data-sort-url="<%= ordering_participatory_process_steps_path(current_participatory_process) %>">
|
data/app/views/decidim/participatory_processes/admin/participatory_process_steps/show.html.erb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<h3><%= translated_attribute(@participatory_process_step.title) %></h3>
|
2
2
|
|
3
|
-
<div
|
3
|
+
<div>
|
4
4
|
<hr>
|
5
5
|
<%= link_to t("decidim.admin.actions.edit"), edit_participatory_process_step_path(participatory_process, @participatory_process_step) if allowed_to? :update, :process_step, process_step: @participatory_process_step %>
|
6
6
|
<%= link_to t("decidim.admin.actions.destroy"), participatory_process_step_path(participatory_process, @participatory_process_step), method: :delete, class: "alert button", data: { confirm: t("decidim.admin.actions.confirm_destroy") } if allowed_to? :destroy, :process_step, process_step: @participatory_process_step %>
|
data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/index.html.erb
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
<th><%= sort_link(query, :last_sign_in_at, t("models.user.fields.last_sign_in_at", scope: "decidim.admin"), default_order: :desc) %></th>
|
20
20
|
<th><%= sort_link(query, :invitation_accepted_at, t("models.user.fields.invitation_accepted_at", scope: "decidim.admin"), default_order: :desc) %></th>
|
21
21
|
<th><%= sort_link(query, :role, t("models.participatory_process_user_role.fields.role", scope: "decidim.admin"), default_order: :desc) %></th>
|
22
|
-
<th
|
22
|
+
<th></th>
|
23
23
|
</tr>
|
24
24
|
</thead>
|
25
25
|
<tbody>
|