decidim-assemblies 0.26.9 → 0.27.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies/show.erb +2 -2
  3. data/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb +5 -5
  4. data/app/commands/decidim/assemblies/admin/copy_assembly.rb +10 -7
  5. data/app/commands/decidim/assemblies/admin/create_assemblies_type.rb +1 -1
  6. data/app/commands/decidim/assemblies/admin/create_assembly.rb +1 -1
  7. data/app/commands/decidim/assemblies/admin/create_assembly_member.rb +12 -12
  8. data/app/commands/decidim/assemblies/admin/destroy_assemblies_type.rb +1 -1
  9. data/app/commands/decidim/assemblies/admin/destroy_assembly_admin.rb +1 -6
  10. data/app/commands/decidim/assemblies/admin/destroy_assembly_member.rb +1 -1
  11. data/app/commands/decidim/assemblies/admin/import_assembly.rb +11 -7
  12. data/app/commands/decidim/assemblies/admin/notify_role_assigned_to_assembly.rb +1 -1
  13. data/app/commands/decidim/assemblies/admin/publish_assembly.rb +1 -1
  14. data/app/commands/decidim/assemblies/admin/unpublish_assembly.rb +1 -1
  15. data/app/commands/decidim/assemblies/admin/update_assemblies_setting.rb +1 -1
  16. data/app/commands/decidim/assemblies/admin/update_assemblies_type.rb +1 -1
  17. data/app/commands/decidim/assemblies/admin/update_assembly.rb +1 -1
  18. data/app/commands/decidim/assemblies/admin/update_assembly_member.rb +11 -11
  19. data/app/controllers/decidim/assemblies/admin/assemblies_types_controller.rb +1 -1
  20. data/app/controllers/decidim/assemblies/admin/assembly_copies_controller.rb +1 -1
  21. data/app/controllers/decidim/assemblies/admin/assembly_imports_controller.rb +1 -1
  22. data/app/controllers/decidim/assemblies/admin/assembly_members_controller.rb +1 -1
  23. data/app/controllers/decidim/assemblies/admin/reminders_controller.rb +14 -0
  24. data/app/controllers/decidim/assemblies/assemblies_controller.rb +6 -6
  25. data/app/events/decidim/role_assigned_to_assembly_event.rb +1 -1
  26. data/app/forms/decidim/assemblies/admin/assembly_import_form.rb +5 -6
  27. data/app/helpers/decidim/assemblies/filter_assemblies_helper.rb +10 -6
  28. data/app/models/decidim/assembly.rb +10 -4
  29. data/app/packs/src/decidim/assemblies/orgchart.js +52 -46
  30. data/app/permissions/decidim/assemblies/permissions.rb +45 -11
  31. data/app/presenters/decidim/assemblies/admin_log/assembly_presenter.rb +1 -1
  32. data/app/presenters/decidim/assemblies/assembly_stats_presenter.rb +4 -1
  33. data/app/presenters/decidim/assembly_member_presenter.rb +3 -5
  34. data/app/queries/decidim/assemblies/admin/admin_users.rb +1 -1
  35. data/app/queries/decidim/assemblies/admin/assembly_members.rb +1 -1
  36. data/app/queries/decidim/assemblies/assemblies_with_user_role.rb +1 -1
  37. data/app/queries/decidim/assemblies/filtered_assemblies.rb +1 -1
  38. data/app/queries/decidim/assemblies/organization_assemblies.rb +1 -1
  39. data/app/queries/decidim/assemblies/organization_prioritized_assemblies.rb +2 -2
  40. data/app/queries/decidim/assemblies/organization_published_assemblies.rb +2 -2
  41. data/app/queries/decidim/assemblies/parent_assemblies.rb +1 -1
  42. data/app/queries/decidim/assemblies/parent_assemblies_for_select.rb +1 -1
  43. data/app/queries/decidim/assemblies/prioritized_assemblies.rb +1 -1
  44. data/app/queries/decidim/assemblies/promoted_assemblies.rb +1 -1
  45. data/app/queries/decidim/assemblies/published_assemblies.rb +1 -1
  46. data/app/queries/decidim/assemblies/visible_assemblies.rb +1 -1
  47. data/app/serializers/decidim/assemblies/assembly_importer.rb +3 -4
  48. data/app/views/decidim/assemblies/_filter_by_type.html.erb +1 -1
  49. data/app/views/decidim/assemblies/admin/assemblies/_form.html.erb +2 -2
  50. data/app/views/decidim/assemblies/admin/assemblies/index.html.erb +2 -3
  51. data/app/views/decidim/assemblies/admin/assemblies/new.html.erb +0 -2
  52. data/app/views/decidim/assemblies/admin/assemblies_settings/edit.html.erb +0 -1
  53. data/app/views/decidim/assemblies/admin/assemblies_types/edit.html.erb +0 -1
  54. data/app/views/decidim/assemblies/admin/assemblies_types/index.html.erb +0 -2
  55. data/app/views/decidim/assemblies/admin/assemblies_types/new.html.erb +0 -1
  56. data/app/views/decidim/assemblies/assemblies/_promoted_assembly.html.erb +1 -1
  57. data/app/views/decidim/assemblies/assemblies/index.html.erb +3 -1
  58. data/app/views/decidim/assemblies/assemblies/show.html.erb +8 -6
  59. data/app/views/layouts/decidim/_assembly_header.html.erb +1 -1
  60. data/app/views/layouts/decidim/admin/assembly.html.erb +0 -1
  61. data/config/locales/am-ET.yml +1 -0
  62. data/config/locales/ar.yml +12 -74
  63. data/config/locales/bg.yml +1 -4
  64. data/config/locales/ca.yml +9 -13
  65. data/config/locales/cs.yml +26 -30
  66. data/config/locales/da.yml +1 -0
  67. data/config/locales/de.yml +20 -24
  68. data/config/locales/el.yml +13 -32
  69. data/config/locales/en.yml +6 -11
  70. data/config/locales/eo.yml +1 -0
  71. data/config/locales/es-MX.yml +10 -14
  72. data/config/locales/es-PY.yml +10 -14
  73. data/config/locales/es.yml +10 -14
  74. data/config/locales/et.yml +1 -0
  75. data/config/locales/eu.yml +187 -206
  76. data/config/locales/fi-plain.yml +11 -15
  77. data/config/locales/fi.yml +15 -19
  78. data/config/locales/fr-CA.yml +14 -18
  79. data/config/locales/fr.yml +22 -26
  80. data/config/locales/ga-IE.yml +2 -0
  81. data/config/locales/gl.yml +13 -9
  82. data/config/locales/hr.yml +1 -0
  83. data/config/locales/hu.yml +14 -56
  84. data/config/locales/id-ID.yml +12 -4
  85. data/config/locales/is-IS.yml +15 -9
  86. data/config/locales/it.yml +15 -11
  87. data/config/locales/ja.yml +10 -14
  88. data/config/locales/ko.yml +1 -0
  89. data/config/locales/lb.yml +12 -11
  90. data/config/locales/lt.yml +1 -470
  91. data/config/locales/lv.yml +10 -1
  92. data/config/locales/mt.yml +1 -0
  93. data/config/locales/nl.yml +30 -31
  94. data/config/locales/no.yml +13 -9
  95. data/config/locales/om-ET.yml +1 -0
  96. data/config/locales/pl.yml +11 -22
  97. data/config/locales/pt-BR.yml +14 -29
  98. data/config/locales/pt.yml +11 -7
  99. data/config/locales/ro-RO.yml +12 -22
  100. data/config/locales/ru.yml +13 -6
  101. data/config/locales/si-LK.yml +1 -0
  102. data/config/locales/sk.yml +1 -20
  103. data/config/locales/sl.yml +5 -15
  104. data/config/locales/so-SO.yml +1 -0
  105. data/config/locales/sr-CS.yml +1 -0
  106. data/config/locales/sv.yml +18 -20
  107. data/config/locales/sw-KE.yml +1 -0
  108. data/config/locales/ti-ER.yml +1 -0
  109. data/config/locales/tr-TR.yml +15 -24
  110. data/config/locales/uk.yml +13 -6
  111. data/config/locales/val-ES.yml +1 -0
  112. data/config/locales/vi.yml +1 -0
  113. data/config/locales/zh-CN.yml +11 -7
  114. data/config/locales/zh-TW.yml +1 -455
  115. data/lib/decidim/assemblies/admin_engine.rb +5 -4
  116. data/lib/decidim/assemblies/participatory_space.rb +9 -9
  117. data/lib/decidim/assemblies/test/factories.rb +0 -4
  118. data/lib/decidim/assemblies/version.rb +1 -1
  119. metadata +13 -50
  120. data/app/services/decidim/assemblies/assembly_search.rb +0 -18
  121. data/config/environment.rb +0 -3
  122. data/config/locales/fa-IR.yml +0 -1
  123. data/config/locales/gn-PY.yml +0 -1
  124. data/config/locales/ka-GE.yml +0 -1
  125. data/config/locales/kaa.yml +0 -60
  126. data/config/locales/lo-LA.yml +0 -1
  127. data/config/locales/oc-FR.yml +0 -1
  128. data/config/locales/sq-AL.yml +0 -1
  129. data/config/locales/th-TH.yml +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e2b09090f862d709287012377ca1fc959ff7980585a2a6fb64c4dcf12411cb9
