decidim-participatory_processes 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/commands/decidim/participatory_processes/admin/activate_participatory_process_step.rb +34 -4
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +25 -0
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb +36 -5
- data/app/commands/decidim/participatory_processes/admin/create_participatory_process_step.rb +3 -1
- data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_admin.rb +53 -0
- data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_step.rb +16 -5
- data/app/commands/decidim/participatory_processes/admin/publish_participatory_process.rb +9 -3
- data/app/commands/decidim/participatory_processes/admin/unpublish_participatory_process.rb +9 -3
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +7 -1
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process_admin.rb +12 -1
- data/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb +23 -7
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_attachment_collections_controller.rb +27 -0
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_publications_controller.rb +2 -2
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_step_activations_controller.rb +1 -1
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_steps_controller.rb +1 -1
- data/app/controllers/decidim/participatory_processes/admin/participatory_process_user_roles_controller.rb +6 -4
- data/app/controllers/decidim/participatory_processes/application_controller.rb +11 -0
- data/app/controllers/decidim/participatory_processes/participatory_process_groups_controller.rb +1 -1
- data/app/controllers/decidim/participatory_processes/participatory_process_steps_controller.rb +1 -1
- data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +4 -3
- data/app/helpers/decidim/participatory_processes/application_helper.rb +23 -0
- data/app/models/decidim/participatory_process.rb +8 -0
- data/app/models/decidim/participatory_process_step.rb +9 -0
- data/app/presenters/decidim/participatory_processes/admin_log/participatory_process_presenter.rb +56 -0
- data/app/presenters/decidim/participatory_processes/admin_log/participatory_process_user_role_presenter.rb +53 -0
- data/app/presenters/decidim/participatory_processes/admin_log/step_presenter.rb +40 -0
- data/app/presenters/decidim/participatory_processes/admin_log/value_types/role_presenter.rb +22 -0
- data/app/types/decidim/participatory_processes/participatory_process_step_type.rb +25 -0
- data/app/types/decidim/participatory_processes/participatory_process_type.rb +15 -0
- data/app/views/decidim/participatory_processes/participatory_process_groups/show.html.erb +1 -0
- data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +2 -0
- data/app/views/layouts/decidim/admin/participatory_process.html.erb +15 -3
- data/config/locales/ca.yml +31 -0
- data/config/locales/en.yml +31 -0
- data/config/locales/es.yml +32 -1
- data/config/locales/eu.yml +31 -0
- data/config/locales/fi.yml +31 -0
- data/config/locales/fr.yml +47 -16
- data/config/locales/gl.yml +31 -0
- data/config/locales/it.yml +31 -0
- data/config/locales/nl.yml +31 -0
- data/config/locales/pl.yml +31 -5
- data/config/locales/pt-BR.yml +31 -0
- data/config/locales/pt.yml +31 -0
- data/config/locales/sv.yml +31 -0
- data/config/locales/uk.yml +9 -5
- data/db/migrate/20170220110740_remove_steps_short_description.rb +1 -1
- data/db/migrate/20171215081244_add_weight_to_attachments.rb +7 -0
- data/db/migrate/20171215141722_add_attachment_collection_to_attachments.rb +9 -0
- data/db/migrate/20180125102537_add_reference_to_processes.rb +7 -0
- data/lib/decidim/participatory_processes.rb +4 -0
- data/lib/decidim/participatory_processes/admin_engine.rb +1 -0
- data/lib/decidim/participatory_processes/participatory_space.rb +16 -0
- data/lib/decidim/participatory_processes/test/factories.rb +6 -0
- data/lib/decidim/participatory_processes/version.rb +1 -1
- metadata +22 -10
- data/app/commands/decidim/participatory_processes/admin/deactivate_participatory_process_step.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99cde756d7e4a5e205ebecf7eed66faf280be18f26f2cd66ae18980e4c0d895b
|
4
|
+
data.tar.gz: f005852ef82d47bd80fac02f71b077a2f8bef1ca682c52f7759da92cd928e066
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82a390448205bf7e1484c99990fb1984138468cc4e74e7f9637bf9ede151574629b4b68af461992b580f316c498b50e2feb2f73a6ce15a091a4f442ee74b08e7
|
7
|
+
data.tar.gz: 207c880ae75785e9128dc9afdf13fc396f39dfc10840643c84df4c1a2b4f743d7747c5d599ca1499471e380ef8f6908ce89ff1888efebf0c008f13bcb395147f
|
data/app/commands/decidim/participatory_processes/admin/activate_participatory_process_step.rb
CHANGED
@@ -9,8 +9,10 @@ module Decidim
|
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# step - A ParticipatoryProcessStep that will be activated
|
12
|
-
|
12
|
+
# current_user - the user performing the action
|
13
|
+
def initialize(step, current_user)
|
13
14
|
@step = step
|
15
|
+
@current_user = current_user
|
14
16
|
end
|
15
17
|
|
16
18
|
# Executes the command. Broadcasts these events:
|
@@ -26,6 +28,7 @@ module Decidim
|
|
26
28
|
deactivate_active_steps
|
27
29
|
activate_step
|
28
30
|
notify_followers
|
31
|
+
publish_step_settings_change
|
29
32
|
end
|
30
33
|
|
31
34
|
broadcast(:ok)
|
@@ -33,16 +36,23 @@ module Decidim
|
|
33
36
|
|
34
37
|
private
|
35
38
|
|
36
|
-
attr_reader :step
|
39
|
+
attr_reader :step, :current_user
|
37
40
|
|
38
41
|
def deactivate_active_steps
|
39
42
|
step.participatory_process.steps.where(active: true).each do |step|
|
40
|
-
step.
|
43
|
+
@previous_step = step if step.active?
|
44
|
+
step.update!(active: false)
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
44
48
|
def activate_step
|
45
|
-
|
49
|
+
Decidim.traceability.perform_action!(
|
50
|
+
:activate,
|
51
|
+
step,
|
52
|
+
current_user
|
53
|
+
) do
|
54
|
+
step.update!(active: true)
|
55
|
+
end
|
46
56
|
end
|
47
57
|
|
48
58
|
def notify_followers
|
@@ -53,6 +63,26 @@ module Decidim
|
|
53
63
|
recipient_ids: step.participatory_process.followers.pluck(:id)
|
54
64
|
)
|
55
65
|
end
|
66
|
+
|
67
|
+
def publish_step_settings_change
|
68
|
+
step.participatory_process.features.each do |feature|
|
69
|
+
Decidim::SettingsChange.publish(
|
70
|
+
feature,
|
71
|
+
previous_step_settings(feature).to_h,
|
72
|
+
current_step_settings(feature).to_h
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def current_step_settings(feature)
|
78
|
+
feature.step_settings.fetch(step.id.to_s)
|
79
|
+
end
|
80
|
+
|
81
|
+
def previous_step_settings(feature)
|
82
|
+
return {} unless @previous_step
|
83
|
+
|
84
|
+
feature.step_settings.fetch(@previous_step.id.to_s)
|
85
|
+
end
|
56
86
|
end
|
57
87
|
end
|
58
88
|
end
|
@@ -24,6 +24,7 @@ module Decidim
|
|
24
24
|
process = create_participatory_process
|
25
25
|
|
26
26
|
if process.persisted?
|
27
|
+
add_admins_as_followers(process)
|
27
28
|
broadcast(:ok, process)
|
28
29
|
else
|
29
30
|
form.errors.add(:hero_image, process.errors[:hero_image]) if process.errors.include? :hero_image
|
@@ -65,6 +66,8 @@ module Decidim
|
|
65
66
|
transaction do
|
66
67
|
process.save!
|
67
68
|
|
69
|
+
log_process_creation(process)
|
70
|
+
|
68
71
|
process.steps.create!(
|
69
72
|
title: TranslationsHelper.multi_translation(
|
70
73
|
"decidim.admin.participatory_process_steps.default_title",
|
@@ -76,6 +79,28 @@ module Decidim
|
|
76
79
|
process
|
77
80
|
end
|
78
81
|
end
|
82
|
+
|
83
|
+
def log_process_creation(process)
|
84
|
+
Decidim::ActionLogger.log(
|
85
|
+
"create",
|
86
|
+
form.current_user,
|
87
|
+
process,
|
88
|
+
process.versions.last.id
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
def add_admins_as_followers(process)
|
93
|
+
process.organization.admins.each do |admin|
|
94
|
+
form = Decidim::FollowForm
|
95
|
+
.from_params(followable_gid: process.to_signed_global_id.to_s)
|
96
|
+
.with_context(
|
97
|
+
current_organization: process.organization,
|
98
|
+
current_user: admin
|
99
|
+
)
|
100
|
+
|
101
|
+
Decidim::CreateFollow.new(form, admin).call
|
102
|
+
end
|
103
|
+
end
|
79
104
|
end
|
80
105
|
end
|
81
106
|
end
|
data/app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb
CHANGED
@@ -9,6 +9,7 @@ module Decidim
|
|
9
9
|
# Public: Initializes the command.
|
10
10
|
#
|
11
11
|
# form - A form object with the params.
|
12
|
+
# current_user - the user performing this action
|
12
13
|
# participatory_process - The ParticipatoryProcess that will hold the
|
13
14
|
# user role
|
14
15
|
def initialize(form, current_user, participatory_process)
|
@@ -27,8 +28,9 @@ module Decidim
|
|
27
28
|
return broadcast(:invalid) if form.invalid?
|
28
29
|
|
29
30
|
ActiveRecord::Base.transaction do
|
30
|
-
|
31
|
-
create_role
|
31
|
+
@user = existing_user || new_user
|
32
|
+
existing_role || create_role
|
33
|
+
add_admin_as_follower
|
32
34
|
end
|
33
35
|
|
34
36
|
broadcast(:ok)
|
@@ -42,15 +44,31 @@ module Decidim
|
|
42
44
|
attr_reader :form, :participatory_process, :current_user, :user
|
43
45
|
|
44
46
|
def create_role
|
45
|
-
|
47
|
+
extra_info = {
|
48
|
+
resource: {
|
49
|
+
title: user.name
|
50
|
+
}
|
51
|
+
}
|
52
|
+
role_params = {
|
46
53
|
role: form.role.to_sym,
|
47
54
|
user: user,
|
48
55
|
participatory_process: @participatory_process
|
56
|
+
}
|
57
|
+
|
58
|
+
Decidim.traceability.create!(
|
59
|
+
Decidim::ParticipatoryProcessUserRole,
|
60
|
+
current_user,
|
61
|
+
role_params,
|
62
|
+
extra_info
|
49
63
|
)
|
50
64
|
end
|
51
65
|
|
52
|
-
def
|
53
|
-
|
66
|
+
def existing_role
|
67
|
+
Decidim::ParticipatoryProcessUserRole.where(
|
68
|
+
role: form.role.to_sym,
|
69
|
+
user: user,
|
70
|
+
participatory_process: @participatory_process
|
71
|
+
).first
|
54
72
|
end
|
55
73
|
|
56
74
|
def existing_user
|
@@ -87,6 +105,19 @@ module Decidim
|
|
87
105
|
return "invite_admin" if form.role == "admin"
|
88
106
|
"invite_collaborator"
|
89
107
|
end
|
108
|
+
|
109
|
+
def add_admin_as_follower
|
110
|
+
return if user.follows?(participatory_process)
|
111
|
+
|
112
|
+
form = Decidim::FollowForm
|
113
|
+
.from_params(followable_gid: participatory_process.to_signed_global_id.to_s)
|
114
|
+
.with_context(
|
115
|
+
current_organization: participatory_process.organization,
|
116
|
+
current_user: user
|
117
|
+
)
|
118
|
+
|
119
|
+
Decidim::CreateFollow.new(form, user).call
|
120
|
+
end
|
90
121
|
end
|
91
122
|
end
|
92
123
|
end
|
data/app/commands/decidim/participatory_processes/admin/create_participatory_process_step.rb
CHANGED
@@ -34,7 +34,9 @@ module Decidim
|
|
34
34
|
attr_reader :form
|
35
35
|
|
36
36
|
def create_participatory_process_step
|
37
|
-
|
37
|
+
Decidim.traceability.create!(
|
38
|
+
ParticipatoryProcessStep,
|
39
|
+
@form.current_user,
|
38
40
|
title: form.title,
|
39
41
|
description: form.description,
|
40
42
|
start_date: form.start_date,
|
data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_admin.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module ParticipatoryProcesses
|
5
|
+
module Admin
|
6
|
+
# A command with all the business logic when destroying a participatory
|
7
|
+
# process admin in the system.
|
8
|
+
class DestroyParticipatoryProcessAdmin < Rectify::Command
|
9
|
+
# Public: Initializes the command.
|
10
|
+
#
|
11
|
+
# role - the ParticipatoryProcessUserRole to destroy
|
12
|
+
# current_user - the user performing this action
|
13
|
+
def initialize(role, current_user)
|
14
|
+
@role = role
|
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 form wasn't valid and we couldn't proceed.
|
22
|
+
#
|
23
|
+
# Returns nothing.
|
24
|
+
def call
|
25
|
+
destroy_role!
|
26
|
+
broadcast(:ok)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :role, :current_user
|
32
|
+
|
33
|
+
def destroy_role!
|
34
|
+
extra_info = {
|
35
|
+
resource: {
|
36
|
+
title: role.user.name
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
Decidim.traceability.perform_action!(
|
41
|
+
"delete",
|
42
|
+
role,
|
43
|
+
current_user,
|
44
|
+
extra_info
|
45
|
+
) do
|
46
|
+
role.destroy!
|
47
|
+
role
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_step.rb
CHANGED
@@ -8,9 +8,11 @@ module Decidim
|
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# step - A ParticipatoryProcessStep that will be deactivated
|
11
|
-
|
11
|
+
# current_user - the user performing the action
|
12
|
+
def initialize(step, current_user)
|
12
13
|
@step = step
|
13
14
|
@participatory_process = step.participatory_process
|
15
|
+
@current_user = current_user
|
14
16
|
end
|
15
17
|
|
16
18
|
# Executes the command. Broadcasts these events:
|
@@ -22,19 +24,28 @@ module Decidim
|
|
22
24
|
def call
|
23
25
|
return broadcast(:invalid, :active_step) if active_step?
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
+
transaction do
|
28
|
+
Decidim.traceability.perform_action!(:delete, step, current_user) do
|
29
|
+
step.destroy!
|
30
|
+
step
|
31
|
+
end
|
32
|
+
|
33
|
+
reorder_steps
|
34
|
+
end
|
35
|
+
|
27
36
|
broadcast(:ok)
|
28
37
|
end
|
29
38
|
|
30
39
|
private
|
31
40
|
|
41
|
+
attr_reader :step, :participatory_process, :current_user
|
42
|
+
|
32
43
|
def active_step?
|
33
|
-
|
44
|
+
participatory_process.steps.count > 1 && step.active?
|
34
45
|
end
|
35
46
|
|
36
47
|
def reorder_steps
|
37
|
-
steps =
|
48
|
+
steps = participatory_process.steps.reload
|
38
49
|
|
39
50
|
ReorderParticipatoryProcessSteps
|
40
51
|
.new(steps, steps.map(&:id))
|
@@ -8,8 +8,10 @@ module Decidim
|
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# process - A ParticipatoryProcess that will be published
|
11
|
-
|
11
|
+
# current_user - the user performing this action
|
12
|
+
def initialize(process, current_user)
|
12
13
|
@process = process
|
14
|
+
@current_user = current_user
|
13
15
|
end
|
14
16
|
|
15
17
|
# Executes the command. Broadcasts these events:
|
@@ -21,13 +23,17 @@ module Decidim
|
|
21
23
|
def call
|
22
24
|
return broadcast(:invalid) if process.nil? || process.published?
|
23
25
|
|
24
|
-
|
26
|
+
transaction do
|
27
|
+
Decidim.traceability.perform_action!("publish", process, current_user) do
|
28
|
+
process.publish!
|
29
|
+
end
|
30
|
+
end
|
25
31
|
broadcast(:ok)
|
26
32
|
end
|
27
33
|
|
28
34
|
private
|
29
35
|
|
30
|
-
attr_reader :process
|
36
|
+
attr_reader :process, :current_user
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
@@ -8,8 +8,10 @@ module Decidim
|
|
8
8
|
# Public: Initializes the command.
|
9
9
|
#
|
10
10
|
# process - A ParticipatoryProcess that will be unpublished
|
11
|
-
|
11
|
+
# current_user - the user performing this action
|
12
|
+
def initialize(process, current_user)
|
12
13
|
@process = process
|
14
|
+
@current_user = current_user
|
13
15
|
end
|
14
16
|
|
15
17
|
# Executes the command. Broadcasts these events:
|
@@ -21,13 +23,17 @@ module Decidim
|
|
21
23
|
def call
|
22
24
|
return broadcast(:invalid) if process.nil? || !process.published?
|
23
25
|
|
24
|
-
|
26
|
+
transaction do
|
27
|
+
Decidim.traceability.perform_action!("unpublish", process, current_user) do
|
28
|
+
process.unpublish!
|
29
|
+
end
|
30
|
+
end
|
25
31
|
broadcast(:ok)
|
26
32
|
end
|
27
33
|
|
28
34
|
private
|
29
35
|
|
30
|
-
attr_reader :process
|
36
|
+
attr_reader :process, :current_user
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
@@ -40,7 +40,13 @@ module Decidim
|
|
40
40
|
|
41
41
|
def update_participatory_process
|
42
42
|
@participatory_process.assign_attributes(attributes)
|
43
|
-
|
43
|
+
if @participatory_process.valid?
|
44
|
+
@participatory_process.save!
|
45
|
+
|
46
|
+
Decidim.traceability.perform_action!(:update, @participatory_process, form.current_user) do
|
47
|
+
@participatory_process
|
48
|
+
end
|
49
|
+
end
|
44
50
|
end
|
45
51
|
|
46
52
|
def attributes
|
data/app/commands/decidim/participatory_processes/admin/update_participatory_process_admin.rb
CHANGED
@@ -35,7 +35,18 @@ module Decidim
|
|
35
35
|
attr_reader :form, :user_role
|
36
36
|
|
37
37
|
def update_role!
|
38
|
-
|
38
|
+
extra_info = {
|
39
|
+
resource: {
|
40
|
+
title: user_role.user.name
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
Decidim.traceability.update!(
|
45
|
+
user_role,
|
46
|
+
form.current_user,
|
47
|
+
{ role: form.role },
|
48
|
+
extra_info
|
49
|
+
)
|
39
50
|
end
|
40
51
|
end
|
41
52
|
end
|
data/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb
CHANGED
@@ -6,13 +6,13 @@ module Decidim
|
|
6
6
|
# A command with all the business logic when creating a new participatory
|
7
7
|
# process in the system.
|
8
8
|
class UpdateParticipatoryProcessStep < Rectify::Command
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :step
|
10
10
|
# Public: Initializes the command.
|
11
11
|
#
|
12
|
-
#
|
12
|
+
# step - the ParticipatoryProcessStep to update
|
13
13
|
# form - A form object with the params.
|
14
|
-
def initialize(
|
15
|
-
@
|
14
|
+
def initialize(step, form)
|
15
|
+
@step = step
|
16
16
|
@form = form
|
17
17
|
end
|
18
18
|
|
@@ -25,7 +25,8 @@ module Decidim
|
|
25
25
|
def call
|
26
26
|
return broadcast(:invalid) if form.invalid?
|
27
27
|
|
28
|
-
|
28
|
+
update_step
|
29
|
+
notify_followers
|
29
30
|
broadcast(:ok)
|
30
31
|
end
|
31
32
|
|
@@ -33,8 +34,12 @@ module Decidim
|
|
33
34
|
|
34
35
|
attr_reader :form
|
35
36
|
|
36
|
-
def
|
37
|
-
|
37
|
+
def update_step
|
38
|
+
Decidim.traceability.update!(
|
39
|
+
step,
|
40
|
+
form.current_user,
|
41
|
+
attributes
|
42
|
+
)
|
38
43
|
end
|
39
44
|
|
40
45
|
def attributes
|
@@ -45,6 +50,17 @@ module Decidim
|
|
45
50
|
description: form.description
|
46
51
|
}
|
47
52
|
end
|
53
|
+
|
54
|
+
def notify_followers
|
55
|
+
return unless step.saved_change_to_start_date || step.saved_change_to_end_date
|
56
|
+
|
57
|
+
Decidim::EventsManager.publish(
|
58
|
+
event: "decidim.events.participatory_process.step_changed",
|
59
|
+
event_class: Decidim::ParticipatoryProcessStepChangedEvent,
|
60
|
+
resource: step,
|
61
|
+
recipient_ids: step.participatory_process.followers.pluck(:id)
|
62
|
+
)
|
63
|
+
end
|
48
64
|
end
|
49
65
|
end
|
50
66
|
end
|