decidim-assemblies 0.28.3 → 0.29.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/assemblies/assembly_g_cell.rb +2 -2
  3. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb +0 -4
  4. data/app/cells/decidim/assemblies/content_blocks/stats_cell.rb +1 -1
  5. data/app/commands/decidim/assemblies/admin/create_assemblies_type.rb +3 -31
  6. data/app/commands/decidim/assemblies/admin/create_assembly.rb +30 -89
  7. data/app/commands/decidim/assemblies/admin/create_assembly_member.rb +14 -66
  8. data/app/commands/decidim/assemblies/admin/destroy_assembly_member.rb +5 -37
  9. data/app/commands/decidim/assemblies/admin/import_assembly.rb +1 -1
  10. data/app/commands/decidim/assemblies/admin/update_assemblies_type.rb +2 -35
  11. data/app/commands/decidim/assemblies/admin/update_assembly.rb +22 -99
  12. data/app/commands/decidim/assemblies/admin/update_assembly_member.rb +8 -69
  13. data/app/controllers/decidim/assemblies/admin/assemblies_controller.rb +1 -1
  14. data/app/controllers/decidim/assemblies/admin/assemblies_types_controller.rb +4 -4
  15. data/app/controllers/decidim/assemblies/admin/assembly_members_controller.rb +1 -1
  16. data/app/controllers/decidim/assemblies/admin/participatory_space_private_users_controller.rb +1 -1
  17. data/app/controllers/decidim/assemblies/admin/participatory_space_private_users_csv_imports_controller.rb +1 -1
  18. data/app/controllers/decidim/assemblies/application_controller.rb +4 -1
  19. data/app/controllers/decidim/assemblies/assemblies_controller.rb +0 -3
  20. data/app/controllers/decidim/assemblies/assembly_members_controller.rb +0 -2
  21. data/app/forms/decidim/assemblies/admin/assembly_form.rb +0 -1
  22. data/app/helpers/decidim/assemblies/assemblies_helper.rb +0 -26
  23. data/app/permissions/decidim/assemblies/permissions.rb +1 -1
  24. data/app/presenters/decidim/assemblies/admin_log/assembly_presenter.rb +0 -1
  25. data/app/serializers/decidim/assemblies/assembly_importer.rb +0 -1
  26. data/app/serializers/decidim/assemblies/assembly_serializer.rb +1 -2
  27. data/app/views/decidim/assemblies/admin/assemblies/_form.html.erb +5 -9
  28. data/app/views/decidim/assemblies/admin/assembly_members/index.html.erb +1 -1
  29. data/app/views/decidim/assemblies/admin/assembly_user_roles/index.html.erb +1 -1
  30. data/app/views/decidim/assemblies/assemblies/show.html.erb +22 -18
  31. data/app/views/decidim/assemblies/assembly_members/index.html.erb +2 -1
  32. data/config/locales/ar.yml +0 -6
  33. data/config/locales/bg.yml +2 -7
  34. data/config/locales/ca.yml +3 -8
  35. data/config/locales/cs.yml +1 -6
  36. data/config/locales/de.yml +3 -8
  37. data/config/locales/el.yml +0 -6
  38. data/config/locales/en.yml +2 -7
  39. data/config/locales/es-MX.yml +2 -7
  40. data/config/locales/es-PY.yml +1 -6
  41. data/config/locales/es.yml +4 -9
  42. data/config/locales/eu.yml +2 -7
  43. data/config/locales/fi-plain.yml +1 -6
  44. data/config/locales/fi.yml +1 -6
  45. data/config/locales/fr-CA.yml +2 -7
  46. data/config/locales/fr.yml +2 -7
  47. data/config/locales/ga-IE.yml +0 -3
  48. data/config/locales/gl.yml +0 -6
  49. data/config/locales/he-IL.yml +0 -4
  50. data/config/locales/hu.yml +1 -7
  51. data/config/locales/id-ID.yml +0 -5
  52. data/config/locales/is-IS.yml +0 -4
  53. data/config/locales/it.yml +0 -6
  54. data/config/locales/ja.yml +2 -7
  55. data/config/locales/lb.yml +0 -5
  56. data/config/locales/lt.yml +0 -6
  57. data/config/locales/lv.yml +0 -5
  58. data/config/locales/nl.yml +0 -6
  59. data/config/locales/no.yml +0 -6
  60. data/config/locales/pl.yml +1 -12
  61. data/config/locales/pt-BR.yml +0 -6
  62. data/config/locales/pt.yml +0 -6
  63. data/config/locales/ro-RO.yml +0 -6
  64. data/config/locales/ru.yml +0 -5
  65. data/config/locales/sk.yml +0 -3
  66. data/config/locales/sl.yml +0 -2
  67. data/config/locales/sq-AL.yml +2 -3
  68. data/config/locales/sv.yml +123 -189
  69. data/config/locales/tr-TR.yml +0 -5
  70. data/config/locales/uk.yml +0 -5
  71. data/config/locales/zh-CN.yml +0 -5
  72. data/config/locales/zh-TW.yml +0 -6
  73. data/db/migrate/20240712061153_change_show_statistics_from_decidim_assemblies.rb +11 -0
  74. data/decidim-assemblies.gemspec +1 -1
  75. data/lib/decidim/api/assembly_type.rb +5 -6
  76. data/lib/decidim/assemblies/content_blocks/registry_manager.rb +1 -1
  77. data/lib/decidim/assemblies/engine.rb +1 -0
  78. data/lib/decidim/assemblies/menu.rb +11 -0
  79. data/lib/decidim/assemblies/seeds.rb +1 -11
  80. data/lib/decidim/assemblies/test/factories.rb +0 -1
  81. data/lib/decidim/assemblies/version.rb +1 -1
  82. metadata +17 -18
  83. data/app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb +0 -45
  84. data/app/views/layouts/decidim/assembly.html.erb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a16649518271f3a2049f530268fe608eee09079f6491498235681c7557c2d1e
