decidim-assemblies 0.29.2 → 0.30.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
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 +1 -72
  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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b74ba273556ca0e94a759cbd5113716342eba68ac7f4ec0b259ae563167b3fb8
4
- data.tar.gz: 9e44b00be96f1fe4c7a22558cea599aff5c40a681f1d506fae075cc00ed15fa1
3
+ metadata.gz: 767f537492079cef350fbb6cd63781248da90014557aa25b9e089a0934f31a96
4
+ data.tar.gz: 376a7609207d2dee4fb10182413c8283718bf273b38771ff95729374f3467edf
5
5
  SHA512:
6
- metadata.gz: ae74d4d6e9ca6b7e1b50793ad96902846ae0cae14077cfded2e60fe85872c33c132d64c6e4a70d676fe430e3496facfaacfab77dd97fd9474dab5b19829d5ca1
7
- data.tar.gz: 0fcb0bf1dcef6daec9b9f7d2c535a4733de1ca7b961ff56ced152cc68313a28e030e63e5331c0a6b51e448b6da2f0e39549308bc8baf894524fa230438038a48
6
+ metadata.gz: 88b2b02713d50f6e1e47d636d3f30408f17f2ba2d673a8d512829b1b6fe117829f6fb7321cebc3e2c8844af479874d1cf4739592f019488cfe0b66b61a58fbd6
7
+ data.tar.gz: da1c1a75ec045d6909f035470cdb2274bc640b913bd40589c4957e0b3b7104f74c71ea2aa67594a58fba756b3c51b65cd30bd3a26b24d69ac6125436f5259247
@@ -9,16 +9,7 @@ module Decidim
9
9
  private
10
10
 
11
11
  def items
12
- [children_item, assembly_type].compact
13
- end
14
-
15
- def assembly_type
16
- return unless has_assembly_type?
17
-
18
- {
19
- text: translated_attribute(model.assembly_type.title),
20
- icon: "group-2-line"
21
- }
12
+ [children_item].compact
22
13
  end
23
14
 
24
15
  def children_item
@@ -37,10 +28,6 @@ module Decidim
37
28
  def published_children_assemblies
38
29
  @published_children_assemblies ||= model.children.published
39
30
  end
40
-
41
- def has_assembly_type?
42
- model.assembly_type.present?
43
- end
44
31
  end
45
32
  end
46
33
  end
@@ -4,28 +4,18 @@ module Decidim
4
4
  module Assemblies
5
5
  module ContentBlocks
6
6
  class ExtraDataCell < Decidim::ContentBlocks::ParticipatorySpaceExtraDataCell
7
- delegate :assembly_type, :duration, to: :presented_resource
7
+ delegate :duration, to: :presented_resource
8
8
 
9
9
  private
10
10
 
11
11
  def extra_data_items
12
- [type_item, duration_item].compact
12
+ [duration_item].compact
13
13
  end
14
14
 
15
15
  def presented_resource
16
16
  Decidim::Assemblies::AssemblyPresenter.new(resource)
17
17
  end
18
18
 
19
- def type_item
20
- return if assembly_type.blank?
21
-
22
- {
23
- title: t("assembly_type", scope: "decidim.assemblies.show"),
24
- icon: "group-2-line",
25
- text: decidim_sanitize_translated(assembly_type)
26
- }
27
- end
28
-
29
19
  def duration_item