4
- data.tar.gz: 6e4097f72dc77f22d5af6f97877d9862c2ee71111469f66461df058f22e253fe
3
+ metadata.gz: 2a5b5e8c31f5fe95f7daababb5bbc461d310b6856de642bc7fbfbc11ec28e2ad
4
+ data.tar.gz: 93a14db836c2565409018f0f7412e573a09e82d284d1f8541e02760840e9474b
5
5
  SHA512:
6
- metadata.gz: 806a64f9fcc766397e28bc65abb34d93f40573819a08f247eb6eb3b6100415acb4dece7274c1d3ce59050adfcc30ee0ba1ec0108d71de5af21cd92f926df421e
7
- data.tar.gz: 461d35e0b91e283c361c9a35b9de2dd06260d738867f69eb979e17ec533d1661d139c05b2feb113e0c638953825488097a7db56568039d13eba62c75ab3403a0
6
+ metadata.gz: 1d798e4bce33008a72d064a0018526315f7d19316892ea0768143da3ebe88b2dd2b41a49a933ec1a53179d86f14ee12725e125f84b7805668a3b7daf02064c41
7
+ data.tar.gz: 8acdd79b4afb870df01b723e8d2f2e821bbeafbfb132cacfdb6c32efbb6d4ba0daf48defffe6717b630f3bcbf7e0dd3af2f93ca8eea2f0959bcc9f8f507ffdb3
@@ -1,4 +1,4 @@
1
- <section class="wrapper-home home-section" xmlns="http://www.w3.org/1999/xhtml">
1
+ <section id="highlighted_assemblies" class="wrapper-home home-section" xmlns="http://www.w3.org/1999/xhtml">
2
2
  <div class="row" id="highlighted-assemblies">
