decidim-assemblies 0.21.0 → 0.23.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/decidim/assemblies/assembly.svg +1 -3
  3. data/app/assets/javascripts/decidim/assemblies/orgchart.js.es6 +698 -0
  4. data/app/cells/decidim/assemblies/assembly_m/footer.erb +2 -2
  5. data/app/cells/decidim/assemblies/assembly_m_cell.rb +4 -0
  6. data/app/cells/decidim/assemblies/assembly_member/show.erb +4 -4
  7. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies/show.erb +10 -11
  8. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb +1 -0
  9. data/app/commands/decidim/assemblies/admin/create_assembly_admin.rb +2 -1
  10. data/app/commands/decidim/assemblies/admin/create_assembly_member.rb +12 -3
  11. data/app/commands/decidim/assemblies/admin/import_assembly.rb +72 -0
  12. data/app/commands/decidim/assemblies/admin/notify_role_assigned_to_assembly.rb +22 -0
  13. data/app/commands/decidim/assemblies/admin/update_assemblies_setting.rb +46 -0
  14. data/app/commands/decidim/assemblies/admin/update_assembly.rb +10 -5
  15. data/app/commands/decidim/assemblies/admin/update_assembly_admin.rb +2 -1
  16. data/app/controllers/decidim/assemblies/admin/assemblies_settings_controller.rb +49 -0
  17. data/app/controllers/decidim/assemblies/admin/assembly_exports_controller.rb +24 -0
  18. data/app/controllers/decidim/assemblies/admin/assembly_imports_controller.rb +31 -0
  19. data/app/controllers/decidim/assemblies/admin/assembly_user_roles_controller.rb +2 -1
  20. data/app/controllers/decidim/assemblies/assemblies_controller.rb +5 -1
  21. data/app/controllers/decidim/assemblies/{assembly_widgets_controller.rb → widgets_controller.rb} +2 -2
  22. data/app/events/decidim/assemblies/create_assembly_member_event.rb +17 -0
  23. data/app/events/decidim/role_assigned_to_assembly_event.rb +28 -0
  24. data/app/forms/decidim/assemblies/admin/assemblies_setting_form.rb +14 -0
  25. data/app/forms/decidim/assemblies/admin/assembly_form.rb +19 -10
  26. data/app/forms/decidim/assemblies/admin/assembly_import_form.rb +83 -0
  27. data/app/forms/decidim/assemblies/admin/assembly_user_role_form.rb +3 -2
  28. data/app/helpers/decidim/assemblies/assemblies_helper.rb +6 -3
  29. data/app/models/decidim/assemblies_setting.rb +17 -0
  30. data/app/models/decidim/assemblies_type.rb +3 -0
  31. data/app/models/decidim/assembly.rb +14 -1
  32. data/app/permissions/decidim/assemblies/permissions.rb +35 -2
  33. data/app/presenters/decidim/assemblies/admin_log/assemblies_setting_presenter.rb +27 -0
  34. data/app/presenters/decidim/assemblies/admin_log/assemblies_type_presenter.rb +2 -2
  35. data/app/presenters/decidim/assemblies/admin_log/assembly_member_presenter.rb +2 -2
  36. data/app/presenters/decidim/assemblies/admin_log/assembly_presenter.rb +2 -2
  37. data/app/presenters/decidim/assemblies/admin_log/assembly_user_role_presenter.rb +2 -2
  38. data/app/presenters/decidim/assemblies/assembly_presenter.rb +29 -0
  39. data/app/presenters/decidim/assemblies/assembly_stats_presenter.rb +1 -1
  40. data/app/queries/decidim/assemblies/parent_assemblies_for_select.rb +20 -1
  41. data/app/serializers/decidim/assemblies/assembly_importer.rb +172 -0
  42. data/app/serializers/decidim/assemblies/assembly_serializer.rb +147 -0
  43. data/app/views/decidim/assemblies/_filter_by_type.html.erb +11 -9
  44. data/app/views/decidim/assemblies/admin/assemblies/index.html.erb +13 -2
  45. data/app/views/decidim/assemblies/admin/assemblies_settings/_form.html.erb +10 -0
  46. data/app/views/decidim/assemblies/admin/assemblies_settings/edit.html.erb +6 -0
  47. data/app/views/decidim/assemblies/admin/assembly_imports/_form.html.erb +46 -0
  48. data/app/views/decidim/assemblies/admin/assembly_imports/new.html.erb +7 -0
  49. data/app/views/decidim/assemblies/admin/assembly_members/index.html.erb +2 -2
  50. data/app/views/decidim/assemblies/assemblies/_parent_assemblies.html.erb +2 -2
  51. data/app/views/decidim/assemblies/assemblies/_promoted_assembly.html.erb +3 -3
  52. data/app/views/decidim/assemblies/assemblies/index.html.erb +11 -8
  53. data/app/views/decidim/assemblies/assemblies/show.html.erb +10 -9
  54. data/app/views/decidim/assemblies/assembly_members/index.html.erb +1 -1
  55. data/app/views/layouts/decidim/admin/assemblies.html.erb +5 -0
  56. data/app/views/layouts/decidim/assembly.html.erb +1 -0
  57. data/config/locales/am-ET.yml +1 -0
  58. data/config/locales/bg-BG.yml +7 -0
  59. data/config/locales/bg.yml +7 -0
  60. data/config/locales/ca.yml +72 -1
  61. data/config/locales/cs.yml +118 -47
  62. data/config/locales/da-DK.yml +1 -0
  63. data/config/locales/da.yml +1 -0
  64. data/config/locales/de.yml +133 -39
  65. data/config/locales/el.yml +474 -0
  66. data/config/locales/en.yml +71 -0
  67. data/config/locales/eo.yml +1 -0
  68. data/config/locales/es-MX.yml +71 -0
  69. data/config/locales/es-PY.yml +71 -0
  70. data/config/locales/es.yml +71 -0
  71. data/config/locales/et-EE.yml +1 -0
  72. data/config/locales/et.yml +1 -0
  73. data/config/locales/fi-plain.yml +72 -1
  74. data/config/locales/fi.yml +79 -8
  75. data/config/locales/fr-CA.yml +481 -0
  76. data/config/locales/fr.yml +93 -1
  77. data/config/locales/ga-IE.yml +1 -0
  78. data/config/locales/gl.yml +37 -16
  79. data/config/locales/hr-HR.yml +1 -0
  80. data/config/locales/hr.yml +1 -0
  81. data/config/locales/hu.yml +53 -2
  82. data/config/locales/is.yml +263 -0
  83. data/config/locales/it.yml +159 -76
  84. data/config/locales/ja-JP.yml +471 -0
  85. data/config/locales/ja.yml +477 -0
  86. data/config/locales/ko-KR.yml +1 -0
  87. data/config/locales/ko.yml +1 -0
  88. data/config/locales/lt-LT.yml +1 -0
  89. data/config/locales/lt.yml +1 -0
  90. data/config/locales/lv.yml +454 -0
  91. data/config/locales/mt-MT.yml +1 -0
  92. data/config/locales/mt.yml +1 -0
  93. data/config/locales/nl.yml +77 -0
  94. data/config/locales/no.yml +79 -10
  95. data/config/locales/om-ET.yml +1 -0
  96. data/config/locales/pl.yml +240 -152
  97. data/config/locales/pt-BR.yml +1 -1
  98. data/config/locales/pt.yml +207 -119
  99. data/config/locales/ro-RO.yml +441 -0
  100. data/config/locales/si-LK.yml +1 -0
  101. data/config/locales/sk-SK.yml +168 -0
  102. data/config/locales/sk.yml +172 -0
  103. data/config/locales/sl.yml +283 -0
  104. data/config/locales/so-SO.yml +1 -0
  105. data/config/locales/sr-CS.yml +73 -0
  106. data/config/locales/sv.yml +178 -89
  107. data/config/locales/sw-KE.yml +1 -0
  108. data/config/locales/ti-ER.yml +1 -0
  109. data/config/locales/tr-TR.yml +237 -144
  110. data/config/locales/vi-VN.yml +1 -0
  111. data/config/locales/vi.yml +1 -0
  112. data/config/locales/zh-CN.yml +471 -0
  113. data/config/locales/zh-TW.yml +1 -0
  114. data/db/migrate/20200320105906_index_foreign_keys_in_decidim_assemblies.rb +7 -0
  115. data/db/migrate/20200320105907_index_foreign_keys_in_decidim_assembly_user_roles.rb +7 -0
  116. data/db/migrate/20200416132109_remove_legacy_decidim_assembly_type.rb +8 -0
  117. data/db/migrate/20200430202456_create_decidim_assemblies_settings.rb +10 -0
  118. data/db/seeds/city.jpeg +0 -0
  119. data/db/seeds/city2.jpeg +0 -0
  120. data/lib/decidim/assemblies/admin_engine.rb +8 -0
  121. data/lib/decidim/assemblies/engine.rb +1 -1
  122. data/lib/decidim/assemblies/participatory_space.rb +26 -13
  123. data/lib/decidim/assemblies/test/factories.rb +8 -3
  124. data/lib/decidim/assemblies/version.rb +1 -1
  125. metadata +74 -14
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module AdminLog
6
+ # This class holds the logic to present a `Decidim::AssembliesSetting`
7
+ # for the `AdminLog` log.
8
+ #
9
+ # Usage should be automatic and you shouldn't need to call this class
10
+ # directly, but here's an example:
11
+ #
12
+ # action_log = Decidim::ActionLog.last
13
+ # view_helpers # => this comes from the views
14
+ # AssembliesSettingPresenter.new(action_log, view_helpers).present
15
+ class AssembliesSettingPresenter < Decidim::Log::BasePresenter
16
+ private
17
+
18
+ def action_string
19
+ case action
20
+ when "update"
21
+ "decidim.admin_log.assembly_setting.#{action}"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -34,8 +34,8 @@ module Decidim
34
34
  end