30
20
  {
31
21
  title: t("duration", scope: "decidim.assemblies.show"),
@@ -1,3 +1,3 @@
1
1
  <% form.fields_for :settings, form.object.settings do |settings_fields| %>
2
- <%= settings_fields.select :max_results, [6, 9, 12], prompt: "", label: %>
2
+ <%= settings_fields.number_field :max_results, label: %>
3
3
  <% end %>
@@ -29,7 +29,6 @@ module Decidim
29
29
  Assembly.transaction do
30
30
  copy_assembly
31
31
  copy_assembly_attachments
32
- copy_assembly_categories if @form.copy_categories?
33
32
  copy_assembly_components if @form.copy_components?
34
33
  end
35
34
  end
@@ -51,7 +50,6 @@ module Decidim
51
50
  description: @assembly.description,
52
51
  short_description: @assembly.short_description,
53
52
  promoted: @assembly.promoted,
54
- scope: @assembly.scope,
55
53
  parent: @assembly.parent,
56
54
  developer_group: @assembly.developer_group,
57
55
  local_area: @assembly.local_area,
@@ -60,7 +58,8 @@ module Decidim
60
58
  participatory_scope: @assembly.participatory_scope,
61
59
  participatory_structure: @assembly.participatory_structure,
62
60
  meta_scope: @assembly.meta_scope,
63
- announcement: @assembly.announcement
61
+ announcement: @assembly.announcement,
62
+ taxonomies: @assembly.taxonomies
64
63
  )
65
64
  end
66
65
 
@@ -72,17 +71,6 @@ module Decidim
72
71
  end
73
72
  end
74
73
 
75
- def copy_assembly_categories
76
- @assembly.categories.each do |category|
77
- Category.create!(
78
- name: category.name,
79
- description: category.description,
80
- parent_id: category.parent_id,
81
- participatory_space: @copied_assembly
82
- )
83
- end
84
- end
85
-
86
74
  def copy_assembly_components
87
75
  @assembly.components.each do |component|
