decidim-assemblies 0.29.2 → 0.30.0.rc2

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 (139) 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 -14
  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 +1 -3
  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 -1
  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 -20
  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 -4
  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 +71 -75
  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 +0 -72
  63. data/config/locales/he-IL.yml +8 -57
  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 -45
  67. data/config/locales/it.yml +0 -73
  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 -72
  79. data/config/locales/ro-RO.yml +14 -85
  80. data/config/locales/ru.yml +0 -57
  81. data/config/locales/sk.yml +0 -46
  82. data/config/locales/sl.yml +0 -54
  83. data/config/locales/sq-AL.yml +0 -74
  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 -57
  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 -48
  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/lib/decidim/api/assembly_member_type.rb +0 -27
@@ -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();
@@ -37,7 +37,6 @@ module Decidim
37
37
 
38
38
  # org admins and space admins can do everything in the admin section
39
39
  org_admin_action?
40
- assemblies_type_action?
41
40
 
42
41
  return permission_action unless assembly
43
42
 
@@ -60,21 +59,6 @@ module Decidim
60
59
  toggle_allow(user.admin? || can_manage_assembly?(role: :admin) || can_manage_assembly?(role: :collaborator))
61
60
  end
62
61
 
63
- def assemblies_type_action?
64
- return unless [:assembly_type, :assemblies_type].include? permission_action.subject
65
- return disallow! unless user.admin?
66
-
67
- assembly_type = context.fetch(:assembly_type, nil)
68
- case permission_action.action
69
- when :destroy
70
- assemblies_is_empty = assembly_type && assembly_type.assemblies.empty?
71
-
72
- toggle_allow(assemblies_is_empty)
73
- else
74
- allow!
75
- end
76
- end
77
-
78
62
  # It is an admin user if it is an organization admin or is a space admin
79
63
  # for the current `assembly`.
80
64
  def admin_user?
@@ -126,6 +110,7 @@ module Decidim
126
110
  return disallow! unless can_view_private_space?
127
111
  return allow! if user&.admin?
128
112
  return allow! if assembly.published?
113
+ return allow! if user_can_preview_space?
129
114
 
130
115
  toggle_allow(can_manage_assembly?)
131
116
  end
@@ -258,14 +243,13 @@ module Decidim
258
243
  is_allowed = [
259
244
  :attachment,
260
245
  :attachment_collection,
261
- :category,
262
246
  :component,
263
247
  :component_data,
264
248
  :moderation,
265
249
  :assembly,
266
250
  :assembly_user_role,
267
- :assembly_member,
268
251
  :export_space,
252
+ :share_tokens,
269
253
  :import
270
254
  ].include?(permission_action.subject)
271
255
  allow! if is_allowed
@@ -277,19 +261,24 @@ module Decidim
277
261
  is_allowed = [
278
262
  :attachment,
279
263
  :attachment_collection,
280
- :category,
281
264
  :component,
282
265
  :component_data,
283
266
  :moderation,
284
267
  :assembly,
285
268
  :assembly_user_role,
286
- :assembly_member,
287
269
  :export_space,
270
+ :share_tokens,
288
271
  :import
289
272
  ].include?(permission_action.subject)
290
273
  allow! if is_allowed
291
274
  end
292
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
+
293
282
  # Checks if the permission_action is to read the admin assemblies list or
294
283
  # not.
295
284
  def read_assembly_list_permission_action?