35
35
  end
36
36
 
37
- def has_diff?
38
- action == "delete" || super
37
+ def diff_actions
38
+ super + %w(delete)
39
39
  end
40
40
  end
41
41
  end
@@ -43,8 +43,8 @@ module Decidim
43
43
  end
44
44
  end
45
45
 
46
- def has_diff?
47
- action == "delete" || super
46
+ def diff_actions
47
+ super + %w(delete)
48
48
  end
49
49
  end
50
50
  end
@@ -70,8 +70,8 @@ module Decidim
70
70
  end
71
71
  end
72
72
 
73
- def has_diff?
74
- action == "unpublish" || super
73
+ def diff_actions
74
+ super + %w(unpublish)
75
75
  end
76
76
  end
77
77
  end
@@ -44,8 +44,8 @@ module Decidim
44
44
  ).changeset
45
45
  end
46
46
 
47
- def has_diff?
48
- action == "delete" || super
47
+ def diff_actions
48
+ super + %w(delete)
49
49
  end
50
50
  end
51
51
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ class AssemblyPresenter < SimpleDelegator
6
+ include Rails.application.routes.mounted_helpers
7
+ include ActionView::Helpers::UrlHelper
8
+
9
+ delegate :url, to: :hero_image, prefix: true
10
+ delegate :url, to: :banner_image, prefix: true
11
+
12
+ def hero_image_url
13
+ return if assembly.hero_image.blank?
14
+
15
+ URI.join(decidim.root_url(host: assembly.organization.host), assembly.hero_image_url).to_s
16
+ end
17
+
18
+ def banner_image_url
19
+ return if assembly.banner_image.blank?
20
+
21
+ URI.join(decidim.root_url(host: assembly.organization.host), assembly.banner_image_url).to_s
22
+ end
23
+
24
+ def assembly
25
+ __getobj__
26
+ end
27
+ end
28
+ end
29
+ end
@@ -38,7 +38,7 @@ module Decidim
38
38
 