3
3
  <h3 class="section-heading"><%= t("active_assemblies", scope: i18n_scope) %></h3>
4
4
  <div class="row collapse">
@@ -8,7 +8,7 @@
8
8
  <div class="column">
9
9
  <%= link_to decidim_assemblies.assembly_path(assembly), class: "card card--assembly card--mini" do %>
10
10
  <div aria-hidden="true" class="card__image-top"
11
- style="background-image:url('<%= assembly.attached_uploader(:hero_image).path %>')"></div>
11
+ style="background-image:url(<%= assembly.attached_uploader(:hero_image).path %>)"></div>
12
12
  <div class="card__content">
13
13
  <span class="card__title card__link"><%= translated_attribute assembly.title %></span>
14
14
  </div>
@@ -6,10 +6,6 @@ module Decidim
6
6
  class HighlightedAssembliesCell < Decidim::ViewModel
7
7
  delegate :current_user, to: :controller
8
8
 
9
- cache :show, expires_in: 10.minutes, if: :perform_caching? do
10
- cache_hash
11
- end
12
-
13
9
  def show
14
10
  render if highlighted_assemblies.any?
15
11
  end
@@ -22,6 +18,7 @@ module Decidim
22
18
  @highlighted_assemblies ||= OrganizationPrioritizedAssemblies
23
19
  .new(current_organization, current_user)
24
20
  .query
21
+ .with_attached_hero_image
25
22
  .includes([:organization])
26
23
  .limit(max_results)