4
- data.tar.gz: c4bdd9e76df3314ca72571c3d12b1656849df8db59a817ff70a9b06f72cbd41d
3
+ metadata.gz: bb2e321d4d397b59daabff4553cdc2caa3ed6fbf2eb8f9d33b3e3fbc1fef8ffc
4
+ data.tar.gz: f0e387fe8972d70c6e1d046b4726caba7d7529d1aa9306ca6484807d3d1fc1e4
5
5
  SHA512:
6
- metadata.gz: c072d797227785aa510389d0be5c4332cbacf194a27b9f09618d60a4713adc2b98f3dd9f7b9049e20a94c28d9dc59b5ba3c5a19baa9dff8a8608cd55e6dd28a9
7
- data.tar.gz: 6102c1ec728707d9dbbcf097da718812b34b2fa75b3b3d5a8b4325def3f258855f703dfe2681baf9d0a24bc09154fb02b06c14df9d64bfaa09eca95f12d587cd
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 resource_image_url
15
- model.attached_uploader(:hero_image).url
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
@@ -7,7 +7,7 @@ module Decidim
7
7
  private
8
8
 
9
9
  def stats
10
- @stats ||= resource.show_statistics && AssemblyStatsPresenter.new(assembly: resource).collection
10
+ @stats ||= AssemblyStatsPresenter.new(assembly: resource).collection
11
11
  end
12
12
  end
13
13
  end
@@ -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::Command
9
- # Public: Initializes the command.
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
- attr_reader :form
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 participatory
7
- # assembly in the system.
8
- class CreateAssembly < Decidim::Command
9
- # Public: Initializes the command.
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
- if assembly.persisted?
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
- attr_reader :form
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(assembly)
92
- assembly.organization.admins.each do |admin|
32
+ def add_admins_as_followers
33
+ resource.organization.admins.each do |admin|
93
34
  form = Decidim::FollowForm
94
- .from_params(followable_gid: assembly.to_signed_global_id.to_s)
35
+ .from_params(followable_gid: resource.to_signed_global_id.to_s)
95
36
  .with_context(
96
- current_organization: assembly.organization,
37
+ current_organization: resource.organization,
97
38
  current_user: admin
98
39
  )
99
40
 
100
- Decidim::CreateFollow.new(form, admin).call
41
+ Decidim::CreateFollow.new(form).call
101
42
  end
102
43
  end
103
44
 
104
- def participatory_processes(assembly)
105
- @participatory_processes ||= assembly.participatory_space_sibling_scope(:participatory_processes).where(id: @form.participatory_processes_ids)
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(assembly)
109
- assembly.link_participatory_space_resources(participatory_processes(assembly), "included_participatory_processes")
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::Command
9
- include ::Decidim::AttachmentAttributesMethods
8
+ class CreateAssemblyMember < Decidim::Commands::CreateResource
9
+ fetch_file_attributes :non_user_avatar
10
10
 
11
- # Public: Initializes the command.
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
- if assembly_member_with_attributes.valid?
31
- create_assembly_member!
32
- notify_assembly_member_about_new_membership
14
+ protected
33
15
 
34
- broadcast(:ok)
35
- else
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
- attr_reader :form, :assembly, :current_user
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 assembly_member_attributes
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 create_assembly_member!
74
- log_info = {
28
+ def extra_params
29
+ {
75
30
  resource: {
76
31
  title: form.full_name
77
32
  },
78
33
  participatory_space: {
79
- title: assembly.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: assembly,
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::Command
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
- attr_reader :assembly_member, :current_user
32
-
33
- def destroy_member!
34
- log_info = {
11
+ def extra_params
12
+ {
35
13
  resource: {
36
- title: assembly_member.full_name
14
+ title: resource.full_name
37
15
  },
38
16
  participatory_space: {
39
- title: assembly_member.assembly.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
@@ -67,7 +67,7 @@ module Decidim
67
67
  current_user: admin
68
68
  )
69
69
 
70
- Decidim::CreateFollow.new(form, admin).call
70
+ Decidim::CreateFollow.new(form).call
71
71
  end
72
72
  end
73
73
  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::Command
9
- # Public: Initializes the command.
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 creating a new participatory
7
- # assembly in the system.
8
- class UpdateAssembly < Decidim::Command
9
- include ::Decidim::AttachmentAttributesMethods
10
-
11
- # Public: Initializes the command.
12
- #
13
- # assembly - the Assembly to update
14
- # form - A form object with the params.
15
- def initialize(assembly, form)
16
- @assembly = assembly
17
- @form = form
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
- attr_reader :form, :assembly
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 save_assembly
53
- transaction do
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(assembly)
108
- @participatory_processes ||= assembly.participatory_space_sibling_scope(:participatory_processes).where(id: @form.participatory_processes_ids)
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(assembly)
112
- assembly.link_participatory_space_resources(participatory_processes(assembly), "included_participatory_processes")
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 @parent
43
+ return unless parent
121
44
 
122
- Assembly.reset_counters(@parent.id, :children_count)
45
+ Assembly.reset_counters(parent.id, :children_count)
123
46
  end
124
47
  end
125
48
  end