39
39
  def render_stats_data(component_manifest, name, data, index)
40
40
  safe_join([
41
- index.zero? ? manifest_icon(component_manifest) : " /&nbsp".html_safe,
41
+ index.zero? ? manifest_icon(component_manifest, role: "img", "aria-hidden": true) : " /&nbsp".html_safe,
42
42
  content_tag(:span, "#{number_with_delimiter(data)} " + I18n.t(name, scope: "decidim.assemblies.statistics"),
43
43
  class: "#{name} process_stats-text")
44
44
  ])
@@ -15,8 +15,27 @@ module Decidim
15
15
  @assembly = assembly
16
16
  end
17
17
 
18
+ # Finds the available assemblies
19
+ #
20
+ # Returns an ActiveRecord::Relation.
18
21
  def query
19
- Assembly.where(organization: @organization).where.not(id: @assembly)
22
+ available_assemblies = Assembly.where(organization: @organization).where.not(id: @assembly)
23
+
24
+ return available_assemblies if @assembly.blank?
25
+
26
+ available_assemblies.where.not(id: descendant_ids)
27
+ end
28
+
29
+ private
30
+
31
+ def descendant_ids
32
+ recursive_children(@assembly).flatten
33
+ end
34
+
35
+ def recursive_children(model)
36
+ model.children.map do |child|
37
+ [recursive_children(child), child.id]
38
+ end
20
39
  end