88
76
  new_component = Component.create!(
@@ -9,10 +9,10 @@ module Decidim
9
9
  fetch_file_attributes :hero_image, :banner_image
10
10
 
11
11
  fetch_form_attributes :title, :subtitle, :weight, :slug, :hashtag, :description, :short_description,
12
- :promoted, :scopes_enabled, :scope, :area, :parent, :announcement, :organization,
12
+ :promoted, :taxonomizations, :parent, :announcement, :organization,
13
13
  :private_space, :developer_group, :local_area, :target, :participatory_scope,
14
14
  :participatory_structure, :meta_scope, :purpose_of_action,
15
- :composition, :assembly_type, :creation_date, :created_by, :created_by_other,
15
+ :composition, :creation_date, :created_by, :created_by_other,
16
16
  :duration, :included_at, :closing_date, :closing_date_reason, :internal_organisation,
17
17
  :is_transparent, :special_features, :twitter_handler, :facebook_handler,
18
18
  :instagram_handler, :youtube_handler, :github_handler
@@ -41,8 +41,6 @@ module Decidim
41
41
  assemblies.each do |original_assembly|
42
42
  Decidim.traceability.perform_action!("import", Assembly, @user) do
43
43
  @imported_assembly = importer.import(original_assembly, form.current_user, title: form.title, slug: form.slug)
44
- importer.import_assemblies_type(original_assembly["decidim_assemblies_type_id"])
45
- importer.import_categories(original_assembly["assembly_categories"]) if form.import_categories?
46
44
  importer.import_folders_and_attachments(original_assembly["attachments"]) if form.import_attachments?
47
45
  importer.import_components(original_assembly["components"]) if form.import_components?
48
46
  @imported_assembly
@@ -9,9 +9,9 @@ module Decidim
9
9
  fetch_file_attributes :hero_image, :banner_image
10
10
 
11
11
  fetch_form_attributes :title, :subtitle, :slug, :hashtag, :promoted, :description, :short_description,
12
- :scopes_enabled, :scope, :area, :parent, :private_space, :developer_group, :local_area,
12
+ :taxonomizations, :parent, :private_space, :developer_group, :local_area,
13
13
  :target, :participatory_scope, :participatory_structure, :meta_scope,
14
- :purpose_of_action, :composition, :assembly_type, :creation_date, :created_by,
14
+ :purpose_of_action, :composition, :creation_date, :created_by,
15
15
  :created_by_other, :duration, :included_at, :closing_date, :closing_date_reason,
16
16
  :internal_organisation, :is_transparent, :special_features, :twitter_handler, :announcement,
17
17
  :facebook_handler, :instagram_handler, :youtube_handler, :github_handler, :weight
@@ -25,24 +25,15 @@ module Decidim
25
25
  end
26
26
 
27
27
  def filters
28
- [:private_space_eq, :published_at_null, :decidim_assemblies_type_id_eq]
28
+ [:private_space_eq, :published_at_null]
29
29
  end
30
30
 
31
31
  def filters_with_values
32
32
  {
33
33
  private_space_eq: [true, false],
34
- published_at_null: [true, false],
35
- decidim_assemblies_type_id_eq: AssembliesType.where(organization: current_organization).pluck(:id)
34
+ published_at_null: [true, false]
36
35
  }
37
36
  end
38
-
39
- def dynamically_translated_filters
40
- [:decidim_assemblies_type_id_eq]
41
- end
42
-
43
- def translated_decidim_assemblies_type_id_eq(id)
44
- translated_attribute(Decidim::AssembliesType.find(id).title)
45
- end
46
37
  end
47
38
  end
48
39
  end
@@ -7,8 +7,11 @@ module Decidim
7
7
  #
8
8
  class AssembliesController < Decidim::Assemblies::Admin::ApplicationController
9
9
  include Decidim::Assemblies::Admin::Filterable
10
- include Decidim::Admin::ParticipatorySpaceAdminBreadcrumb
11
- helper_method :current_assembly, :parent_assembly, :current_participatory_space
10
+ include Decidim::Admin::ParticipatorySpaceAdminContext
11
+ include Decidim::Admin::HasTrashableResources
12
+
13
+ helper_method :current_assembly, :parent_assembly, :parent_assembly_id, :current_participatory_space
14
+
12
15
  layout "decidim/admin/assemblies"
13
16
 
14
17
  def index
@@ -29,7 +32,7 @@ module Decidim
29
32
  CreateAssembly.call(@form) do
30
33
  on(:ok) do |assembly|
31
34
  flash[:notice] = I18n.t("assemblies.create.success", scope: "decidim.admin")
32
- redirect_to assemblies_path(q: { parent_id_eq: assembly.parent_id })
35
+ redirect_to components_path(assembly)
33
36
  end
34
37
 
35
38
  on(:invalid) do
@@ -75,8 +78,20 @@ module Decidim
75
78
  @collection ||= OrganizationAssemblies.new(current_user.organization).query
76
79
  end
77
80
 
81
+ def trashable_deleted_resource_type
82
+ :assembly
83
+ end
84
+
85
+ def trashable_deleted_resource
86
+ @trashable_deleted_resource ||= current_assembly
87
+ end
88
+
89
+ def trashable_deleted_collection
90
+ @trashable_deleted_collection = filtered_collection.only_deleted.deleted_at_desc
91
+ end
92
+
78
93
  def current_assembly
79
- @current_assembly ||= collection.where(slug: params[:slug]).or(
94
+ @current_assembly ||= collection.with_deleted.where(slug: params[:slug]).or(
80
95
  collection.where(id: params[:slug])
81
96
  ).first
82
97
  end
@@ -20,7 +20,7 @@ module Decidim
20
20
  CopyAssembly.call(@form, current_assembly, current_user) do
21
21
  on(:ok) do
22
22
  flash[:notice] = I18n.t("assemblies_copies.create.success", scope: "decidim.admin")
23
- redirect_to assemblies_path(parent_id: current_assembly.parent_id)
23
+ redirect_to assemblies_path
24
24
  end
25
25
 
26
26
  on(:invalid) do
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module Admin
6
+ # This controller allows sharing unpublished things.
7
+ # It is targeted for customizations for sharing unpublished things that lives under
8
+ # an assembly.
9
+ class AssemblyShareTokensController < Decidim::Admin::ShareTokensController
10
+ include Concerns::AssemblyAdmin
11
+
12
+ def resource
13
+ current_assembly
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module Admin
6
+ # This controller allows sharing unpublished things.
7
+ # It is targeted for customizations for sharing unpublished things that lives under
8
+ # an assembly.
9
+ class ComponentShareTokensController < Decidim::Admin::ShareTokensController
10
+ include Concerns::AssemblyAdmin
11
+
12
+ def resource
13
+ @resource ||= current_participatory_space.components.find(params[:component_id])
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -56,9 +56,7 @@ module Decidim
56
56
 
57
57
  def default_filter_params
58
58
  {
59
- with_any_scope: nil,
60
- with_any_area: nil,
61
- with_any_type: nil
59
+ with_any_taxonomies: nil
62
60
  }
63
61
  end
64
62
 
@@ -2,27 +2,19 @@
2
2
 
3
3
  module Decidim
4
4
  module Assemblies
5
- class AssemblyMembersController < Decidim::Assemblies::ApplicationController
5
+ class ParticipatorySpacePrivateUsersController < Decidim::Assemblies::ApplicationController
6
6
  include ParticipatorySpaceContext
7
- include AssemblyBreadcrumb
8
-
9
- helper_method :collection
7
+ include Decidim::HasMembersPage
10
8
 
11
9
  def index
12
10
  raise ActionController::RoutingError, "No members for this assembly" if members.none?
13
11
 
14
12
  enforce_permission_to :list, :members
15
- redirect_to decidim_assemblies.assembly_path(current_participatory_space) unless current_user_can_visit_space?
13
+ redirect_to decidim_assemblies.assembly_path(current_participatory_space) unless can_visit_index?
16
14
  end
17
15
 
18
16
  private
19
17
 
20
- def members
21
- @members ||= current_participatory_space.members.not_ceased
22
- end
23
-
24
- alias collection members
25
-
26
18
  def current_participatory_space
27
19
  return unless params[:assembly_slug]
28
20
 
@@ -14,7 +14,6 @@ module Decidim
14
14
  mimic :assembly
15
15
 
16
16
  attribute :slug, String
17
- attribute :copy_categories, Boolean
18
17
  attribute :copy_components, Boolean
19
18
 
20
19
  validates :slug, presence: true, format: { with: Decidim::Assembly.slug_format }
@@ -9,6 +9,7 @@ module Decidim
9
9
  class AssemblyForm < Form
10
10
  include TranslatableAttributes
11
11
  include Decidim::HasUploadValidations
12
+ include Decidim::HasTaxonomyFormAttributes
12
13
 
13
14
  CREATED_BY = %w(city_council public others).freeze
14
15
 
@@ -41,17 +42,13 @@ module Decidim
41
42
  attribute :twitter_handler, String
42
43
  attribute :youtube_handler, String
43
44
 
44
- attribute :decidim_assemblies_type_id, Integer
45
- attribute :area_id, Integer
46
45
  attribute :parent_id, Integer
47
46
  attribute :participatory_processes_ids, Array[Integer]
48
- attribute :scope_id, Integer
49
47
  attribute :weight, Integer, default: 0
50
48
 
51
49
  attribute :is_transparent, Boolean
52
50
  attribute :promoted, Boolean
53
51
  attribute :private_space, Boolean
54
- attribute :scopes_enabled, Boolean
55
52
 
56
53
  attribute :closing_date, Decidim::Attributes::LocalizedDate
57
54
  attribute :creation_date, Decidim::Attributes::LocalizedDate
@@ -63,16 +60,12 @@ module Decidim
63
60
  attribute :remove_banner_image, Boolean, default: false
64
61
  attribute :remove_hero_image, Boolean, default: false
65
62
 
66
- validates :area, presence: true, if: proc { |object| object.area_id.present? }
67
-
68
63
  validates :parent, presence: true, if: ->(form) { form.parent.present? }
69
64
  validate :ensure_parent_cannot_be_child, if: ->(form) { form.parent.present? }
70
65
 
71
- validates :scope, presence: true, if: proc { |object| object.scope_id.present? }
72
66
  validates :slug, presence: true, format: { with: Decidim::Assembly.slug_format }
73
67
 
74
68
  validate :slug_uniqueness
75
- validate :same_type_organization, if: ->(form) { form.decidim_assemblies_type_id }
76
69
 
77
70
  validates :created_by_other, translatable_presence: true, if: ->(form) { form.created_by == "others" }
78
71
  validates :title, :subtitle, :description, :short_description, translatable_presence: true
@@ -84,6 +77,10 @@ module Decidim
84
77
 
85
78
  alias organization current_organization
86
79
 
80
+ def participatory_space_manifest
81
+ :assemblies
82
+ end
83
+
87
84
  def ensure_parent_cannot_be_child
88
85
  return if id.blank?
89
86
 
@@ -91,23 +88,6 @@ module Decidim
91
88
  errors.add(:parent, :invalid) unless available_assemblies.include? parent
92
89
  end
93
90
 
94
- def map_model(model)
95
- self.scope_id = model.decidim_scope_id
96
- end
97
-
98
- def scope
99
- @scope ||= current_organization.scopes.find_by(id: scope_id)
100
- end
101
-
102
- def area
103
- @area ||= current_organization.areas.find_by(id: area_id)
104
- end
105
-
106
- def assembly_types_for_select
107
- @assembly_types_for_select ||= organization_assembly_types
108
- &.map { |type| [translated_attribute(type.title), type.id] }
109
- end
110
-
111
91
  def created_by_for_select
112
92
  CREATED_BY.map do |creator|
113
93
  [
@@ -127,16 +107,8 @@ module Decidim
127
107
  &.sort_by { |arr| arr[0] }
128
108
  end
129
109
 
130
- def assembly_type
131
- AssembliesType.find_by(id: decidim_assemblies_type_id)
132
- end
133
-
134
110
  private
135
111
 
136
- def organization_assembly_types
137
- AssembliesType.where(organization: current_organization)
138
- end
139
-
140
112
  def organization_participatory_processes
141
113
  Decidim.find_participatory_space_manifest(:participatory_processes)
142
114
  .participatory_spaces.call(current_organization)
@@ -154,13 +126,6 @@ module Decidim
154
126
 
155
127
  errors.add(:slug, :taken)
156
128
  end
157
-
158
- def same_type_organization
159
- return unless assembly_type
160
- return if assembly_type.organization == current_organization
161
-
162
- errors.add(:assembly_type, :invalid)
163
- end
164
129
  end
165
130
  end
166
131
  end
@@ -27,7 +27,6 @@ module Decidim
27
27
 
28
28
  attribute :slug, String
29
29
  attribute :import_steps, Boolean, default: false
30
- attribute :import_categories, Boolean, default: true
31
30
  attribute :import_attachments, Boolean, default: true
32
31
  attribute :import_components, Boolean, default: true
33
32
  attribute :document, Decidim::Attributes::Blob
@@ -15,10 +15,32 @@ module Decidim
15
15
  end
16
16
  end
17
17
 
18
- # Public: A collection of Assemblies that can be selected as parent
19
- # assemblies for another assembly; to be used in forms.
20
- def parent_assemblies_for_select
21
- @parent_assemblies_for_select ||= ParentAssembliesForSelect.for(current_organization, current_assembly)
18
+ # Public: select options representing a collection of Assemblies that
19
+ # can be selected as parent assemblies for another assembly; to be used in forms.
20
+ def parent_assemblies_options
21
+ options = []
22
+ root_assemblies = ParentAssembliesForSelect.for(current_organization, current_assembly).where(parent_id: nil).sort_by(&:weight)
23
+
24
+ root_assemblies.each do |assembly|
25
+ build_assembly_options(assembly, options)
26
+ end
27
+
28
+ options
29
+ end
30
+
31
+ private
32
+
33
+ # Recursively build the options for the assembly tree
34
+ def build_assembly_options(assembly, options, level = 0)
35
+ name = sanitize("#{"&nbsp;" * 4 * level} #{assembly.translated_title}")
36
+ options << [name, assembly.id]
37
+
38
+ # Skip the current assembly to avoid selecting a child as parent
39
+ return if assembly == current_assembly
40
+
41
+ assembly.children.each do |child|
42
+ build_assembly_options(child, options, level + 1)
43
+ end
22
44
  end
23
45
  end
24
46
  end
@@ -17,11 +17,11 @@ module Decidim
17
17
  components = participatory_space.components.published.or(Decidim::Component.where(id: try(:current_component)))
18
18
 
19
19
  [
20
- *(if participatory_space.members.not_ceased.any?
20
+ *(if participatory_space.members_public_page?
21
21
  [{
22
22
  name: t("assembly_member_menu_item", scope: "layouts.decidim.assembly_navigation"),
23
- url: decidim_assemblies.assembly_assembly_members_path(participatory_space),
24
- active: is_active_link?(decidim_assemblies.assembly_assembly_members_path(participatory_space), :inclusive)
23
+ url: decidim_assemblies.assembly_participatory_space_private_users_path(participatory_space),
24
+ active: is_active_link?(decidim_assemblies.assembly_participatory_space_private_users_path(participatory_space), :inclusive)
25
25
  }]
26
26
  end
27
27
  )
@@ -31,7 +31,7 @@ module Decidim
31
31
  url: main_component_path(component),
32
32
  active: is_active_link?(main_component_path(component), :inclusive)
33
33
  }
34
- end
34
+ end.compact
35
35
  end
36
36
  end
37
37
  end
@@ -6,25 +6,21 @@ module Decidim
6
6
  module FilterAssembliesHelper
7
7
  include Decidim::CheckBoxesTreeHelper
8
8
 
9
- def assembly_types
10
- @assembly_types ||= AssembliesType.where(organization: current_organization).joins(:assemblies).distinct
11
- end
12
-
13
- def filter_types_values
14
- return if assembly_types.blank?
9
+ def filter_sections
10
+ items = []
15
11
 
16
- type_values = assembly_types.map { |type| [type.id.to_s, translated_attribute(type.title)] }
17
- type_values.prepend(["", t("decidim.assemblies.assemblies.filters.names.all")])
12
+ available_taxonomy_filters.find_each do |taxonomy_filter|
13
+ items.append(method: "with_any_taxonomies[#{taxonomy_filter.root_taxonomy_id}]",
14
+ collection: filter_taxonomy_values_for(taxonomy_filter),
15
+ label: decidim_sanitize_translated(taxonomy_filter.name),
16
+ id: "taxonomy")
17
+ end
18
18
 
19
- filter_tree_from_array(type_values)
19
+ items.reject { |item| item[:collection].blank? }
20
20
  end
21
21
 
22
- def filter_sections
23
- [
24
- { method: :with_any_scope, collection: filter_global_scopes_values, label_scope: "decidim.shared.participatory_space_filters.filters", id: "scope" },
25
- { method: :with_any_area, collection: filter_areas_values, label_scope: "decidim.shared.participatory_space_filters.filters", id: "area" },
26
- { method: :with_any_type, collection: filter_types_values, label_scope: "decidim.assemblies.assemblies.filters", id: "type" }
27
- ].reject { |item| item[:collection].blank? }
22
+ def available_taxonomy_filters
23
+ Decidim::TaxonomyFilter.for(current_organization).for_manifest(:assemblies)
28
24
  end
29
25
  end
30
26
  end
@@ -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"