@@ -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>
@@ -0,0 +1,101 @@
1
+ <tr data-assembly-id="<%= assembly.id %>" data-parent-id="<%= assembly.parent_id %>" data-level="<%= assembly.ancestors.count %>">
2
+ <td class="whitespace-nowrap">
3
+ <% if parent_assembly_id %>
4
+ <% [assembly.ancestors.count - 1, 0].max.times do |index| %>
5
+ <span class="px-3"></span>
6
+ <% end %>
7
+ <span class="px-3 text-xl text-secondary opacity-10">|</span>
8
+ <% end %>
9
+
10
+ <% if assembly.promoted? %>
11
+ <%= icon_with_tooltip "star-s-fill", t("models.assembly.fields.promoted", scope: "decidim.admin") %>
12
+ <% end %>
13
+
14
+ <span class="table-list__title-ellipsis">
15
+ <% if allowed_to? :update, :assembly, assembly: assembly %>
16
+ <%= link_to translated_attribute(assembly.title), edit_assembly_path(assembly) %>
17
+ <% elsif allowed_to? :read, :component, assembly: assembly %>
18
+ <%= link_to translated_attribute(assembly.title), components_path(assembly) %><br>
19
+ <% else %>
20
+ <%= translated_attribute(assembly.title) %>
21
+ <% end %>
22
+ </span>
23
+
24
+ <% if assembly.children.count.positive? %>
25
+ <%= link_to url_for(query_params_with(parent_id_eq: assembly.id)), remote: true, data: { arrow_down: true } do %>
26
+ <%= icon "arrow-down-s-line", class: "w-4 h-4 ml-2" %>
27
+ <% end %>
28
+ <%= link_to "#", class: "hidden", data: { arrow_up: true } do %>
29
+ <%= icon "arrow-up-s-line", class: "w-4 h-4 ml-2" %>
30
+ <% end %>
31
+ <% end %>
32
+ </td>
33
+ <td class="table-list__date">
34
+ <%= l(assembly.created_at, format: :short) %>
35
+ </td>
36
+ <td class="table-list__state">
37
+ <% if assembly.private_space? %>
38
+ <span><%= t("assemblies.index.private", scope: "decidim.admin") %></span>
39
+ <% else %>
40
+ <span><%= t("assemblies.index.public", scope: "decidim.admin") %></span>
41
+ <% end %>
42
+ </td>
43
+ <td class="table-list__state">
44
+ <% if assembly.published? %>
45
+ <span class="label success !text-sm"><%= t("assemblies.index.published", scope: "decidim.admin") %></span>
46
+ <% else %>
47
+ <span class="label alert !text-sm"><%= t("assemblies.index.unpublished", scope: "decidim.admin") %></span>
48
+ <% end %>
49
+ </td>
50
+ <td class="table-list__actions">
51
+ <% if view == :deleted %>
52
+ <% if allowed_to? :restore, :assembly, trashable_deleted_resource: assembly %>
53
+ <%= icon_link_to "refresh-line", restore_assembly_path(assembly), t("actions.restore", scope: "decidim.admin"), method: :patch, class: "action-icon--restore" %>
54
+ <% else %>
55
+ <span class="action-space icon"></span>
56
+ <% end %>
57
+ <% else %>
58
+ <% if allowed_to? :read, :share_tokens, current_participatory_space: assembly %>
59
+ <%= icon_link_to "share-line", decidim_admin_assemblies.assembly_share_tokens_path(assembly), t("actions.share_tokens", scope: "decidim.admin"), class: "action-icon--new" %>
60
+ <% else %>
61
+ <span class="action-space icon"></span>
62
+ <% end %>
63
+ <% if allowed_to? :update, :assembly, assembly: assembly %>
64
+ <%= icon_link_to "pencil-line", edit_assembly_path(assembly), t("actions.configure", scope: "decidim.admin"), class: "action-icon--new" %>
65
+ <% else %>
66
+ <span class="action-space icon"></span>
67
+ <% end %>
68
+ <% if allowed_to? :copy, :assembly, assembly: assembly, assembly: parent_assembly %>
69
+ <%= icon_link_to "file-copy-line", new_assembly_copy_path(assembly), t("actions.duplicate", scope: "decidim.admin"), class: "action-icon--copy" %>
70
+ <% else %>
71
+ <span class="action-space icon"></span>
72
+ <% end %>
73
+
74
+ <% if allowed_to? :export, :assembly, assembly: assembly %>
75
+ <%= icon_link_to "download-line", assembly_export_path(assembly), t("actions.export", scope: "decidim.admin"), method: :post, class: "action-icon--export" %>
76
+ <% else %>
77
+ <span class="action-space icon"></span>
78
+ <% end %>
79
+
80
+ <% if allowed_to? :preview, :assembly, assembly: assembly %>
81
+ <%= icon_link_to "eye-line", decidim_assemblies.assembly_path(assembly), t("actions.preview", scope: "decidim.admin"), class: "action-icon--preview", target: "_blank", data: { "external-link": false } %>
82
+ <% else %>
83
+ <span class="action-space icon"></span>
84
+ <% end %>
85
+
86
+ <% if allowed_to? :read, :moderation, assembly: assembly %>
87
+ <%= icon_link_to "flag-line", moderations_path(assembly), t("actions.moderate", scope: "decidim.admin"), class: "action-icon--moderate" %>
88
+ <% else %>
89
+ <span class="action-space icon"></span>
90
+ <% end %>
91
+
92
+ <% if allowed_to? :soft_delete, :assembly, trashable_deleted_resource: assembly %>
93
+ <% if assembly.published? %>
94
+ <%= icon "delete-bin-line", class: "action-icon action-icon--disabled", role: "img", aria_label: t("actions.soft_delete", scope: "decidim.admin") %>
95
+ <% else %>
96
+ <%= icon_link_to "delete-bin-line", soft_delete_assembly_path(assembly), t("actions.soft_delete", scope: "decidim.admin"), method: :patch, class: "action-icon--delete", data: { confirm: t("actions.confirm_delete_assembly", scope: "decidim.admin") } %>
97
+ <% end %>
98
+ <% end %>
99
+ <% end %>
100
+ </td>
101
+ </tr>