21
40
  end
22
41
  end
@@ -0,0 +1,172 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ # A factory class to ensure we always create Assemblies the same way since it involves some logic.
6
+ class AssemblyImporter < Decidim::Importers::Importer
7
+ def initialize(organization, user)
8
+ @organization = organization
9
+ @user = user
10
+ end
11
+
12
+ # Public: Creates a new Assembly.
13
+ #
14
+ # attributes - The Hash of attributes to create the Assembly with.
15
+ # user - The user that performs the action.
16
+ # opts - The options MUST contain:
17
+ # - title: The +title+ for the new Assembly
18
+ # - slug: The +slug+ for the new Assembly
19
+ #
20
+ # Returns a Assembly.
21
+ def import(attributes, _user, opts)
22
+ title = opts[:title]
23
+ slug = opts[:slug]
24
+ Decidim.traceability.perform_action!(:create, Assembly, @user, visibility: "all") do
25
+ @imported_assembly = Assembly.new(
26
+ organization: @organization,
27
+ title: title,
28
+ slug: slug,
29
+ hashtag: attributes["hashtag"],
30
+ subtitle: attributes["subtitle"],
31
+ short_description: attributes["short_description"],
32
+ description: attributes["description"],
33
+ promoted: attributes["promoted"],
34
+ developer_group: attributes["developer_group"],
35
+ local_area: attributes["local_area"],
36
+ target: attributes["target"],
37
+ participatory_scope: attributes["participatory_scope"],
38
+ participatory_structure: attributes["participatory_structure"],
39
+ show_statistics: attributes["show_statistics"],
40
+ scopes_enabled: attributes["scopes_enabled"],
41
+ private_space: attributes["private_space"],
42
+ reference: attributes["reference"],
43
+ purpose_of_action: attributes["purpose_of_action"],
44
+ composition: attributes["composition"],
45
+ duration: attributes["duration"],
46
+ creation_date: attributes["creation_date"],
47
+ decidim_scope_id: attributes["decidim_scope_id"],
48
+ closing_date_reason: attributes["closing_date_reason"],
49
+ included_at: attributes["included_at"],
50
+ closing_date: attributes["closing_date"],
51
+ created_by_other: attributes["created_by_other"],
52
+ internal_organisation: attributes["internal_organisation"],
53
+ is_transparent: attributes["is_transparent"],
54
+ special_features: attributes["special_features"],
55
+ twitter_handler: attributes["twitter_handler"],
56
+ instagram_handler: attributes["instagram_handler"],
57
+ facebook_handler: attributes["facebook_handler"],
58
+ youtube_handler: attributes["youtube_handler"],
59
+ github_handler: attributes["github_handler"],
60
+ created_by: attributes["created_by"],
61
+ meta_scope: attributes["meta_scope"]
62
+ )
63
+ @imported_assembly.remote_hero_image_url = attributes["remote_hero_image_url"] if remote_file_exists?(attributes["remote_hero_image_url"])
64
+ @imported_assembly.remote_banner_image_url = attributes["remote_banner_image_url"] if remote_file_exists?(attributes["remote_banner_image_url"])
65
+ @imported_assembly.save!
66
+ @imported_assembly
67
+ end
68
+ end
69
+
70
+ def import_assemblies_type(type_id)
71
+ return if Decidim::AssembliesType.find_by(id: type_id).nil?
72
+
73
+ @imported_assembly.decidim_assemblies_type_id = type_id
74
+ end
75
+
76
+ def import_categories(categories)
77
+ return if categories.nil?
78
+
79
+ categories.map do |category_attributes|
80
+ category = Decidim.traceability.create!(
81
+ Category,
82
+ @user,
83
+ name: category_attributes["name"],
84
+ description: category_attributes["description"],
85
+ parent_id: category_attributes["parent_id"],
86
+ participatory_space: @imported_assembly
87
+ )
88
+ next if category_attributes["subcategories"].nil?
89
+
90
+ category_attributes["subcategories"].map do |subcategory_attributes|
91
+ Decidim.traceability.create!(
92
+ Category,
93
+ @user,
94
+ name: subcategory_attributes["name"],
95
+ description: subcategory_attributes["description"],
96
+ parent_id: category.id,
97
+ participatory_space: @imported_assembly
98
+ )
99
+ end
100
+ end
101
+ end
102
+
103
+ def import_folders_and_attachments(attachments)
104
+ return if attachments["files"].nil?
105
+
106
+ attachments["files"].map do |file|
107
+ next unless remote_file_exists?(file["remote_file_url"])
108
+
109
+ file_tmp = URI.open(file["remote_file_url"])
110
+
111
+ Decidim.traceability.perform_action!("create", Attachment, @user) do
112
+ attachment = Attachment.new(
113
+ title: file["title"],
114
+ description: file["description"],
115
+ content_type: file_tmp.content_type,
116
+ attached_to: @imported_assembly,
117
+ weight: file["weight"],
118
+ file: form.file, # Define attached_to before this
119
+ file_size: file_tmp.size
120
+ )
121
+ attachment.create_attachment_collection(file["attachment_collection"])
122
+ attachment.save!
123
+ attachment
124
+ end
125
+ end
126
+
127
+ attachments["attachment_collections"].map do |collection|
128
+ Decidim.traceability.perform_action!("create", AttachmentCollection, @user) do
129
+ create_attachment_collection(collection)
130
+ end
131
+ end
132
+ end
133
+
134
+ # +components+: An Array of Hashes, each corresponding with the settings of a Decidim::Component.
135
+ def import_components(components)
136
+ return if components.nil?
137
+
138
+ importer = Decidim::Importers::ParticipatorySpaceComponentsImporter.new(@imported_assembly)
139
+ importer.import(components, @user)
140
+ end
141
+
142
+ private
143
+
144
+ def create_attachment_collection(attributes)
145
+ return unless attributes.compact.any?
146
+
147
+ attachment_collection = AttachmentCollection.find_or_initialize_by(
148
+ name: attributes["name"],
149
+ weight: attributes["weight"],
150
+ description: attributes["description"],
151
+ collection_for: @imported_assembly
152
+ )
153
+ attachment_collection.save!
154
+ attachment_collection
155
+ end
156
+
157
+ def remote_file_exists?(url)
158
+ return if url.nil?
159
+
160
+ accepted = ["image", "application/pdf"]
161
+ url = URI.parse(url)
162
+ http_connection = Net::HTTP.new(url.host, url.port)
163
+ http_connection.use_ssl = true if url.scheme == "https"
164
+ http_connection.start do |http|
165
+ return http.head(url.request_uri)["Content-Type"].start_with?(*accepted)
166
+ end
167
+ rescue StandardError
168
+ nil
169
+ end
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ # This class serializes an Assembly so it can be exported to CSV, JSON or other formats.
6
+ class AssemblySerializer < Decidim::Exporters::Serializer
7
+ include Decidim::ApplicationHelper
8
+ include Decidim::ResourceHelper
9
+ include Decidim::TranslationsHelper
10
+
11
+ # Public: Initializes the serializer with a assembly.
12
+ def initialize(assembly)
13
+ @assembly = assembly
14
+ end
15
+
16
+ # Public: Exports a hash with the serialized data for this assembly.
17
+ def serialize
18
+ {
19
+ id: assembly.id,
20
+ slug: assembly.slug,
21
+ hashtag: assembly.hashtag,
22
+ decidim_organization_id: assembly.decidim_organization_id,
23
+ title: assembly.title,
24
+ subtitle: assembly.subtitle,
25
+ short_description: assembly.short_description,
26
+ description: assembly.description,
27
+ remote_hero_image_url: Decidim::Assemblies::AssemblyPresenter.new(assembly).hero_image_url,
28
+ remote_banner_image_url: Decidim::Assemblies::AssemblyPresenter.new(assembly).banner_image_url,
29
+ promoted: assembly.promoted,
30
+ developer_group: assembly.developer_group,
31
+ meta_scope: assembly.meta_scope,
32
+ local_area: assembly.local_area,
33
+ target: assembly.target,
34
+ decidim_scope_id: assembly.decidim_scope_id,
35
+ paticipatory_scope: assembly.participatory_scope,
36
+ participatory_structure: assembly.participatory_structure,
37
+ show_statistics: assembly.show_statistics,
38
+ scopes_enabled: assembly.scopes_enabled,
39
+ private_space: assembly.private_space,
40
+ reference: assembly.reference,
41
+ purpose_of_action: assembly.purpose_of_action,
42
+ composition: assembly.composition,
43
+ duration: assembly.duration,
44
+ participatory_scope: assembly.participatory_scope,
45
+ included_at: assembly.included_at,
46
+ closing_date: assembly.closing_date,
47
+ created_by: assembly.created_by,
48
+ creation_date: assembly.creation_date,
49
+ closing_date_reason: assembly.closing_date_reason,
50
+ internal_organisation: assembly.internal_organisation,
51
+ is_transparent: assembly.is_transparent,
52
+ special_features: assembly.special_features,
53
+ twitter_handler: assembly.twitter_handler,
54
+ instagram_handler: assembly.instagram_handler,
55
+ facebook_handler: assembly.facebook_handler,
56
+ youtube_handler: assembly.youtube_handler,
57
+ github_handler: assembly.github_handler,
58
+ created_by_other: assembly.created_by_other,
59
+ decidim_assemblies_type_id: assembly.decidim_assemblies_type_id,
60
+ area: {
61
+ id: assembly.area.try(:id),
62
+ name: assembly.area.try(:name) || empty_translatable
63
+ },
64
+ scope: {
65
+ id: assembly.scope.try(:id),
66
+ name: assembly.scope.try(:name) || empty_translatable
67
+ },
68
+
69
+ assembly_categories: serialize_categories,
70
+ attachments: {
71
+ attachment_collections: serialize_attachment_collections,
72
+ files: serialize_attachments
73
+ },
74
+ components: serialize_components
75
+ }
76
+ end
77
+
78
+ private
79
+
80
+ attr_reader :assembly
81
+
82
+ def serialize_categories
83
+ return unless assembly.categories.first_class.any?
84
+
85
+ assembly.categories.first_class.map do |category|
86
+ {
87
+ id: category.try(:id),
88
+ name: category.try(:name),
89
+ description: category.try(:description),
90
+ parent_id: category.try(:parent_id),
91
+ subcategories: serialize_subcategories(category.subcategories)
92
+ }
93
+ end
94
+ end
95
+
96
+ def serialize_subcategories(subcategories)
97
+ return unless subcategories.any?
98
+
99
+ subcategories.map do |subcategory|
100
+ {
101
+ id: subcategory.try(:id),
102
+ name: subcategory.try(:name),
103
+ description: subcategory.try(:description),
104
+ parent_id: subcategory.try(:parent_id)
105
+ }
106
+ end
107
+ end
108
+
109
+ def serialize_attachment_collections
110
+ return unless assembly.attachment_collections.any?
111
+
112
+ assembly.attachment_collections.map do |collection|
113
+ {
114
+ id: collection.try(:id),
115
+ name: collection.try(:name),
116
+ weight: collection.try(:weight),
117
+ description: collection.try(:description)
118
+ }
119
+ end
120
+ end
121
+
122
+ def serialize_attachments
123
+ return unless assembly.attachments.any?
124
+
125
+ assembly.attachments.map do |attachment|
126
+ {
127
+ id: attachment.try(:id),
128
+ title: attachment.try(:title),
129
+ weight: attachment.try(:weight),
130
+ description: attachment.try(:description),
131
+ attachment_collection: {
132
+ name: attachment.attachment_collection.try(:name),
133
+ weight: attachment.attachment_collection.try(:weight),
134
+ description: attachment.attachment_collection.try(:description)
135
+ },
136
+ remote_file_url: Decidim::AttachmentPresenter.new(attachment).attachment_file_url
137
+ }
138
+ end
139
+ end
140
+
141
+ def serialize_components
142
+ serializer = Decidim::Exporters::ParticipatorySpaceComponentsSerializer.new(@assembly)
143
+ serializer.serialize
144
+ end
145
+ end
146
+ end
147
+ end