27
24
  end
@@ -39,9 +36,12 @@ module Decidim
39
36
  def cache_hash
40
37
  hash = []
41
38
  hash.push(I18n.locale)
42
- hash.push(highlighted_assemblies.map(&:cache_key_with_version))
43
39
  hash.join(Decidim.cache_key_separator)
44
40
  end
41
+
42
+ def cache_expiry_time
43
+ 10.minutes
44
+ end
45
45
  end
46
46
  end
47
47
  end
@@ -5,14 +5,15 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when copying a new participatory
7
7
  # assembly in the system.
8
- class CopyAssembly < Rectify::Command
8
+ class CopyAssembly < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
12
12
  # assembly - An assembly we want to duplicate
13
- def initialize(form, assembly)
13
+ def initialize(form, assembly, user)
14
14
  @form = form
15
15
  @assembly = assembly
16
+ @user = user
16
17
  end
17
18
 
18
19
  # Executes the command. Broadcasts these events:
@@ -24,11 +25,13 @@ module Decidim
24
25
  def call
25
26
  return broadcast(:invalid) if form.invalid?
26
27
 
27
- Assembly.transaction do
28
- copy_assembly
29
- copy_assembly_attachments
30
- copy_assembly_categories if @form.copy_categories?
31
- copy_assembly_components if @form.copy_components?
28
+ Decidim.traceability.perform_action!("duplicate", @assembly, @user) do
29
+ Assembly.transaction do
30
+ copy_assembly
31
+ copy_assembly_attachments
32
+ copy_assembly_categories if @form.copy_categories?
33
+ copy_assembly_components if @form.copy_components?
34
+ end
32
35
  end
33
36
 
34
37
  broadcast(:ok, @copied_assembly)
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new assembly
7
7
  # type in the system.
8
- class CreateAssembliesType < Rectify::Command
8
+ class CreateAssembliesType < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new participatory
7
7
  # assembly in the system.
8
- class CreateAssembly < Rectify::Command
8
+ class CreateAssembly < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new assembly
7
7
  # member in the system.
8
- class CreateAssemblyMember < Rectify::Command
8
+ class CreateAssemblyMember < Decidim::Command
9
9
  include ::Decidim::AttachmentAttributesMethods
10
10
 
11
11
  # Public: Initializes the command.
@@ -53,16 +53,16 @@ module Decidim
53
53
 
54
54
  def assembly_member_attributes
55
55
  form.attributes.slice(
56
- :full_name,
57
- :gender,
58
- :birthday,
59
- :birthplace,
60
- :ceased_date,
61
- :designation_date,
62
- :position,
63
- :position_other,
64
- :weight
65
- ).merge(
56
+ "full_name",
57
+ "gender",
58
+ "birthday",
59
+ "birthplace",
60
+ "ceased_date",
61
+ "designation_date",
62
+ "position",
63
+ "position_other",
64
+ "weight"
65
+ ).symbolize_keys.merge(
66
66
  assembly: assembly,
67
67
  user: form.user
68
68
  ).merge(
@@ -99,7 +99,7 @@ module Decidim
99
99
  resource: assembly,
100
100
  followers: followers
101
101
  }
102
- Decidim::EventsManager.publish(data)
102
+ Decidim::EventsManager.publish(**data)
103
103
  end
104
104
  end
105
105
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when destroying an assembly
7
7
  # type in the system.
8
- class DestroyAssembliesType < Rectify::Command
8
+ class DestroyAssembliesType < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # assemblies_type - the AssemblyMember to destroy
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when destroying an assembly
7
7
  # admin in the system.
8
- class DestroyAssemblyAdmin < Rectify::Command
8
+ class DestroyAssemblyAdmin < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # role - the AssemblyUserRole to destroy
@@ -23,7 +23,6 @@ module Decidim
23
23
  # Returns nothing.
24
24
  def call
25
25
  destroy_role!
26
- dispatch_system_event
27
26
  broadcast(:ok)
28
27
  end
29
28
 
@@ -31,10 +30,6 @@ module Decidim
31
30
 
32
31
  attr_reader :role, :current_user
33
32
 
