decidim-assemblies 0.29.4 → 0.30.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.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/assemblies/assembly_metadata_g_cell.rb +1 -14
  3. data/app/cells/decidim/assemblies/content_blocks/extra_data_cell.rb +2 -12
  4. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_settings_form/show.erb +1 -1
  5. data/app/commands/decidim/assemblies/admin/copy_assembly.rb +2 -47
  6. data/app/commands/decidim/assemblies/admin/create_assembly.rb +2 -2
  7. data/app/commands/decidim/assemblies/admin/import_assembly.rb +0 -2
  8. data/app/commands/decidim/assemblies/admin/update_assembly.rb +2 -2
  9. data/app/controllers/concerns/decidim/assemblies/admin/filterable.rb +2 -11
  10. data/app/controllers/decidim/assemblies/admin/assemblies_controller.rb +19 -4
  11. data/app/controllers/decidim/assemblies/admin/assembly_copies_controller.rb +1 -1
  12. data/app/controllers/decidim/assemblies/admin/assembly_share_tokens_controller.rb +18 -0
  13. data/app/controllers/decidim/assemblies/admin/component_share_tokens_controller.rb +18 -0
  14. data/app/controllers/decidim/assemblies/assemblies_controller.rb +2 -4
  15. data/app/controllers/decidim/assemblies/{assembly_members_controller.rb → participatory_space_private_users_controller.rb} +3 -11
  16. data/app/forms/decidim/assemblies/admin/assembly_copy_form.rb +0 -2
  17. data/app/forms/decidim/assemblies/admin/assembly_form.rb +5 -40
  18. data/app/forms/decidim/assemblies/admin/assembly_import_form.rb +0 -1
  19. data/app/helpers/decidim/assemblies/admin/assemblies_helper.rb +26 -4
  20. data/app/helpers/decidim/assemblies/assemblies_helper.rb +4 -4
  21. data/app/helpers/decidim/assemblies/filter_assemblies_helper.rb +11 -15
  22. data/app/models/decidim/assembly.rb +21 -11
  23. data/app/packs/entrypoints/decidim_assemblies_admin.js +0 -1
  24. data/app/packs/entrypoints/decidim_assemblies_admin_list.js +1 -0
  25. data/app/packs/src/decidim/assemblies/admin/assemblies_list.js +72 -0
  26. data/app/permissions/decidim/assemblies/permissions.rb +9 -26
  27. data/app/presenters/decidim/assemblies/admin_log/assembly_presenter.rb +1 -1
  28. data/app/presenters/decidim/assemblies/assembly_presenter.rb +0 -6
  29. data/app/queries/decidim/assemblies/metrics/assemblies_metric_manage.rb +2 -2
  30. data/app/serializers/decidim/assemblies/assembly_importer.rb +0 -35
  31. data/app/serializers/decidim/assemblies/assembly_serializer.rb +11 -135
  32. data/app/serializers/decidim/assemblies/open_data_assembly_serializer.rb +59 -0
  33. data/app/views/decidim/assemblies/admin/assemblies/_assemblies_thead.html.erb +19 -0
  34. data/app/views/decidim/assemblies/admin/assemblies/_assembly_row.html.erb +101 -0
  35. data/app/views/decidim/assemblies/admin/assemblies/_form.html.erb +29 -41
  36. data/app/views/decidim/assemblies/admin/assemblies/index.html.erb +18 -92
  37. data/app/views/decidim/assemblies/admin/assemblies/index.js.erb +10 -0
  38. data/app/views/decidim/assemblies/admin/assemblies/manage_trash.html.erb +20 -0
  39. data/app/views/decidim/assemblies/admin/assembly_copies/_form.html.erb +0 -7
  40. data/app/views/decidim/assemblies/admin/assembly_imports/_form.html.erb +0 -3
  41. data/app/views/decidim/assemblies/assemblies/index.html.erb +3 -1
  42. data/app/views/decidim/assemblies/assemblies/show.html.erb +5 -6
  43. data/app/views/decidim/assemblies/{assembly_members → participatory_space_private_users}/index.html.erb +6 -5
  44. data/config/assets.rb +2 -1
  45. data/config/locales/ar.yml +0 -72
  46. data/config/locales/bg.yml +0 -74
  47. data/config/locales/bs-BA.yml +0 -15
  48. data/config/locales/ca.yml +70 -74
  49. data/config/locales/cs.yml +70 -74
  50. data/config/locales/de.yml +70 -74
  51. data/config/locales/el.yml +0 -72
  52. data/config/locales/en.yml +71 -75
  53. data/config/locales/es-MX.yml +70 -74
  54. data/config/locales/es-PY.yml +70 -74
  55. data/config/locales/es.yml +70 -74
  56. data/config/locales/eu.yml +74 -78
  57. data/config/locales/fi-plain.yml +71 -75
  58. data/config/locales/fi.yml +71 -75
  59. data/config/locales/fr-CA.yml +22 -74
  60. data/config/locales/fr.yml +22 -74
  61. data/config/locales/ga-IE.yml +0 -25
  62. data/config/locales/gl.yml +1 -73
  63. data/config/locales/he-IL.yml +8 -60
  64. data/config/locales/hu.yml +0 -74
  65. data/config/locales/id-ID.yml +0 -63
  66. data/config/locales/is-IS.yml +0 -48
  67. data/config/locales/it.yml +1 -144
  68. data/config/locales/ja.yml +70 -74
  69. data/config/locales/kaa.yml +0 -9
  70. data/config/locales/ko.yml +0 -6
  71. data/config/locales/lb.yml +0 -70
  72. data/config/locales/lt.yml +0 -72
  73. data/config/locales/lv.yml +0 -74
  74. data/config/locales/nl.yml +0 -72
  75. data/config/locales/no.yml +0 -72
  76. data/config/locales/pl.yml +0 -75
  77. data/config/locales/pt-BR.yml +0 -74
  78. data/config/locales/pt.yml +0 -152
  79. data/config/locales/ro-RO.yml +14 -85
  80. data/config/locales/ru.yml +0 -60
  81. data/config/locales/sk.yml +0 -46
  82. data/config/locales/sl.yml +0 -54
  83. data/config/locales/sq-AL.yml +0 -77
  84. data/config/locales/sr-CS.yml +0 -15
  85. data/config/locales/sv.yml +71 -75
  86. data/config/locales/tr-TR.yml +0 -75
  87. data/config/locales/uk.yml +0 -60
  88. data/config/locales/zh-CN.yml +0 -74
  89. data/config/locales/zh-TW.yml +0 -72
  90. data/db/migrate/20190215093700_reset_negative_children_count_counters.rb +2 -2
  91. data/db/migrate/20210310120444_add_followable_counter_cache_to_assemblies.rb +1 -1
  92. data/db/migrate/20240822161222_add_deleted_at_to_decidim_assemblies.rb +8 -0
  93. data/db/migrate/20241016101151_migrate_assembly_members_to_private_users.rb +53 -0
  94. data/db/migrate/20241108141651_remove_column_show_statistics_from_assemblies.rb +7 -0
  95. data/decidim-assemblies.gemspec +1 -1
  96. data/lib/decidim/api/assemblies_type_type.rb +2 -2
  97. data/lib/decidim/api/assembly_type.rb +32 -34
  98. data/lib/decidim/assemblies/admin_engine.rb +77 -54
  99. data/lib/decidim/assemblies/api.rb +0 -1
  100. data/lib/decidim/assemblies/content_blocks/registry_manager.rb +11 -0
  101. data/lib/decidim/assemblies/engine.rb +9 -3
  102. data/lib/decidim/assemblies/menu.rb +9 -22
  103. data/lib/decidim/assemblies/participatory_space.rb +7 -3
  104. data/lib/decidim/assemblies/seeds.rb +9 -33
  105. data/lib/decidim/assemblies/test/factories.rb +15 -36
  106. data/lib/decidim/assemblies/version.rb +1 -1
  107. metadata +28 -49
  108. data/app/cells/decidim/assemblies/assembly_member/data.erb +0 -19
  109. data/app/cells/decidim/assemblies/assembly_member/name_and_position.erb +0 -11
  110. data/app/cells/decidim/assemblies/assembly_member/show.erb +0 -9
  111. data/app/cells/decidim/assemblies/assembly_member_cell.rb +0 -21
  112. data/app/commands/decidim/assemblies/admin/create_assembly_member.rb +0 -55
  113. data/app/commands/decidim/assemblies/admin/destroy_assembly_member.rb +0 -24
  114. data/app/commands/decidim/assemblies/admin/update_assembly_member.rb +0 -29
  115. data/app/controllers/concerns/decidim/assemblies/admin/assembly_members/filterable.rb +0 -39
  116. data/app/controllers/decidim/assemblies/admin/assemblies_types_controller.rb +0 -107
  117. data/app/controllers/decidim/assemblies/admin/assembly_members_controller.rb +0 -83
  118. data/app/controllers/decidim/assemblies/admin/categories_controller.rb +0 -13
  119. data/app/events/decidim/assemblies/create_assembly_member_event.rb +0 -17
  120. data/app/forms/decidim/assemblies/admin/assembly_member_form.rb +0 -64
  121. data/app/helpers/decidim/assemblies/admin/assembly_members_helper.rb +0 -11
  122. data/app/models/decidim/assembly_member.rb +0 -34
  123. data/app/packs/src/decidim/assemblies/admin/assembly_members.js +0 -47
  124. data/app/packs/src/decidim/assemblies/orgchart.js +0 -0
  125. data/app/presenters/decidim/admin/assembly_member_presenter.rb +0 -24
  126. data/app/presenters/decidim/assemblies/admin_log/assembly_member_presenter.rb +0 -51
  127. data/app/presenters/decidim/assemblies/admin_log/value_types/member_position_presenter.rb +0 -22
  128. data/app/presenters/decidim/assembly_member_presenter.rb +0 -68
  129. data/app/views/decidim/assemblies/admin/assemblies_types/_form.html.erb +0 -9
  130. data/app/views/decidim/assemblies/admin/assemblies_types/edit.html.erb +0 -13
  131. data/app/views/decidim/assemblies/admin/assemblies_types/index.html.erb +0 -44
  132. data/app/views/decidim/assemblies/admin/assemblies_types/new.html.erb +0 -18
  133. data/app/views/decidim/assemblies/admin/assembly_members/_form.html.erb +0 -62
  134. data/app/views/decidim/assemblies/admin/assembly_members/edit.html.erb +0 -18
  135. data/app/views/decidim/assemblies/admin/assembly_members/index.html.erb +0 -55
  136. data/app/views/decidim/assemblies/admin/assembly_members/new.html.erb +0 -18
  137. data/app/views/decidim/assembly_members/_assembly_member.html.erb +0 -1
  138. data/app/views/layouts/decidim/admin/assemblies_types.html.erb +0 -17
  139. data/config/locales/ca-IT.yml +0 -460
  140. data/lib/decidim/api/assembly_member_type.rb +0 -27
