decidim-assemblies 0.28.5 → 0.29.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/cells/decidim/assemblies/assembly_g_cell.rb +2 -2
- data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb +0 -4
- data/app/cells/decidim/assemblies/content_blocks/stats_cell.rb +1 -1
- data/app/commands/decidim/assemblies/admin/create_assemblies_type.rb +3 -31
- data/app/commands/decidim/assemblies/admin/create_assembly.rb +30 -89
- data/app/commands/decidim/assemblies/admin/create_assembly_member.rb +14 -66
- data/app/commands/decidim/assemblies/admin/destroy_assembly_member.rb +5 -37
- data/app/commands/decidim/assemblies/admin/import_assembly.rb +1 -1
- data/app/commands/decidim/assemblies/admin/update_assemblies_type.rb +2 -35
- data/app/commands/decidim/assemblies/admin/update_assembly.rb +22 -99
- data/app/commands/decidim/assemblies/admin/update_assembly_member.rb +8 -69
- data/app/controllers/decidim/assemblies/admin/assemblies_controller.rb +5 -20
- data/app/controllers/decidim/assemblies/admin/assemblies_types_controller.rb +4 -4
- data/app/controllers/decidim/assemblies/admin/assembly_landing_page_content_blocks_controller.rb +0 -6
- data/app/controllers/decidim/assemblies/admin/assembly_members_controller.rb +1 -1
- data/app/controllers/decidim/assemblies/admin/participatory_space_private_users_controller.rb +1 -1
- data/app/controllers/decidim/assemblies/admin/participatory_space_private_users_csv_imports_controller.rb +1 -1
- data/app/controllers/decidim/assemblies/application_controller.rb +4 -1
- data/app/controllers/decidim/assemblies/assemblies_controller.rb +0 -3
- data/app/controllers/decidim/assemblies/assembly_members_controller.rb +0 -2
- data/app/forms/decidim/assemblies/admin/assembly_form.rb +8 -9
- data/app/helpers/decidim/assemblies/assemblies_helper.rb +0 -26
- data/app/models/decidim/assembly.rb +1 -6
- data/app/permissions/decidim/assemblies/permissions.rb +2 -2
- data/app/presenters/decidim/assemblies/admin_log/assembly_presenter.rb +0 -1
- data/app/presenters/decidim/assemblies/assembly_presenter.rb +2 -2
- data/app/serializers/decidim/assemblies/assembly_importer.rb +0 -1
- data/app/serializers/decidim/assemblies/assembly_serializer.rb +1 -2
- data/app/views/decidim/assemblies/admin/assemblies/_form.html.erb +5 -9
- data/app/views/decidim/assemblies/admin/assemblies/index.html.erb +2 -2
- data/app/views/decidim/assemblies/admin/assembly_members/index.html.erb +1 -1
- data/app/views/decidim/assemblies/admin/assembly_user_roles/index.html.erb +1 -1
- data/app/views/decidim/assemblies/assemblies/show.html.erb +22 -18
- data/app/views/decidim/assemblies/assembly_members/index.html.erb +2 -1
- data/app/views/layouts/decidim/admin/assemblies.html.erb +1 -1
- data/config/locales/ar.yml +7 -14
- data/config/locales/bg.yml +2 -7
- data/config/locales/ca.yml +9 -14
- data/config/locales/cs.yml +3 -8
- data/config/locales/de.yml +20 -25
- data/config/locales/el.yml +0 -6
- data/config/locales/en.yml +2 -7
- data/config/locales/es-MX.yml +6 -11
- data/config/locales/es-PY.yml +5 -10
- data/config/locales/es.yml +8 -13
- data/config/locales/eu.yml +48 -53
- data/config/locales/fi-plain.yml +6 -11
- data/config/locales/fi.yml +10 -15
- data/config/locales/fr-CA.yml +7 -12
- data/config/locales/fr.yml +7 -12
- data/config/locales/ga-IE.yml +0 -5
- data/config/locales/gl.yml +2 -10
- data/config/locales/he-IL.yml +0 -171
- data/config/locales/hu.yml +2 -8
- data/config/locales/id-ID.yml +0 -10
- data/config/locales/is-IS.yml +5 -9
- data/config/locales/it.yml +3 -11
- data/config/locales/ja.yml +3 -8
- data/config/locales/ko.yml +8 -1
- data/config/locales/lb.yml +5 -14
- data/config/locales/lt.yml +2 -8
- data/config/locales/lv.yml +0 -10
- data/config/locales/nl.yml +3 -11
- data/config/locales/no.yml +0 -8
- data/config/locales/pl.yml +3 -14
- data/config/locales/pt-BR.yml +0 -6
- data/config/locales/pt.yml +1 -9
- data/config/locales/ro-RO.yml +2 -12
- data/config/locales/ru.yml +6 -11
- data/config/locales/sk.yml +0 -20
- data/config/locales/sl.yml +0 -17
- data/config/locales/sq-AL.yml +5 -6
- data/config/locales/sv.yml +137 -203
- data/config/locales/tr-TR.yml +4 -9
- data/config/locales/uk.yml +5 -10
- data/config/locales/zh-CN.yml +0 -10
- data/config/locales/zh-TW.yml +1 -7
- data/db/migrate/20240712061153_change_show_statistics_from_decidim_assemblies.rb +11 -0
- data/decidim-assemblies.gemspec +2 -2
- data/lib/decidim/api/assembly_type.rb +5 -6
- data/lib/decidim/assemblies/content_blocks/registry_manager.rb +1 -1
- data/lib/decidim/assemblies/engine.rb +1 -0
- data/lib/decidim/assemblies/menu.rb +11 -0
- data/lib/decidim/assemblies/seeds.rb +1 -11
- data/lib/decidim/assemblies/test/factories.rb +0 -1
- data/lib/decidim/assemblies/version.rb +1 -1
- metadata +18 -21
- data/app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb +0 -45
- data/app/views/layouts/decidim/assembly.html.erb +0 -18
- data/config/locales/bn-BD.yml +0 -1
- data/config/locales/bs-BA.yml +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb2e321d4d397b59daabff4553cdc2caa3ed6fbf2eb8f9d33b3e3fbc1fef8ffc
|
4
|
+
data.tar.gz: f0e387fe8972d70c6e1d046b4726caba7d7529d1aa9306ca6484807d3d1fc1e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6065ed4aca734ca6c4bf6c019229d442d270bdc732f7e8607204a1f800c1d80ee95efa9f39950b9731c3d6269306ab027ee72b68a8a79d6e0930d859e39a726b
|
7
|
+
data.tar.gz: 0e9b83e6c7a03b6a47e02c2072762b3ba62817607ab823269e351d4fe2210e9ebff6e64c59a2e583645b5893cb3a157d3c2a957966187205aee046f03ae9fea7
|
@@ -11,8 +11,8 @@ module Decidim
|
|
11
11
|
Decidim::Assemblies::Engine.routes.url_helpers.assembly_path(model)
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
model.attached_uploader(:hero_image).
|
14
|
+
def resource_image_path
|
15
|
+
model.attached_uploader(:hero_image).path
|
16
16
|
end
|
17
17
|
|
18
18
|
def metadata_cell
|
@@ -4,14 +4,10 @@ module Decidim
|
|
4
4
|
module Assemblies
|
5
5
|
module ContentBlocks
|
6
6
|
class HighlightedAssembliesCell < Decidim::ContentBlocks::HighlightedParticipatorySpacesCell
|
7
|
-
delegate :current_user, to: :controller
|
8
|
-
|
9
7
|
def highlighted_spaces
|
10
8
|
@highlighted_spaces ||= OrganizationPrioritizedAssemblies
|
11
9
|
.new(current_organization, current_user)
|
12
10
|
.query
|
13
|
-
.with_attached_hero_image
|
14
|
-
.includes([:organization])
|
15
11
|
end
|
16
12
|
|
17
13
|
def i18n_scope
|
@@ -5,40 +5,12 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when creating a new assembly
|
7
7
|
# type in the system.
|
8
|
-
class CreateAssembliesType < Decidim::
|
9
|
-
|
10
|
-
#
|
11
|
-
# form - A form object with the params.
|
12
|
-
def initialize(form)
|
13
|
-
@form = form
|
14
|
-
end
|
15
|
-
|
16
|
-
# Executes the command. Broadcasts these events:
|
17
|
-
#
|
18
|
-
# - :ok when everything is valid.
|
19
|
-
# - :invalid if the form was not valid and we could not proceed.
|
20
|
-
#
|
21
|
-
# Returns nothing.
|
22
|
-
def call
|
23
|
-
return broadcast(:invalid) if form.invalid?
|
24
|
-
|
25
|
-
create_assemblies_type!
|
26
|
-
|
27
|
-
broadcast(:ok)
|
28
|
-
end
|
8
|
+
class CreateAssembliesType < Decidim::Commands::CreateResource
|
9
|
+
fetch_form_attributes :title, :organization
|
29
10
|
|
30
11
|
private
|
31
12
|
|
32
|
-
|
33
|
-
|
34
|
-
def create_assemblies_type!
|
35
|
-
Decidim.traceability.create!(
|
36
|
-
AssembliesType,
|
37
|
-
form.current_user,
|
38
|
-
organization: form.current_organization,
|
39
|
-
title: form.title
|
40
|
-
)
|
41
|
-
end
|
13
|
+
def resource_class = Decidim::AssembliesType
|
42
14
|
end
|
43
15
|
end
|
44
16
|
end
|
@@ -3,110 +3,51 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Assemblies
|
5
5
|
module Admin
|
6
|
-
# A command with all the business logic when creating a new
|
7
|
-
#
|
8
|
-
class CreateAssembly < Decidim::
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
add_admins_as_followers(assembly)
|
27
|
-
link_participatory_processes(assembly)
|
28
|
-
Decidim::ContentBlocksCreator.new(assembly).create_default!
|
29
|
-
|
30
|
-
broadcast(:ok, assembly)
|
31
|
-
else
|
32
|
-
form.errors.add(:hero_image, assembly.errors[:hero_image]) if assembly.errors.include? :hero_image
|
33
|
-
form.errors.add(:banner_image, assembly.errors[:banner_image]) if assembly.errors.include? :banner_image
|
34
|
-
broadcast(:invalid)
|
35
|
-
end
|
6
|
+
# A command with all the business logic when creating a new assembly
|
7
|
+
# in the system.
|
8
|
+
class CreateAssembly < Decidim::Commands::CreateResource
|
9
|
+
fetch_file_attributes :hero_image, :banner_image
|
10
|
+
|
11
|
+
fetch_form_attributes :title, :subtitle, :weight, :slug, :hashtag, :description, :short_description,
|
12
|
+
:promoted, :scopes_enabled, :scope, :area, :parent, :announcement, :organization,
|
13
|
+
:private_space, :developer_group, :local_area, :target, :participatory_scope,
|
14
|
+
:participatory_structure, :meta_scope, :purpose_of_action,
|
15
|
+
:composition, :assembly_type, :creation_date, :created_by, :created_by_other,
|
16
|
+
:duration, :included_at, :closing_date, :closing_date_reason, :internal_organisation,
|
17
|
+
:is_transparent, :special_features, :twitter_handler, :facebook_handler,
|
18
|
+
:instagram_handler, :youtube_handler, :github_handler
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def run_after_hooks
|
23
|
+
add_admins_as_followers
|
24
|
+
link_participatory_processes
|
25
|
+
Decidim::ContentBlocksCreator.new(resource).create_default!
|
36
26
|
end
|
37
27
|
|
38
28
|
private
|
39
29
|
|
40
|
-
|
41
|
-
|
42
|
-
def assembly
|
43
|
-
@assembly ||= Decidim.traceability.create(
|
44
|
-
Assembly,
|
45
|
-
form.current_user,
|
46
|
-
organization: form.current_organization,
|
47
|
-
title: form.title,
|
48
|
-
subtitle: form.subtitle,
|
49
|
-
weight: form.weight,
|
50
|
-
slug: form.slug,
|
51
|
-
hashtag: form.hashtag,
|
52
|
-
description: form.description,
|
53
|
-
short_description: form.short_description,
|
54
|
-
hero_image: form.hero_image,
|
55
|
-
banner_image: form.banner_image,
|
56
|
-
promoted: form.promoted,
|
57
|
-
scopes_enabled: form.scopes_enabled,
|
58
|
-
scope: form.scope,
|
59
|
-
area: form.area,
|
60
|
-
parent: form.parent,
|
61
|
-
private_space: form.private_space,
|
62
|
-
developer_group: form.developer_group,
|
63
|
-
local_area: form.local_area,
|
64
|
-
target: form.target,
|
65
|
-
participatory_scope: form.participatory_scope,
|
66
|
-
participatory_structure: form.participatory_structure,
|
67
|
-
meta_scope: form.meta_scope,
|
68
|
-
show_statistics: form.show_statistics,
|
69
|
-
purpose_of_action: form.purpose_of_action,
|
70
|
-
composition: form.composition,
|
71
|
-
assembly_type: form.assembly_type,
|
72
|
-
creation_date: form.creation_date,
|
73
|
-
created_by: form.created_by,
|
74
|
-
created_by_other: form.created_by_other,
|
75
|
-
duration: form.duration,
|
76
|
-
included_at: form.included_at,
|
77
|
-
closing_date: form.closing_date,
|
78
|
-
closing_date_reason: form.closing_date_reason,
|
79
|
-
internal_organisation: form.internal_organisation,
|
80
|
-
is_transparent: form.is_transparent,
|
81
|
-
special_features: form.special_features,
|
82
|
-
twitter_handler: form.twitter_handler,
|
83
|
-
facebook_handler: form.facebook_handler,
|
84
|
-
instagram_handler: form.instagram_handler,
|
85
|
-
youtube_handler: form.youtube_handler,
|
86
|
-
github_handler: form.github_handler,
|
87
|
-
announcement: form.announcement
|
88
|
-
)
|
89
|
-
end
|
30
|
+
def resource_class = Decidim::Assembly
|
90
31
|
|
91
|
-
def add_admins_as_followers
|
92
|
-
|
32
|
+
def add_admins_as_followers
|
33
|
+
resource.organization.admins.each do |admin|
|
93
34
|
form = Decidim::FollowForm
|
94
|
-
.from_params(followable_gid:
|
35
|
+
.from_params(followable_gid: resource.to_signed_global_id.to_s)
|
95
36
|
.with_context(
|
96
|
-
current_organization:
|
37
|
+
current_organization: resource.organization,
|
97
38
|
current_user: admin
|
98
39
|
)
|
99
40
|
|
100
|
-
Decidim::CreateFollow.new(form
|
41
|
+
Decidim::CreateFollow.new(form).call
|
101
42
|
end
|
102
43
|
end
|
103
44
|
|
104
|
-
def participatory_processes
|
105
|
-
@participatory_processes ||=
|
45
|
+
def participatory_processes
|
46
|
+
@participatory_processes ||= resource.participatory_space_sibling_scope(:participatory_processes).where(id: form.participatory_processes_ids)
|
106
47
|
end
|
107
48
|
|
108
|
-
def link_participatory_processes
|
109
|
-
|
49
|
+
def link_participatory_processes
|
50
|
+
resource.link_participatory_space_resources(participatory_processes, "included_participatory_processes")
|
110
51
|
end
|
111
52
|
end
|
112
53
|
end
|
@@ -5,87 +5,35 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when creating a new assembly
|
7
7
|
# member in the system.
|
8
|
-
class CreateAssemblyMember < Decidim::
|
9
|
-
|
8
|
+
class CreateAssemblyMember < Decidim::Commands::CreateResource
|
9
|
+
fetch_file_attributes :non_user_avatar
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
# form - A form object with the params.
|
14
|
-
# assembly - The Assembly that will hold the member
|
15
|
-
def initialize(form, current_user, assembly)
|
16
|
-
@form = form
|
17
|
-
@current_user = current_user
|
18
|
-
@assembly = assembly
|
19
|
-
end
|
20
|
-
|
21
|
-
# Executes the command. Broadcasts these events:
|
22
|
-
#
|
23
|
-
# - :ok when everything is valid.
|
24
|
-
# - :invalid if the form was not valid and we could not proceed.
|
25
|
-
#
|
26
|
-
# Returns nothing.
|
27
|
-
def call
|
28
|
-
return broadcast(:invalid) if form.invalid?
|
11
|
+
fetch_form_attributes :full_name, :gender, :birthday, :birthplace, :ceased_date, :designation_date,
|
12
|
+
:position, :position_other, :user
|
29
13
|
|
30
|
-
|
31
|
-
create_assembly_member!
|
32
|
-
notify_assembly_member_about_new_membership
|
14
|
+
protected
|
33
15
|
|
34
|
-
|
35
|
-
|
36
|
-
if assembly_member_with_attributes.errors.include? :non_user_avatar
|
37
|
-
form.errors.add(
|
38
|
-
:non_user_avatar,
|
39
|
-
assembly_member_with_attributes.errors[:non_user_avatar]
|
40
|
-
)
|
41
|
-
end
|
42
|
-
broadcast(:invalid)
|
43
|
-
end
|
16
|
+
def run_after_hooks
|
17
|
+
notify_assembly_member_about_new_membership
|
44
18
|
end
|
45
19
|
|
46
20
|
private
|
47
21
|
|
48
|
-
|
49
|
-
|
50
|
-
def assembly_member_with_attributes
|
51
|
-
@assembly_member_with_attributes ||= Decidim::AssemblyMember.new(assembly_member_attributes)
|
22
|
+
def attributes
|
23
|
+
super.merge(assembly: form.participatory_space)
|
52
24
|
end
|
53
25
|
|
54
|
-
def
|
55
|
-
form.attributes.slice(
|
56
|
-
"full_name",
|
57
|
-
"gender",
|
58
|
-
"birthday",
|
59
|
-
"birthplace",
|
60
|
-
"ceased_date",
|
61
|
-
"designation_date",
|
62
|
-
"position",
|
63
|
-
"position_other",
|
64
|
-
"weight"
|
65
|
-
).symbolize_keys.merge(
|
66
|
-
assembly:,
|
67
|
-
user: form.user
|
68
|
-
).merge(
|
69
|
-
attachment_attributes(:non_user_avatar)
|
70
|
-
)
|
71
|
-
end
|
26
|
+
def resource_class = Decidim::AssemblyMember
|
72
27
|
|
73
|
-
def
|
74
|
-
|
28
|
+
def extra_params
|
29
|
+
{
|
75
30
|
resource: {
|
76
31
|
title: form.full_name
|
77
32
|
},
|
78
33
|
participatory_space: {
|
79
|
-
title:
|
34
|
+
title: form.participatory_space.title
|
80
35
|
}
|
81
36
|
}
|
82
|
-
|
83
|
-
@assembly_member = Decidim.traceability.create!(
|
84
|
-
Decidim::AssemblyMember,
|
85
|
-
current_user,
|
86
|
-
assembly_member_attributes,
|
87
|
-
log_info
|
88
|
-
)
|
89
37
|
end
|
90
38
|
|
91
39
|
def followers
|
@@ -96,7 +44,7 @@ module Decidim
|
|
96
44
|
data = {
|
97
45
|
event: "decidim.events.assemblies.create_assembly_member",
|
98
46
|
event_class: Decidim::Assemblies::CreateAssemblyMemberEvent,
|
99
|
-
resource:
|
47
|
+
resource: form.participatory_space,
|
100
48
|
followers:
|
101
49
|
}
|
102
50
|
Decidim::EventsManager.publish(**data)
|
@@ -5,50 +5,18 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when destroying an assembly
|
7
7
|
# member in the system.
|
8
|
-
class DestroyAssemblyMember < Decidim::
|
9
|
-
# Public: Initializes the command.
|
10
|
-
#
|
11
|
-
# assembly_member - the AssemblyMember to destroy
|
12
|
-
# current_user - the user performing this action
|
13
|
-
def initialize(assembly_member, current_user)
|
14
|
-
@assembly_member = assembly_member
|
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 was not valid and we could not proceed.
|
22
|
-
#
|
23
|
-
# Returns nothing.
|
24
|
-
def call
|
25
|
-
destroy_member!
|
26
|
-
broadcast(:ok)
|
27
|
-
end
|
28
|
-
|
8
|
+
class DestroyAssemblyMember < Decidim::Commands::DestroyResource
|
29
9
|
private
|
30
10
|
|
31
|
-
|
32
|
-
|
33
|
-
def destroy_member!
|
34
|
-
log_info = {
|
11
|
+
def extra_params
|
12
|
+
{
|
35
13
|
resource: {
|
36
|
-
title:
|
14
|
+
title: resource.full_name
|
37
15
|
},
|
38
16
|
participatory_space: {
|
39
|
-
title:
|
17
|
+
title: resource.assembly.title
|
40
18
|
}
|
41
19
|
}
|
42
|
-
|
43
|
-
Decidim.traceability.perform_action!(
|
44
|
-
"delete",
|
45
|
-
assembly_member,
|
46
|
-
current_user,
|
47
|
-
log_info
|
48
|
-
) do
|
49
|
-
assembly_member.destroy!
|
50
|
-
assembly_member
|
51
|
-
end
|
52
20
|
end
|
53
21
|
end
|
54
22
|
end
|
@@ -5,41 +5,8 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# A command with all the business logic when updating a new assembly
|
7
7
|
# type in the system.
|
8
|
-
class UpdateAssembliesType < Decidim::
|
9
|
-
|
10
|
-
#
|
11
|
-
# assemblies_type - A assemblies_type object to update.
|
12
|
-
# form - A form object with the params.
|
13
|
-
def initialize(assemblies_type, form)
|
14
|
-
@assemblies_type = assemblies_type
|
15
|
-
@form = form
|
16
|
-
end
|
17
|
-
|
18
|
-
# Executes the command. Broadcasts these events:
|
19
|
-
#
|
20
|
-
# - :ok when everything is valid.
|
21
|
-
# - :invalid if the form was not valid and we could not proceed.
|
22
|
-
#
|
23
|
-
# Returns nothing.
|
24
|
-
def call
|
25
|
-
return broadcast(:invalid) if form.invalid?
|
26
|
-
|
27
|
-
update_assemblies_type!
|
28
|
-
|
29
|
-
broadcast(:ok)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
attr_reader :form
|
35
|
-
|
36
|
-
def update_assemblies_type!
|
37
|
-
Decidim.traceability.update!(
|
38
|
-
@assemblies_type,
|
39
|
-
form.current_user,
|
40
|
-
title: form.title
|
41
|
-
)
|
42
|
-
end
|
8
|
+
class UpdateAssembliesType < Decidim::Commands::UpdateResource
|
9
|
+
fetch_form_attributes :title
|
43
10
|
end
|
44
11
|
end
|
45
12
|
end
|
@@ -3,113 +3,36 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Assemblies
|
5
5
|
module Admin
|
6
|
-
# A command with all the business logic when
|
7
|
-
#
|
8
|
-
class UpdateAssembly < Decidim::
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@parent = Assembly.find_by(id: @assembly.parent)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Executes the command. Broadcasts these events:
|
22
|
-
#
|
23
|
-
# - :ok when everything is valid.
|
24
|
-
# - :invalid if the form was not valid and we could not proceed.
|
25
|
-
#
|
26
|
-
# Returns nothing.
|
27
|
-
def call
|
28
|
-
return broadcast(:invalid) if form.invalid?
|
29
|
-
|
30
|
-
update_assembly
|
31
|
-
link_participatory_processes(@assembly)
|
32
|
-
|
33
|
-
if @assembly.valid?
|
34
|
-
broadcast(:ok, @assembly)
|
35
|
-
else
|
36
|
-
form.errors.add(:hero_image, @assembly.errors[:hero_image]) if @assembly.errors.include? :hero_image
|
37
|
-
form.errors.add(:banner_image, @assembly.errors[:banner_image]) if @assembly.errors.include? :banner_image
|
38
|
-
broadcast(:invalid)
|
39
|
-
end
|
40
|
-
end
|
6
|
+
# A command with all the business logic when updating a new assembly
|
7
|
+
# in the system.
|
8
|
+
class UpdateAssembly < Decidim::Commands::UpdateResource
|
9
|
+
fetch_file_attributes :hero_image, :banner_image
|
10
|
+
|
11
|
+
fetch_form_attributes :title, :subtitle, :slug, :hashtag, :promoted, :description, :short_description,
|
12
|
+
:scopes_enabled, :scope, :area, :parent, :private_space, :developer_group, :local_area,
|
13
|
+
:target, :participatory_scope, :participatory_structure, :meta_scope,
|
14
|
+
:purpose_of_action, :composition, :assembly_type, :creation_date, :created_by,
|
15
|
+
:created_by_other, :duration, :included_at, :closing_date, :closing_date_reason,
|
16
|
+
:internal_organisation, :is_transparent, :special_features, :twitter_handler, :announcement,
|
17
|
+
:facebook_handler, :instagram_handler, :youtube_handler, :github_handler, :weight
|
41
18
|
|
42
19
|
private
|
43
20
|
|
44
|
-
|
45
|
-
|
46
|
-
def update_assembly
|
47
|
-
@assembly.assign_attributes(attributes)
|
48
|
-
save_assembly if @assembly.valid?
|
21
|
+
def run_after_hooks
|
22
|
+
link_participatory_processes
|
49
23
|
update_children_count
|
50
24
|
end
|
51
25
|
|
52
|
-
def
|
53
|
-
|
54
|
-
@assembly.save!
|
55
|
-
Decidim.traceability.perform_action!(:update, @assembly, form.current_user) do
|
56
|
-
@assembly
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def attributes
|
62
|
-
{
|
63
|
-
title: form.title,
|
64
|
-
subtitle: form.subtitle,
|
65
|
-
slug: form.slug,
|
66
|
-
hashtag: form.hashtag,
|
67
|
-
promoted: form.promoted,
|
68
|
-
description: form.description,
|
69
|
-
short_description: form.short_description,
|
70
|
-
scopes_enabled: form.scopes_enabled,
|
71
|
-
scope: form.scope,
|
72
|
-
area: form.area,
|
73
|
-
parent: form.parent,
|
74
|
-
private_space: form.private_space,
|
75
|
-
developer_group: form.developer_group,
|
76
|
-
local_area: form.local_area,
|
77
|
-
target: form.target,
|
78
|
-
participatory_scope: form.participatory_scope,
|
79
|
-
participatory_structure: form.participatory_structure,
|
80
|
-
meta_scope: form.meta_scope,
|
81
|
-
show_statistics: form.show_statistics,
|
82
|
-
purpose_of_action: form.purpose_of_action,
|
83
|
-
composition: form.composition,
|
84
|
-
assembly_type: form.assembly_type,
|
85
|
-
creation_date: form.creation_date,
|
86
|
-
created_by: form.created_by,
|
87
|
-
created_by_other: form.created_by_other,
|
88
|
-
duration: form.duration,
|
89
|
-
included_at: form.included_at,
|
90
|
-
closing_date: form.closing_date,
|
91
|
-
closing_date_reason: form.closing_date_reason,
|
92
|
-
internal_organisation: form.internal_organisation,
|
93
|
-
is_transparent: form.is_transparent,
|
94
|
-
special_features: form.special_features,
|
95
|
-
twitter_handler: form.twitter_handler,
|
96
|
-
facebook_handler: form.facebook_handler,
|
97
|
-
instagram_handler: form.instagram_handler,
|
98
|
-
youtube_handler: form.youtube_handler,
|
99
|
-
github_handler: form.github_handler,
|
100
|
-
weight: form.weight,
|
101
|
-
announcement: form.announcement
|
102
|
-
}.merge(
|
103
|
-
attachment_attributes(:hero_image, :banner_image)
|
104
|
-
)
|
26
|
+
def parent
|
27
|
+
@parent ||= Assembly.find_by(id: resource.parent)
|
105
28
|
end
|
106
29
|
|
107
|
-
def participatory_processes
|
108
|
-
@participatory_processes ||=
|
30
|
+
def participatory_processes
|
31
|
+
@participatory_processes ||= resource.participatory_space_sibling_scope(:participatory_processes).where(id: form.participatory_processes_ids)
|
109
32
|
end
|
110
33
|
|
111
|
-
def link_participatory_processes
|
112
|
-
|
34
|
+
def link_participatory_processes
|
35
|
+
resource.link_participatory_space_resources(participatory_processes, "included_participatory_processes")
|
113
36
|
end
|
114
37
|
|
115
38
|
# Resets the children counter cache to its correct value using an SQL count query.
|
@@ -117,9 +40,9 @@ module Decidim
|
|
117
40
|
#
|
118
41
|
# Returns nothing.
|
119
42
|
def update_children_count
|
120
|
-
return unless
|
43
|
+
return unless parent
|
121
44
|
|
122
|
-
Assembly.reset_counters(
|
45
|
+
Assembly.reset_counters(parent.id, :children_count)
|
123
46
|
end
|
124
47
|
end
|
125
48
|
end
|