34
- def dispatch_system_event
35
- ActiveSupport::Notifications.publish("decidim.system.participatory_space.admin.destroyed", role.class.name, role.id)
36
- end
37
-
38
33
  def destroy_role!
39
34
  extra_info = {
40
35
  resource: {
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when destroying an assembly
7
7
  # member in the system.
8
- class DestroyAssemblyMember < Rectify::Command
8
+ class DestroyAssemblyMember < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # assembly_member - the AssemblyMember to destroy
@@ -5,13 +5,14 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic to import a new assembly
7
7
  # in the system.
8
- class ImportAssembly < Rectify::Command
8
+ class ImportAssembly < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
12
12
  # assembly - An assembly we want to duplicate
13
- def initialize(form)
13
+ def initialize(form, user)
14
14
  @form = form
15
+ @user = user
15
16
  end
16
17
 
17
18
  # Executes the command. Broadcasts these events:
@@ -38,11 +39,14 @@ module Decidim
38
39
  def import_assembly
39
40
  importer = Decidim::Assemblies::AssemblyImporter.new(form.current_organization, form.current_user)
40
41
  assemblies.each do |original_assembly|
41
- @imported_assembly = importer.import(original_assembly, form.current_user, title: form.title, slug: form.slug)
42
- importer.import_assemblies_type(original_assembly["decidim_assemblies_type_id"])
43
- importer.import_categories(original_assembly["assembly_categories"]) if form.import_categories?
44
- importer.import_folders_and_attachments(original_assembly["attachments"]) if form.import_attachments?
45
- importer.import_components(original_assembly["components"]) if form.import_components?
42
+ Decidim.traceability.perform_action!("import", Assembly, @user) do
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
+ importer.import_folders_and_attachments(original_assembly["attachments"]) if form.import_attachments?
47
+ importer.import_components(original_assembly["components"]) if form.import_components?
48
+ @imported_assembly
49
+ end
46
50
  end
47
51
  end
48
52
 
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Assemblies
5
5
  module Admin
6
6
  # A command to notify users when a role is assigned for an assembly
7
- class NotifyRoleAssignedToAssembly < Rectify::Command
7
+ class NotifyRoleAssignedToAssembly < Decidim::Command
8
8
  def send_notification(user)
9
9
  Decidim::EventsManager.publish(
10
10
  event: "decidim.events.assembly.role_assigned",
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Assemblies
5
5
  module Admin
6
6
  # A command that sets an assembly as published.
7
- class PublishAssembly < Rectify::Command
7
+ class PublishAssembly < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # assembly - A Assembly that will be published
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Assemblies
5
5
  module Admin
6
6
  # A command that sets an assembly as unpublished.
7
- class UnpublishAssembly < Rectify::Command
7
+ class UnpublishAssembly < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # assembly - A Assembly that will be published
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when updating assemblies
7
7
  # settings in admin area.
8
- class UpdateAssembliesSetting < Rectify::Command
8
+ class UpdateAssembliesSetting < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # assemblies_setting - A assemblies_setting object to update.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when updating a new assembly
7
7
  # type in the system.
8
- class UpdateAssembliesType < Rectify::Command
8
+ class UpdateAssembliesType < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # assemblies_type - A assemblies_type object to update.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new participatory
7
7
  # assembly in the system.
8
- class UpdateAssembly < Rectify::Command
8
+ class UpdateAssembly < Decidim::Command
9
9
  include ::Decidim::AttachmentAttributesMethods
10
10
 
11
11
  # Public: Initializes the command.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when updating an assembly
7
7
  # member in the system.
8
- class UpdateAssemblyMember < Rectify::Command
8
+ class UpdateAssemblyMember < Decidim::Command
9
9
  include ::Decidim::AttachmentAttributesMethods
10
10
 
11
11
  # Public: Initializes the command.
@@ -51,16 +51,16 @@ module Decidim
51
51
 
52
52
  def attributes
53
53
  form.attributes.slice(
54
- :full_name,
55
- :gender,
56
- :birthday,
57
- :birthplace,
58
- :ceased_date,
59
- :designation_date,
60
- :position,
61
- :position_other,
62
- :weight
63
- ).merge(
54
+ "full_name",
55
+ "gender",
56
+ "birthday",
57
+ "birthplace",
58
+ "ceased_date",
59
+ "designation_date",
60
+ "position",
61
+ "position_other",
62
+ "weight"
63
+ ).symbolize_keys.merge(
64
64
  user: form.user
65
65
  ).merge(
66
66
  attachment_attributes(:non_user_avatar)
@@ -95,7 +95,7 @@ module Decidim
95
95
  end
96
96
 
97
97
  def current_assembly_type
98
- @current_assembly_type ||= available_assemblies_types.find(params[:id])
98
+ @current_assembly_type ||= AssembliesType.find(params[:id])
99
99
  end
100
100
 
101
101
  def assembly_type_form
@@ -17,7 +17,7 @@ module Decidim
17
17
  enforce_permission_to :create, :assembly
18
18
  @form = form(AssemblyCopyForm).from_params(params)
19
19
 
20
- CopyAssembly.call(@form, current_assembly) do
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
23
  redirect_to assemblies_path(parent_id: current_assembly.parent_id)
@@ -13,7 +13,7 @@ module Decidim
13
13
  enforce_permission_to :import, :assembly
14
14
  @form = form(AssemblyImportForm).from_params(params)
15
15
 
16
- ImportAssembly.call(@form) do
16
+ ImportAssembly.call(@form, current_user) do
17
17
  on(:ok) do
18
18
  flash[:notice] = I18n.t("assembly_imports.create.success", scope: "decidim.admin")
19
19
  redirect_to assemblies_path
@@ -79,7 +79,7 @@ module Decidim
79
79
  private
80
80
 
81
81
  def collection
82
- @collection ||= current_assembly.members
82
+ @collection ||= Decidim::AssemblyMember.where(assembly: current_assembly)
83
83
  end
84
84
  end
85
85
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module Admin
6
+ # This controller allows to send reminders.
7
+ # It is targeted for customizations for reminder things that lives under
8
+ # an assembly.
9
+ class RemindersController < Decidim::Admin::RemindersController
10
+ include Concerns::AssemblyAdmin
11
+ end
12
+ end
13
+ end
14
+ end
@@ -48,15 +48,15 @@ module Decidim
48
48
 
49
49
  private
50
50
 
51
- def search_klass
52
- AssemblySearch
51
+ def search_collection
52
+ Assembly.where(organization: current_organization).published.visible_for(current_user)
53
53
  end
54
54
 
55
55
  def default_filter_params
56
56
  {
57
- scope_id: nil,
58
- area_id: nil,
59
- type_id: nil
57
+ with_scope: nil,
58
+ with_area: nil,
59
+ type_id_eq: nil
60
60
  }
61
61
  end
62
62
 
@@ -77,7 +77,7 @@ module Decidim
77
77
  end
78
78
 
79
79
  def parent_assemblies
80
- search.results.parent_assemblies.order(weight: :asc, promoted: :desc)
80
+ search.result.parent_assemblies.order(weight: :asc, promoted: :desc)
81
81
  end
82
82
 
83
83
  def stats
@@ -6,7 +6,7 @@ module Decidim
6
6
  include Decidim::Events::AuthorEvent
7
7
 
8
8
  def notification_title
9
- I18n.t("notification_title", i18n_options).html_safe
9
+ I18n.t("notification_title", **i18n_options).html_safe
10
10
  end
11
11
 
12
12
  def i18n_role
@@ -30,10 +30,9 @@ module Decidim
30
30
  attribute :import_categories, Boolean, default: true
31
31
  attribute :import_attachments, Boolean, default: true
32
32
  attribute :import_components, Boolean, default: true
33
- attribute :document
34
-
35
- validates :document, presence: true
33
+ attribute :document, Decidim::Attributes::Blob
36
34
 
35
+ validates :document, file_content_type: { allow: ACCEPTED_TYPES.values }
37
36
  validates :slug, presence: true, format: { with: Decidim::Assembly.slug_format }
38
37
  validates :title, translatable_presence: true
39
38
  validate :slug_uniqueness
@@ -41,7 +40,7 @@ module Decidim
41
40
  validate :document_type_must_be_valid, if: :document
42
41
 
43
42
  def document_text
44
- @document_text ||= document&.read
43
+ @document_text ||= document&.download
45
44
  end
46
45
 
47
46
  def document_type_must_be_valid
@@ -60,9 +59,9 @@ module Decidim
60
59
  end
61
60
 
62
61
  def i18n_invalid_document_type_text
63
- I18n.t("invalid_document_type",
62
+ I18n.t("allowed_file_content_types",
64
63
  scope: "activemodel.errors.models.assembly.attributes.document",
65
- valid_mime_types: i18n_valid_mime_types_text)
64
+ types: i18n_valid_mime_types_text)
66
65
  end
67
66
 
68
67
  def i18n_valid_mime_types_text
@@ -7,7 +7,9 @@ module Decidim
7
7
  # `filter` returns a Filter object from Decidim::FilterResource
8
8
  module FilterAssembliesHelper
9
9
  def available_filters
10
- @available_filters ||= [t("all", scope: "decidim.assemblies.filter")] + organization_assembly_types
10
+ return if organization_assembly_types.blank?
11
+
12
+ [t("all", scope: "decidim.assemblies.filter")] + organization_assembly_types
11
13
  end
12
14
 
13
15
  def filter_link(type_id)
@@ -16,9 +18,9 @@ module Decidim
16
18
  .url_helpers
17
19
  .assemblies_path(
18
20
  filter: {
19
- scope_id: filter.scope_id,
20
- area_id: filter.area_id,
21
- type_id: type_id
21
+ with_scope: filter.with_scope,
22
+ with_area: filter.with_area,
23
+ type_id_eq: type_id
22
24
  }
23
25
  )
24
26
  end
@@ -28,14 +30,16 @@ module Decidim
28
30
  end
29
31
 
30
32
  def current_filter_name
31
- type = AssembliesType.find_by(id: filter.type_id)
33
+ type = AssembliesType.find_by(id: filter_params[:type_id_eq])
32
34
  return translated_attribute type.title if type
33
35
 
34
36
  t("all", scope: "decidim.assemblies.filter")
35
37
  end
36
38
 
37
39
  def organization_assembly_types
38
- AssembliesType.where(organization: current_organization)&.map { |type| [translated_attribute(type.title), type.id] }
40
+ @organization_assembly_types ||= AssembliesType.where(organization: current_organization).joins(:assemblies).where(
41
+ decidim_assemblies: { id: search.result.unscope(where: :decidim_assemblies_type_id).parent_assemblies }
42
+ ).distinct&.map { |type| [translated_attribute(type.title), type.id] }
39
43
  end
40
44
  end
41
45
  end
@@ -34,6 +34,8 @@ module Decidim
34
34
  include Decidim::Searchable
35
35
  include Decidim::HasUploadValidations
36
36
  include Decidim::TranslatableResource
37
+ include Decidim::HasArea
38
+ include Decidim::FilterableResource
37
39
 
38
40
  SOCIAL_HANDLERS = [:twitter, :facebook, :instagram, :youtube, :github].freeze
39
41
  CREATED_BY = %w(city_council public others).freeze
@@ -146,7 +148,7 @@ module Decidim
146
148
  end
147
149
 
148
150
  def user_roles(role_name = nil)
149
- roles = Decidim::AssemblyUserRole.where(assembly: self)
151
+ roles = Decidim::AssemblyUserRole.where(assembly: self_and_ancestors)
150
152
  return roles if role_name.blank?
151
153
 
152
154
  roles.where(role: role_name)
@@ -156,6 +158,10 @@ module Decidim
156
158
  :admin
157
159
  end
158
160
 
161
+ def self.ransackable_scopes(_auth_object = nil)
162
+ [:with_area, :with_scope]
163
+ end
164
+
159
165
  private
160
166
 
161
167
  # When an assembly changes their parent, we need to update the parents_path attribute
@@ -208,8 +214,8 @@ module Decidim
208
214
  # rubocop:enable Rails/SkipsModelValidations
209
215
 
210
216
  # Allow ransacker to search for a key in a hstore column (`title`.`en`)
211
- ransacker :title do |parent|
212
- Arel::Nodes::InfixOperation.new("->>", parent.table[:title], Arel::Nodes.build_quoted(I18n.locale.to_s))
213
- end
217
+ ransacker_i18n :title
218
+
219
+ ransack_alias :type_id, :decidim_assemblies_type_id
214
220
  end
215
221
  end