@@ -24,6 +24,7 @@ module Decidim
24
24
  include Decidim::HasAttachmentCollections
25
25
  include Decidim::Participable
26
26
  include Decidim::Publicable
27
+ include Decidim::Taxonomizable
27
28
  include Decidim::ScopableParticipatorySpace
28
29
  include Decidim::Followable
29
30
  include Decidim::HasReference
@@ -36,6 +37,8 @@ module Decidim
36
37
  include Decidim::TranslatableResource
37
38
  include Decidim::HasArea
38
39
  include Decidim::FilterableResource
40
+ include Decidim::SoftDeletable
41
+ include Decidim::ShareableWithToken
39
42
 
40
43
  CREATED_BY = %w(city_council public others).freeze
41
44
 
@@ -60,11 +63,6 @@ module Decidim
60
63
  dependent: :destroy,
61
64
  as: :participatory_space
62
65
 
63
- has_many :members,
64
- foreign_key: "decidim_assembly_id",
65
- class_name: "Decidim::AssemblyMember",
66
- dependent: :destroy
67
-
68
66
  has_many :components, as: :participatory_space, dependent: :destroy
69
67
 
70
68
  has_many :children, foreign_key: "parent_id", class_name: "Decidim::Assembly", inverse_of: :parent, dependent: :destroy
@@ -82,8 +80,6 @@ module Decidim
82
80
  after_create :set_parents_path
83
81
  after_update :set_parents_path, :update_children_paths, if: :saved_change_to_parent_id?
84
82
 
85
- scope :with_any_type, ->(*type_ids) { where(decidim_assemblies_type_id: type_ids) }
86
-
87
83
  searchable_fields({
88
84
  scope_id: :decidim_scope_id,
89
85
  participatory_space: :itself,
@@ -165,7 +161,23 @@ module Decidim
165
161
  end
166
162
 
167
163
  def self.ransackable_scopes(_auth_object = nil)
168
- [:with_any_area, :with_any_scope, :with_any_type]
164
+ [:with_any_taxonomies]
165
+ end
166
+
167
+ def shareable_url(share_token)
168
+ EngineRouter.main_proxy(self).assembly_url(self, share_token: share_token.token)
169
+ end
170
+
171
+ def self.ransackable_attributes(auth_object = nil)
172
+ base = %w(title short_description description id)
173
+
174
+ return base unless auth_object&.admin?
175
+
176
+ base + %w(published_at private_space parent_id)
177
+ end
178
+
179
+ def self.ransackable_associations(_auth_object = nil)
180
+ %w(parent children taxonomies)
169
181
  end
170
182
 
171
183
  private
@@ -186,7 +198,7 @@ module Decidim
186
198
  #
187
199
  # rubocop:disable Rails/SkipsModelValidations
188
200
  def set_parents_path
189
- update_column(:parents_path, [parent&.parents_path, id].select(&:present?).join("."))
201
+ update_column(:parents_path, [parent&.parents_path, id].compact_blank.join("."))
190
202
  end
191
203
  # rubocop:enable Rails/SkipsModelValidations
192
204
 
@@ -221,7 +233,5 @@ module Decidim
221
233
 
222
234
  # Allow ransacker to search for a key in a hstore column (`title`.`en`)
223
235
  ransacker_i18n :title
224
-
225
- ransack_alias :type_id, :decidim_assemblies_type_id
226
236
  end
227
237
  end
@@ -1,3 +1,2 @@
1
1
  import "src/decidim/assemblies/admin/assemblies"
2
- import "src/decidim/assemblies/admin/assembly_members"
3
2
  import "src/decidim/slug_form"
@@ -0,0 +1 @@
1
+ import "src/decidim/assemblies/admin/assemblies_list"
@@ -0,0 +1,72 @@
1
+ /* eslint-disable require-jsdoc */
2
+
3
+ class AdminAssembliesListComponent {
4
+ run() {
5
+ this.rebindArrows();
6
+ }
7
+
8
+ rebindArrows() {
9
+ this.unbindArrows();
10
+ this.bindArrows();
11
+ }
12
+
13
+ bindArrows() {
14
+ document.querySelectorAll("[data-arrow-up]").forEach((element) => {
15
+ element.addEventListener("click", this._onClickUpArrow);
16
+ });
17
+ document.querySelectorAll("[data-arrow-down]").forEach((element) => {
18
+ element.addEventListener("click", this._onClickDownArrow);
19
+ });
20
+ }
21
+
22
+ unbindArrows() {
23
+ document.querySelectorAll("[data-arrow-up]").forEach((element) => {
24
+ element.removeEventListener("click", this._onClickUpArrow);
25
+ });
26
+ document.querySelectorAll("[data-arrow-down]").forEach((element) => {
27
+ element.removeEventListener("click", this._onClickDownArrow);
28
+ });
29
+ }
30
+
31
+ _onClickDownArrow(event) {
32
+ event.preventDefault();
33
+
34
+ const target = event.currentTarget;
35
+ const assembly = target.closest("[data-assembly-id]");
36
+ const upArrow = assembly.querySelector("[data-arrow-up]");
37
+
38
+ target.classList.toggle("hidden");
39
+ upArrow.classList.toggle("hidden");
40
+ }
41
+
42
+ _onClickUpArrow(event) {
43
+ event.preventDefault();
44
+
45
+ const target = event.currentTarget;
46
+ const assembly = target.closest("[data-assembly-id]");
47
+ const parentLevel = assembly.dataset.level;
48
+ const downArrow = assembly.querySelector("[data-arrow-down]");
49
+
50
+ target.classList.toggle("hidden");
51
+ downArrow.classList.toggle("hidden");
52
+
53
+ // Get all following tr elements
54
+ let nextElement = assembly.nextElementSibling;
55
+ while (nextElement) {
56
+ const currentLevel = nextElement.dataset.level;
57
+ const nextSibling = nextElement.nextElementSibling;
58
+
59
+ if (currentLevel > parentLevel) {
60
+ nextElement.remove();
61
+ } else {
62
+ break;
63
+ }
64
+ nextElement = nextSibling;
65
+ }
66
+ }
67
+ }
68
+
69
+ window.Decidim.AdminAssembliesListComponent = AdminAssembliesListComponent;
70
+ const component = new AdminAssembliesListComponent();
71
+
72
+ component.run();
@@ -34,11 +34,9 @@ module Decidim
34
34
  user_can_create_assembly?
35
35
  user_can_export_assembly?
36
36
  user_can_copy_assembly?
37
- user_can_upload_images_in_assembly?
38
37
 
39
38
  # org admins and space admins can do everything in the admin section
40
39
  org_admin_action?
41
- assemblies_type_action?
42
40
 
43
41
  return permission_action unless assembly
44
42
 
@@ -61,21 +59,6 @@ module Decidim
61
59
  toggle_allow(user.admin? || can_manage_assembly?(role: :admin) || can_manage_assembly?(role: :collaborator))
62
60
  end
63
61
 
64
- def assemblies_type_action?
65
- return unless [:assembly_type, :assemblies_type].include? permission_action.subject
66
- return disallow! unless user.admin?
67
-
68
- assembly_type = context.fetch(:assembly_type, nil)
69
- case permission_action.action
70
- when :destroy
71
- assemblies_is_empty = assembly_type && assembly_type.assemblies.empty?
72
-
73
- toggle_allow(assemblies_is_empty)
74
- else
75
- allow!
76
- end
77
- end
78
-
79
62
  # It is an admin user if it is an organization admin or is a space admin
80
63
  # for the current `assembly`.
81
64
  def admin_user?
@@ -127,6 +110,7 @@ module Decidim
127
110
  return disallow! unless can_view_private_space?
128
111
  return allow! if user&.admin?
129
112
  return allow! if assembly.published?
113
+ return allow! if user_can_preview_space?
130
114
 
131
115
  toggle_allow(can_manage_assembly?)
132
116
  end
@@ -259,14 +243,13 @@ module Decidim
259
243
  is_allowed = [
260
244
  :attachment,
261
245
  :attachment_collection,
262
- :category,
263
246
  :component,
264
247
  :component_data,
265
248
  :moderation,
266
249
  :assembly,
267
250
  :assembly_user_role,
268
- :assembly_member,
269
251
  :export_space,
252
+ :share_tokens,
270
253
  :import
271
254
  ].include?(permission_action.subject)
272
255
  allow! if is_allowed
@@ -278,19 +261,24 @@ module Decidim
278
261
  is_allowed = [
279
262
  :attachment,
280
263
  :attachment_collection,
281
- :category,
282
264
  :component,
283
265
  :component_data,
284
266
  :moderation,
285
267
  :assembly,
286
268
  :assembly_user_role,
287
- :assembly_member,
288
269
  :export_space,
270
+ :share_tokens,
289
271
  :import
290
272
  ].include?(permission_action.subject)
291
273
  allow! if is_allowed
292
274
  end
293
275
 
276
+ def user_can_preview_space?
277
+ context[:share_token].present? && Decidim::ShareToken.use!(token_for: assembly, token: context[:share_token], user:)
278
+ rescue ActiveRecord::RecordNotFound, StandardError
279
+ nil
280
+ end
281
+
294
282
  # Checks if the permission_action is to read the admin assemblies list or
295
283
  # not.
296
284
  def read_assembly_list_permission_action?
@@ -315,11 +303,6 @@ module Decidim
315
303
  Decidim::Assembly.where(id: assemblies + child_assemblies)
316
304
  end
317
305
  end
318
-
319
- # Checks if the assigned admins can upload images on the editor
320
- def user_can_upload_images_in_assembly?
321
- allow! if user&.admin_terms_accepted? && user_has_any_role?(user, assembly, broad_check: true) && (permission_action.subject == :editor_image)
322
- end
323
306
  end
324
307
  end
325
308
  end
@@ -62,7 +62,7 @@ module Decidim
62
62
 
63
63
  def action_string
64
64
  case action
65
- when "create", "publish", "unpublish", "update", "duplicate", "export", "import"
65
+ when "create", "publish", "unpublish", "update", "duplicate", "export", "import", "soft_delete", "restore"
66
66
  "decidim.admin_log.assembly.#{action}"
67
67
  else
68
68
  super
@@ -37,12 +37,6 @@ module Decidim
37
37
  formatted_date(date)
38
38
  end
39
39
 
40
- def assembly_type
41
- return if assembly.assembly_type.blank?
42
-
43
- translated_attribute(assembly.assembly_type.title)
44
- end
45
-
46
40
  def formatted_date(date)
47
41
  return if date.blank?
48
42
 
@@ -14,12 +14,12 @@ module Decidim
14
14
  return @query if @query
15
15
 
16
16
  @query = Decidim::Assembly.where(organization: @organization)
17
- @query = @query.where("decidim_assemblies.published_at <= ?", end_time)
17
+ @query = @query.where(decidim_assemblies: { published_at: ..end_time })
18
18
  @query
19
19
  end
20
20
 
21
21
  def quantity
22
- @quantity ||= query.where("decidim_assemblies.published_at >= ?", start_time).count
22
+ @quantity ||= query.where(decidim_assemblies: { published_at: start_time.. }).count
23
23
  end
24
24
  end
25
25
  end
@@ -36,14 +36,12 @@ module Decidim
36
36
  target: attributes["target"],
37
37
  participatory_scope: attributes["participatory_scope"],
38
38
  participatory_structure: attributes["participatory_structure"],
39
- scopes_enabled: attributes["scopes_enabled"],
40
39
  private_space: attributes["private_space"],
41
40
  reference: attributes["reference"],
42
41
  purpose_of_action: attributes["purpose_of_action"],
43
42
  composition: attributes["composition"],
44
43
  duration: attributes["duration"],
45
44
  creation_date: attributes["creation_date"],
46
- decidim_scope_id: attributes["decidim_scope_id"],
47
45
  closing_date_reason: attributes["closing_date_reason"],
48
46
  included_at: attributes["included_at"],
49
47
  closing_date: attributes["closing_date"],
@@ -68,39 +66,6 @@ module Decidim
68
66
  end
69
67
  end
70
68
 
71
- def import_assemblies_type(type_id)
72
- return if Decidim::AssembliesType.find_by(id: type_id).nil?
73
-
74
- @imported_assembly.decidim_assemblies_type_id = type_id
75
- end
76
-
77
- def import_categories(categories)
78
- return if categories.nil?
79
-
80
- categories.map do |category_attributes|
81
- category = Decidim.traceability.create!(
82
- Category,
83
- @user,
84
- name: category_attributes["name"],
85
- description: category_attributes["description"],
86
- parent_id: category_attributes["parent_id"],
87
- participatory_space: @imported_assembly
88
- )
89
- next if category_attributes["subcategories"].nil?
90
-
91
- category_attributes["subcategories"].map do |subcategory_attributes|
92
- Decidim.traceability.create!(
93
- Category,
94
- @user,
95
- name: subcategory_attributes["name"],
96
- description: subcategory_attributes["description"],
97
- parent_id: category.id,
98
- participatory_space: @imported_assembly
99
- )
100
- end
101
- end
102
- end
103
-
104
69
  def import_folders_and_attachments(attachments)
105
70
  return if attachments["files"].nil?
106
71
 
@@ -3,146 +3,22 @@
3
3
  module Decidim
4
4
  module Assemblies
5
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 an Assembly instance.
12
- def initialize(assembly)
13
- @assembly = assembly
14
- end
15
-
6
+ class AssemblySerializer < Decidim::Assemblies::OpenDataAssemblySerializer
16
7
  # Public: Exports a hash with the serialized data for this assembly.
17
8
  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
- weight: assembly.weight,
26
- short_description: assembly.short_description,
27
- description: assembly.description,
28
- remote_hero_image_url: Decidim::Assemblies::AssemblyPresenter.new(assembly).hero_image_url,
29
- remote_banner_image_url: Decidim::Assemblies::AssemblyPresenter.new(assembly).banner_image_url,
30
- promoted: assembly.promoted,
31
- developer_group: assembly.developer_group,
32
- meta_scope: assembly.meta_scope,
33
- local_area: assembly.local_area,
34
- target: assembly.target,
35
- decidim_scope_id: assembly.decidim_scope_id,
36
- paticipatory_scope: assembly.participatory_scope, # intentionally misspelled
37
- participatory_structure: assembly.participatory_structure,
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
- announcement: assembly.announcement
76
- }
77
- end
78
-
79
- private
80
-
81
- attr_reader :assembly
82
- alias resource assembly
83
-
84
- def serialize_categories
85
- return unless assembly.categories.first_class.any?
86
-
87
- assembly.categories.first_class.map do |category|
88
- {
89
- id: category.try(:id),
90
- name: category.try(:name),
91
- description: category.try(:description),
92
- parent_id: category.try(:parent_id),
93
- subcategories: serialize_subcategories(category.subcategories)
94
- }
95
- end
96
- end
97
-
98
- def serialize_subcategories(subcategories)
99
- return unless subcategories.any?
100
-
101
- subcategories.map do |subcategory|
9
+ super.merge(
102
10
  {
103
- id: subcategory.try(:id),
104
- name: subcategory.try(:name),
105
- description: subcategory.try(:description),
106
- parent_id: subcategory.try(:parent_id)
107
- }
108
- end
109
- end
110
-
111
- def serialize_attachment_collections
112
- return unless assembly.attachment_collections.any?
113
-
114
- assembly.attachment_collections.map do |collection|
115
- {
116
- id: collection.try(:id),
117
- name: collection.try(:name),
118
- weight: collection.try(:weight),
119
- description: collection.try(:description)
120
- }
121
- end
122
- end
123
-
124
- def serialize_attachments
125
- return unless assembly.attachments.any?
126
-
127
- assembly.attachments.map do |attachment|
128
- {
129
- id: attachment.try(:id),
130
- title: attachment.try(:title),
131
- weight: attachment.try(:weight),
132
- description: attachment.try(:description),
133
- attachment_collection: {
134
- name: attachment.attachment_collection.try(:name),
135
- weight: attachment.attachment_collection.try(:weight),
136
- description: attachment.attachment_collection.try(:description)
11
+ categories: serialize_categories,
12
+ taxonomies:,
13
+ attachments: {
14
+ attachment_collections: serialize_attachment_collections,
15
+ files: serialize_attachments
137
16
  },
138
- remote_file_url: Decidim::AttachmentPresenter.new(attachment).attachment_file_url
17
+ private_space: resource.private_space,
18
+ weight: resource.weight,
19
+ components: serialize_components
139
20
  }
140
- end
141
- end
142
-
143
- def serialize_components
144
- serializer = Decidim::Exporters::ParticipatorySpaceComponentsSerializer.new(@assembly)
145
- serializer.run
21
+ )
146
22
  end
147
23
  end
148
24
  end
@@ -0,0 +1,59 @@
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 for the Open Data feature.
6
+ class OpenDataAssemblySerializer < Decidim::Exporters::ParticipatorySpaceSerializer
7
+ # Public: Exports a hash with the serialized data for this assembly.
8
+ #
9
+ def serialize
10
+ super.merge(
11
+ {
12
+ url: EngineRouter.main_proxy(resource).assembly_url(resource),
13
+ subtitle: resource.subtitle,
14
+ remote_hero_image_url: Decidim::ParticipatoryProcesses::ParticipatoryProcessPresenter.new(resource).hero_image_url,
15
+ remote_banner_image_url: Decidim::Assemblies::AssemblyPresenter.new(resource).banner_image_url,
16
+ announcement: resource.announcement,
17
+ developer_group: resource.developer_group,
18
+ local_area: resource.local_area,
19
+ meta_scope: resource.meta_scope,
20
+ participatory_scope: resource.participatory_scope,
21
+ purpose_of_action: resource.purpose_of_action,
22
+ composition: resource.composition,
23
+ duration: resource.duration,
24
+ participatory_structure: resource.participatory_structure,
25
+ target: resource.target,
26
+ decidim_scope_id: resource.decidim_scope_id,
27
+ area: {
28
+ id: resource.area.try(:id),
29
+ name: resource.area.try(:name) || empty_translatable
30
+ },
31
+ scope: {
32
+ id: resource.scope.try(:id),
33
+ name: resource.scope.try(:name) || empty_translatable
34
+ },
35
+ scopes_enabled: resource.scopes_enabled,
36
+ included_at: resource.included_at,
37
+ closing_date: resource.closing_date,
38
+ created_by: resource.created_by,
39
+ creation_date: resource.creation_date,
40
+ closing_date_reason: resource.closing_date_reason,
41
+ internal_organisation: resource.internal_organisation,
42
+ is_transparent: resource.is_transparent,
43
+ special_features: resource.special_features,
44
+ twitter_handler: resource.twitter_handler,
45
+ instagram_handler: resource.instagram_handler,
46
+ facebook_handler: resource.facebook_handler,
47
+ youtube_handler: resource.youtube_handler,
48
+ github_handler: resource.github_handler,
49
+ created_by_other: resource.created_by_other,
50
+ assembly_type: {
51
+ id: resource.assembly_type.try(:id),
52
+ title: resource.assembly_type.try(:title) || empty_translatable
53
+ }
54
+ }
55
+ )
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,19 @@
1
+ <thead>
2
+ <tr>
3
+ <th>
4
+ <%= sort_link(query, :title, t("models.assembly.fields.title", scope: "decidim.admin")) %>
5
+ </th>
6
+ <th>
7
+ <%= sort_link(query, :created_at, t("models.assembly.fields.created_at", scope: "decidim.admin"), default_order: :desc) %>
8
+ </th>
9
+ <th>
10
+ <%= sort_link(query, :private_space, t("models.assembly.fields.private", scope: "decidim.admin")) %>
11
+ </th>
12
+ <th class="table-list__actions">
13
+ <%= sort_link(query, :published_at, t("models.assembly.fields.published", scope: "decidim.admin")) %>
14
+ </th>
15
+ <th>
16
+ <%= t("models.assembly.fields.actions", scope: "decidim.admin") %>
17
+ </th>
18
+ </tr>
19
+ </thead>