decidim-admin 0.26.0 → 0.27.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim-admin might be problematic. Click here for more details.

Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/admin/attachments_privacy_warning/show.erb +3 -0
  3. data/app/cells/decidim/admin/attachments_privacy_warning_cell.rb +19 -0
  4. data/app/commands/decidim/admin/block_user.rb +1 -1
  5. data/app/commands/decidim/admin/close_session_managed_user.rb +1 -1
  6. data/app/commands/decidim/admin/create_area.rb +1 -1
  7. data/app/commands/decidim/admin/create_area_type.rb +6 -3
  8. data/app/commands/decidim/admin/create_attachment.rb +14 -6
  9. data/app/commands/decidim/admin/create_attachment_collection.rb +13 -4
  10. data/app/commands/decidim/admin/create_category.rb +6 -4
  11. data/app/commands/decidim/admin/create_component.rb +1 -1
  12. data/app/commands/decidim/admin/create_import.rb +4 -5
  13. data/app/commands/decidim/admin/create_import_example.rb +1 -1
  14. data/app/commands/decidim/admin/create_newsletter.rb +1 -1
  15. data/app/commands/decidim/admin/create_participatory_space_private_user.rb +1 -1
  16. data/app/commands/decidim/admin/create_scope.rb +1 -1
  17. data/app/commands/decidim/admin/create_scope_type.rb +6 -3
  18. data/app/commands/decidim/admin/create_static_page.rb +1 -1
  19. data/app/commands/decidim/admin/create_static_page_topic.rb +1 -1
  20. data/app/commands/decidim/admin/deliver_newsletter.rb +6 -6
  21. data/app/commands/decidim/admin/destroy_area.rb +1 -1
  22. data/app/commands/decidim/admin/destroy_category.rb +6 -3
  23. data/app/commands/decidim/admin/destroy_component.rb +1 -1
  24. data/app/commands/decidim/admin/destroy_newsletter.rb +1 -1
  25. data/app/commands/decidim/admin/destroy_participatory_space_private_user.rb +1 -1
  26. data/app/commands/decidim/admin/destroy_scope.rb +1 -1
  27. data/app/commands/decidim/admin/destroy_share_token.rb +1 -1
  28. data/app/commands/decidim/admin/destroy_static_page.rb +1 -1
  29. data/app/commands/decidim/admin/destroy_static_page_topic.rb +1 -1
  30. data/app/commands/decidim/admin/hide_resource.rb +2 -2
  31. data/app/commands/decidim/admin/impersonate_user.rb +1 -1
  32. data/app/commands/decidim/admin/invite_admin.rb +1 -1
  33. data/app/commands/decidim/admin/officialize_user.rb +1 -1
  34. data/app/commands/decidim/admin/process_participatory_space_private_user_import_csv.rb +7 -3
  35. data/app/commands/decidim/admin/process_user_group_verification_csv.rb +8 -4
  36. data/app/commands/decidim/admin/promote_managed_user.rb +1 -1
  37. data/app/commands/decidim/admin/publish_component.rb +1 -1
  38. data/app/commands/decidim/admin/reject_user_group.rb +1 -1
  39. data/app/commands/decidim/admin/remove_admin.rb +1 -1
  40. data/app/commands/decidim/admin/reorder_content_blocks.rb +1 -1
  41. data/app/commands/decidim/admin/transfer_user.rb +1 -1
  42. data/app/commands/decidim/admin/unblock_user.rb +1 -1
  43. data/app/commands/decidim/admin/unhide_resource.rb +1 -1
  44. data/app/commands/decidim/admin/unofficialize_user.rb +1 -1
  45. data/app/commands/decidim/admin/unpublish_component.rb +1 -1
  46. data/app/commands/decidim/admin/unreport_resource.rb +1 -1
  47. data/app/commands/decidim/admin/unreport_user.rb +1 -1
  48. data/app/commands/decidim/admin/update_area.rb +1 -1
  49. data/app/commands/decidim/admin/update_area_type.rb +8 -3
  50. data/app/commands/decidim/admin/update_attachment.rb +4 -3
  51. data/app/commands/decidim/admin/update_attachment_collection.rb +8 -3
  52. data/app/commands/decidim/admin/update_category.rb +9 -5
  53. data/app/commands/decidim/admin/update_component.rb +8 -5
  54. data/app/commands/decidim/admin/update_component_permissions.rb +9 -6
  55. data/app/commands/decidim/admin/update_content_block.rb +1 -1
  56. data/app/commands/decidim/admin/update_external_domain_whitelist.rb +6 -3
  57. data/app/commands/decidim/admin/update_help_sections.rb +17 -3
  58. data/app/commands/decidim/admin/update_newsletter.rb +1 -1
  59. data/app/commands/decidim/admin/update_organization.rb +1 -1
  60. data/app/commands/decidim/admin/update_organization_appearance.rb +1 -1
  61. data/app/commands/decidim/admin/update_organization_tos_version.rb +1 -1
  62. data/app/commands/decidim/admin/update_resource_permissions.rb +2 -2
  63. data/app/commands/decidim/admin/update_scope.rb +1 -1
  64. data/app/commands/decidim/admin/update_scope_type.rb +8 -3
  65. data/app/commands/decidim/admin/update_static_page.rb +1 -1
  66. data/app/commands/decidim/admin/update_static_page_topic.rb +1 -1
  67. data/app/commands/decidim/admin/update_user_groups.rb +1 -1
  68. data/app/commands/decidim/admin/verify_user_group.rb +1 -1
  69. data/app/controllers/concerns/decidim/admin/filterable.rb +1 -1
  70. data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +3 -1
  71. data/app/controllers/decidim/admin/application_controller.rb +1 -0
  72. data/app/controllers/decidim/admin/area_types_controller.rb +6 -3
  73. data/app/controllers/decidim/admin/categories_controller.rb +3 -3
  74. data/app/controllers/decidim/admin/component_permissions_controller.rb +1 -1
  75. data/app/controllers/decidim/admin/components/base_controller.rb +1 -0
  76. data/app/controllers/decidim/admin/components_controller.rb +1 -1
  77. data/app/controllers/decidim/admin/concerns/has_attachment_collections.rb +6 -3
  78. data/app/controllers/decidim/admin/concerns/has_attachments.rb +6 -3
  79. data/app/controllers/decidim/admin/concerns/has_private_users_csv_import.rb +7 -0
  80. data/app/controllers/decidim/admin/conflicts_controller.rb +3 -1
  81. data/app/controllers/decidim/admin/dashboard_controller.rb +4 -3
  82. data/app/controllers/decidim/admin/exports_controller.rb +4 -1
  83. data/app/controllers/decidim/admin/help_sections_controller.rb +1 -1
  84. data/app/controllers/decidim/admin/metrics_controller.rb +2 -1
  85. data/app/controllers/decidim/admin/moderations_controller.rb +9 -7
  86. data/app/controllers/decidim/admin/organization_external_domain_whitelist_controller.rb +1 -1
  87. data/app/controllers/decidim/admin/reminders_controller.rb +61 -0
  88. data/app/controllers/decidim/admin/resource_permissions_controller.rb +2 -2
  89. data/app/controllers/decidim/admin/scope_types_controller.rb +6 -3
  90. data/app/controllers/decidim/admin/static_pages_controller.rb +1 -7
  91. data/app/forms/decidim/admin/category_form.rb +1 -2
  92. data/app/forms/decidim/admin/component_form.rb +16 -7
  93. data/app/forms/decidim/admin/import_example_form.rb +1 -5
  94. data/app/forms/decidim/admin/import_form.rb +7 -10
  95. data/app/forms/decidim/admin/managed_user_promotion_form.rb +1 -1
  96. data/app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb +7 -4
  97. data/app/forms/decidim/admin/permission_form.rb +9 -8
  98. data/app/forms/decidim/admin/permissions_form.rb +1 -10
  99. data/app/forms/decidim/admin/selective_newsletter_form.rb +1 -1
  100. data/app/forms/decidim/admin/user_group_csv_verification_form.rb +2 -2
  101. data/app/helpers/decidim/admin/bulk_actions_helper.rb +0 -4
  102. data/app/helpers/decidim/admin/moderations/reports_helper.rb +11 -2
  103. data/app/helpers/decidim/admin/newsletters_helper.rb +1 -1
  104. data/app/helpers/decidim/admin/reminders_helper.rb +12 -0
  105. data/app/packs/entrypoints/decidim_admin.js +2 -1
  106. data/app/packs/src/decidim/admin/admin_autocomplete.js +82 -0
  107. data/app/packs/src/decidim/admin/application.js +0 -16
  108. data/app/packs/stylesheets/decidim/admin/_decidim.scss +0 -1
  109. data/app/packs/stylesheets/decidim/admin/modules/_autocomplete.scss +5 -0
  110. data/app/packs/stylesheets/decidim/admin/modules/_modules.scss +2 -0
  111. data/app/packs/stylesheets/decidim/admin/modules/_upload_modal.scss +42 -0
  112. data/app/permissions/decidim/admin/permissions.rb +1 -0
  113. data/app/presenters/decidim/admin/dashboard_metric_charts_presenter.rb +3 -1
  114. data/app/queries/decidim/admin/active_users_counter.rb +1 -1
  115. data/app/queries/decidim/admin/newsletter_recipients.rb +5 -4
  116. data/app/queries/decidim/admin/user_filter.rb +1 -1
  117. data/app/queries/decidim/admin/user_groups_evaluation.rb +1 -1
  118. data/app/views/decidim/admin/attachments/index.html.erb +1 -0
  119. data/app/views/decidim/admin/categories/_form.html.erb +0 -4
  120. data/app/views/decidim/admin/categories/show.html.erb +1 -2
  121. data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +6 -6
  122. data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +5 -4
  123. data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +1 -1
  124. data/app/views/decidim/admin/participatory_space_private_users_csv_imports/new.html.erb +20 -1
  125. data/app/views/decidim/admin/reminders/new.html.erb +21 -0
  126. data/app/views/decidim/admin/shared/_gallery.html.erb +6 -1
  127. data/app/views/decidim/admin/shared/_js-callout.html.erb +6 -0
  128. data/app/views/decidim/admin/users_statistics/_users_count.html.erb +2 -2
  129. data/app/views/layouts/decidim/admin/_application.html.erb +2 -0
  130. data/config/locales/am-ET.yml +1 -0
  131. data/config/locales/ar.yml +242 -28
  132. data/config/locales/bg.yml +1 -0
  133. data/config/locales/ca.yml +28 -6
  134. data/config/locales/cs.yml +29 -5
  135. data/config/locales/da.yml +1 -0
  136. data/config/locales/de.yml +47 -5
  137. data/config/locales/el.yml +1 -6
  138. data/config/locales/en.yml +26 -5
  139. data/config/locales/eo.yml +1 -0
  140. data/config/locales/es-MX.yml +27 -5
  141. data/config/locales/es-PY.yml +27 -5
  142. data/config/locales/es.yml +28 -6
  143. data/config/locales/et.yml +1 -0
  144. data/config/locales/eu.yml +1 -6
  145. data/config/locales/fi-plain.yml +27 -5
  146. data/config/locales/fi.yml +27 -5
  147. data/config/locales/fr-CA.yml +26 -4
  148. data/config/locales/fr.yml +26 -4
  149. data/config/locales/ga-IE.yml +1 -1
  150. data/config/locales/gl.yml +16 -5
  151. data/config/locales/hr.yml +1 -0
  152. data/config/locales/hu.yml +25 -4
  153. data/config/locales/id-ID.yml +1 -3
  154. data/config/locales/is-IS.yml +2 -4
  155. data/config/locales/it.yml +6 -6
  156. data/config/locales/ja.yml +38 -17
  157. data/config/locales/ko.yml +1 -0
  158. data/config/locales/lb.yml +1 -6
  159. data/config/locales/lt.yml +946 -0
  160. data/config/locales/lv.yml +1 -3
  161. data/config/locales/mt.yml +1 -0
  162. data/config/locales/nl.yml +1 -6
  163. data/config/locales/no.yml +13 -7
  164. data/config/locales/om-ET.yml +1 -0
  165. data/config/locales/pl.yml +82 -5
  166. data/config/locales/pt-BR.yml +2 -7
  167. data/config/locales/pt.yml +1 -6
  168. data/config/locales/ro-RO.yml +7 -6
  169. data/config/locales/ru.yml +1 -3
  170. data/config/locales/si-LK.yml +1 -0
  171. data/config/locales/sk.yml +1 -3
  172. data/config/locales/sl.yml +1 -0
  173. data/config/locales/so-SO.yml +1 -0
  174. data/config/locales/sr-CS.yml +1 -2
  175. data/config/locales/sv.yml +30 -8
  176. data/config/locales/sw-KE.yml +1 -0
  177. data/config/locales/ti-ER.yml +1 -0
  178. data/config/locales/tr-TR.yml +1 -4
  179. data/config/locales/uk.yml +1 -2
  180. data/config/locales/val-ES.yml +1 -0
  181. data/config/locales/vi.yml +1 -0
  182. data/config/locales/zh-CN.yml +1 -3
  183. data/config/locales/zh-TW.yml +1 -0
  184. data/lib/decidim/admin/engine.rb +0 -1
  185. data/lib/decidim/admin/import/importer.rb +9 -7
  186. data/lib/decidim/admin/import/readers/json.rb +1 -1
  187. data/lib/decidim/admin/test/commands/create_attachment_collection_examples.rb +15 -2
  188. data/lib/decidim/admin/test/commands/create_category_examples.rb +16 -6
  189. data/lib/decidim/admin/test/commands/destroy_category_examples.rb +29 -1
  190. data/lib/decidim/admin/test/commands/update_attachment_collection_examples.rb +15 -2
  191. data/lib/decidim/admin/test/commands/update_category_examples.rb +16 -6
  192. data/lib/decidim/admin/test/filters_participatory_space_user_roles_examples.rb +4 -4
  193. data/lib/decidim/admin/test/filters_participatory_space_users_examples.rb +4 -4
  194. data/lib/decidim/admin/test/forms/category_form_examples.rb +1 -21
  195. data/lib/decidim/admin/test/manage_attachments_examples.rb +9 -2
  196. data/lib/decidim/admin/test/manage_categories_examples.rb +0 -10
  197. data/lib/decidim/admin/test/manage_component_permissions_examples.rb +0 -2
  198. data/lib/decidim/admin/test/manage_moderations_examples.rb +26 -0
  199. data/lib/decidim/admin/version.rb +1 -1
  200. metadata +21 -15
  201. data/app/packs/src/decidim/admin/autocomplete.component.js +0 -146
  202. data/app/packs/src/decidim/admin/autocomplete.component.test.js +0 -19
  203. data/app/packs/stylesheets/decidim/admin/components/_autocomplete_select.component.scss +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86afc8162ed8463d2e4871528607fa140587c24510441f53ea9636bc49668874
4
- data.tar.gz: 3ad4e80c83cbdd59cc006c84a6110ba28aa85a26056b85ca3c5b6fb62e68b93f
3
+ metadata.gz: bd57dbd303809b47c0bbf9c466c4ed731f6e3d4c8b6604d1adb478114f5ef0cb
4
+ data.tar.gz: e77d08a54416dbff1d3481d3ddf32de28828d475143ff5cb4b5c536114106c45
5
5
  SHA512:
6
- metadata.gz: 6bd5c8d8cf9b364ca551b17f139a55cb260825b6af6dc05aa286928bc6df0158b714b01b7706e083b33d53d997ec844db76488c7d7fcb6caabc24d893dba11e2
7
- data.tar.gz: 00fe8f9837da7f2b6a0602c77b5e0e497f464e4ed868b767d336d00ad705095899cc27cf48e934e1f8ef5e85b0ca6977d1884854caa7b46f04d3cc7388fcc3aa
6
+ metadata.gz: b97e7a0cdb53e8c909c42e7fc6b2cd345f66f61c67648a3c086ad2db8ba9e9dc936e60d51cfaf7689d086d4c9a1f347b2432f22f9e7590743bec4897c278cf17
7
+ data.tar.gz: 96cb283bb59d1026e5de9d917db4dbf185ef5384442a9166f1211077c757554d6680dec253d1408da3924ae381b9dfcbb590f50c1cd73bd80b5120c4cd1cba78
@@ -0,0 +1,3 @@
1
+ <% if private_space? && !(transparent_space?) %>
2
+ <div class="callout warning"><%= t("decidim.admin.attachments_privacy_warning.message") %></div>
3
+ <% end %>
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ class AttachmentsPrivacyWarningCell < Decidim::ViewModel
6
+ delegate :current_participatory_space, to: :controller
7
+
8
+ private
9
+
10
+ def private_space?
11
+ current_participatory_space.private_space if current_participatory_space.respond_to?(:private_space)
12
+ end
13
+
14
+ def transparent_space?
15
+ current_participatory_space.is_transparent if current_participatory_space.respond_to?(:is_transparent)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module Admin
5
- class BlockUser < Rectify::Command
5
+ class BlockUser < Decidim::Command
6
6
  # Public: Initializes the command.
7
7
  #
8
8
  # form - BlockUserForm
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic to close a current impersonation session.
6
- class CloseSessionManagedUser < Rectify::Command
6
+ class CloseSessionManagedUser < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # user - The user impersonated.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when creating an area
6
- class CreateArea < Rectify::Command
6
+ class CreateArea < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - A form object with the params.
@@ -3,12 +3,13 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when creating an area type.
6
- class CreateAreaType < Rectify::Command
6
+ class CreateAreaType < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - A form object with the params.
10
- def initialize(form)
10
+ def initialize(form, user)
11
11
  @form = form
12
+ @user = user
12
13
  end
13
14
 
14
15
  # Executes the command. Broadcasts these events:
@@ -29,7 +30,9 @@ module Decidim
29
30
  attr_reader :form
30
31
 
31
32
  def create_area_type
32
- AreaType.create!(
33
+ Decidim.traceability.create!(
34
+ AreaType,
35
+ @user,
33
36
  name: form.name,
34
37
  organization: form.organization,
35
38
  plural: form.plural
@@ -4,14 +4,15 @@ module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic to add an attachment to a
6
6
  # participatory process.
7
- class CreateAttachment < Rectify::Command
7
+ class CreateAttachment < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A form object with the params.
11
11
  # attached_to - The ActiveRecord::Base that will hold the attachment
12
- def initialize(form, attached_to)
12
+ def initialize(form, attached_to, user)
13
13
  @form = form
14
14
  @attached_to = attached_to
15
+ @user = user
15
16
  end
16
17
 
17
18
  # Executes the command. Broadcasts these events:
@@ -26,9 +27,12 @@ module Decidim
26
27
  build_attachment
27
28
 
28
29
  if @attachment.valid?
29
- @attachment.save!
30
- notify_followers
31
- broadcast(:ok)
30
+ Decidim.traceability.perform_action!(:create, Decidim::Attachment, @user) do
31
+ @attachment.save!
32
+ notify_followers
33
+ broadcast(:ok)
34
+ @attachment
35
+ end
32
36
  else
33
37
  @form.errors.add :file, @attachment.errors[:file] if @attachment.errors.has_key? :file
34
38
  broadcast(:invalid)
@@ -47,7 +51,7 @@ module Decidim
47
51
  weight: form.weight,
48
52
  attachment_collection: form.attachment_collection,
49
53
  file: form.file, # Define attached_to before this
50
- content_type: form.file.content_type
54
+ content_type: blob(form.file).content_type
51
55
  )
52
56
  end
53
57
 
@@ -61,6 +65,10 @@ module Decidim
61
65
  followers: @attachment.attached_to.followers
62
66
  )
63
67
  end
68
+
69
+ def blob(signed_id)
70
+ ActiveStorage::Blob.find_signed(signed_id)
71
+ end
64
72
  end
65
73
  end
66
74
  end
@@ -4,14 +4,15 @@ module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic to add an attachment collection
6
6
  # to a participatory space.
7
- class CreateAttachmentCollection < Rectify::Command
7
+ class CreateAttachmentCollection < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A form object with the params.
11
11
  # collection_for - The ActiveRecord::Base that will hold the collection
12
- def initialize(form, collection_for)
12
+ def initialize(form, collection_for, user)
13
13
  @form = form
14
14
  @collection_for = collection_for
15
+ @user = user
15
16
  end
16
17
 
17
18
  # Executes the command. Broadcasts these events:
@@ -32,12 +33,20 @@ module Decidim
32
33
  attr_reader :form
33
34
 
34
35
  def create_attachment_collection
35
- AttachmentCollection.create!(
36
+ Decidim.traceability.create!(
37
+ AttachmentCollection,
38
+ @user,
39
+ attributes
40
+ )
41
+ end
42
+
43
+ def attributes
44
+ {
36
45
  name: form.name,
37
46
  weight: form.weight,
38
47
  description: form.description,
39
48
  collection_for: @collection_for
40
- )
49
+ }
41
50
  end
42
51
  end
43
52
  end
@@ -4,15 +4,16 @@ module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic to create a new category in the
6
6
  # system.
7
- class CreateCategory < Rectify::Command
7
+ class CreateCategory < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A form object with the params.
11
11
  # participatory_space - The participatory space that will hold the
12
12
  # category
13
- def initialize(form, participatory_space)
13
+ def initialize(form, participatory_space, user)
14
14
  @form = form
15
15
  @participatory_space = participatory_space
16
+ @user = user
16
17
  end
17
18
 
18
19
  # Executes the command. Broadcasts these events:
@@ -33,10 +34,11 @@ module Decidim
33
34
  attr_reader :form
34
35
 
35
36
  def create_category
36
- Category.create!(
37
+ Decidim.traceability.create!(
38
+ Category,
39
+ @user,
37
40
  name: form.name,
38
41
  weight: form.weight,
39
- description: form.description,
40
42
  parent_id: form.parent_id,
41
43
  participatory_space: @participatory_space
42
44
  )
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # This command gets called when a component is created from the admin panel.
6
- class CreateComponent < Rectify::Command
6
+ class CreateComponent < Decidim::Command
7
7
  attr_reader :form, :manifest, :participatory_space
8
8
 
9
9
  # Public: Initializes the command.
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module Admin
5
- class CreateImport < Rectify::Command
5
+ class CreateImport < Decidim::Command
6
6
  def initialize(form)
7
7
  @form = form
8
8
  end
@@ -14,13 +14,12 @@ module Decidim
14
14
  transaction do
15
15
  form.importer.import!
16
16
 
17
- return broadcast(:ok, imported_data)
17
+ broadcast(:ok, imported_data)
18
18
  rescue StandardError
19
+ # Something went wrong with import/finish
20
+ broadcast(:invalid)
19
21
  raise ActiveRecord::Rollback
20
22
  end
21
-
22
- # Something went wrong with import/finish
23
- broadcast(:invalid)
24
23
  end
25
24
 
26
25
  attr_reader :form
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module Admin
5
- class CreateImportExample < Rectify::Command
5
+ class CreateImportExample < Decidim::Command
6
6
  def initialize(form)
7
7
  @form = form
8
8
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Admin
5
5
  # Creates a newsletter and assigns the right author and
6
6
  # organization.
7
- class CreateNewsletter < Rectify::Command
7
+ class CreateNewsletter < Decidim::Command
8
8
  # Initializes the command.
9
9
  #
10
10
  # form - The source fo data for this newsletter.
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when creating a new participatory space
6
6
  # private user in the system.
7
- class CreateParticipatorySpacePrivateUser < Rectify::Command
7
+ class CreateParticipatorySpacePrivateUser < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # form - A form object with the params.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when creating a static scope.
6
- class CreateScope < Rectify::Command
6
+ class CreateScope < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - A form object with the params.
@@ -3,12 +3,13 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when creating a scope type.
6
- class CreateScopeType < Rectify::Command
6
+ class CreateScopeType < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - A form object with the params.
10
- def initialize(form)
10
+ def initialize(form, user)
11
11
  @form = form
12
+ @user = user
12
13
  end
13
14
 
14
15
  # Executes the command. Broadcasts these events:
@@ -29,7 +30,9 @@ module Decidim
29
30
  attr_reader :form
30
31
 
31
32
  def create_scope_type
32
- ScopeType.create!(
33
+ Decidim.traceability.create!(
34
+ ScopeType,
35
+ @user,
33
36
  name: form.name,
34
37
  organization: form.organization,
35
38
  plural: form.plural
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when creating a static page.
6
- class CreateStaticPage < Rectify::Command
6
+ class CreateStaticPage < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - A form object with the params.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when creating a static page topic.
6
- class CreateStaticPageTopic < Rectify::Command
6
+ class CreateStaticPageTopic < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - A form object with the params.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # Delivers the newsletter to its recipients.
6
- class DeliverNewsletter < Rectify::Command
6
+ class DeliverNewsletter < Decidim::Command
7
7
  # Initializes the command.
8
8
  #
9
9
  # newsletter - The newsletter to deliver.
@@ -16,12 +16,12 @@ module Decidim
16
16
  end
17
17
 
18
18
  def call
19
- @newsletter.with_lock do
20
- return broadcast(:invalid) if @form.send_to_all_users && !@user.admin?
21
- return broadcast(:invalid) unless @form.valid?
22
- return broadcast(:invalid) if @newsletter.sent?
23
- return broadcast(:no_recipients) if recipients.blank?
19
+ return broadcast(:invalid) if @form.send_to_all_users && !@user.admin?
20
+ return broadcast(:invalid) unless @form.valid?
21
+ return broadcast(:invalid) if @newsletter.sent?
22
+ return broadcast(:no_recipients) if recipients.blank?
24
23
 
24
+ @newsletter.with_lock do
25
25
  send_newsletter!
26
26
  end
27
27
 
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic to destroy an area.
6
- class DestroyArea < Rectify::Command
6
+ class DestroyArea < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # area - The area to destroy
@@ -4,12 +4,13 @@ module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic to destroy a category in the
6
6
  # system.
7
- class DestroyCategory < Rectify::Command
7
+ class DestroyCategory < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # category - A Category that will be destroyed
11
- def initialize(category)
11
+ def initialize(category, user)
12
12
  @category = category
13
+ @user = user
13
14
  end
14
15
 
15
16
  # Executes the command. Broadcasts these events:
@@ -30,7 +31,9 @@ module Decidim
30
31
  attr_reader :category
31
32
 
32
33
  def destroy_category
33
- category.destroy!
34
+ Decidim.traceability.perform_action!(:delete, category, @user) do
35
+ category.destroy!
36
+ end
34
37
  end
35
38
  end
36
39
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # This command deals with destroying a Component from the admin panel.
6
- class DestroyComponent < Rectify::Command
6
+ class DestroyComponent < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # component - The Component to be destroyed.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # This command deals with destroying a newsletter from the admin panel.
6
- class DestroyNewsletter < Rectify::Command
6
+ class DestroyNewsletter < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # newsletter - The Newsletter to be destroyed.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic to destroy a participatory space private user.
6
- class DestroyParticipatorySpacePrivateUser < Rectify::Command
6
+ class DestroyParticipatorySpacePrivateUser < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # participatory_space_private_user - The participatory space private user to destroy
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic to destroy a scope.
6
- class DestroyScope < Rectify::Command
6
+ class DestroyScope < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # scope - The Scope to destroy
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic to destroy a share token.
6
- class DestroyShareToken < Rectify::Command
6
+ class DestroyShareToken < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # share_token - The share_token to destroy
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # This command deals with destroying a StaticPage from the admin panel.
6
- class DestroyStaticPage < Rectify::Command
6
+ class DestroyStaticPage < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # page - The StaticPage to be destroyed.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # This command deals with destroying a StaticPageTopic from the admin panel.
6
- class DestroyStaticPageTopic < Rectify::Command
6
+ class DestroyStaticPageTopic < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # page - The StaticPageTopic to be destroyed.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when a user hides a resource.
6
- class HideResource < Rectify::Command
6
+ class HideResource < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # reportable - A Decidim::Reportable
@@ -60,7 +60,7 @@ module Decidim
60
60
  affected_users: @reportable.try(:authors) || [@reportable.try(:normalized_author)]
61
61
  }
62
62
 
63
- Decidim::EventsManager.publish(data)
63
+ Decidim::EventsManager.publish(**data)
64
64
  end
65
65
 
66
66
  def report_reasons
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic to impersonate a managed user.
6
- class ImpersonateUser < Rectify::Command
6
+ class ImpersonateUser < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - The form with the authorization info
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command to invite an admin.
6
- class InviteAdmin < Rectify::Command
6
+ class InviteAdmin < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - A form object with the params.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when officializing a user.
6
- class OfficializeUser < Rectify::Command
6
+ class OfficializeUser < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form - The officialization form.
@@ -4,7 +4,9 @@ require "csv"
4
4
 
5
5
  module Decidim
6
6
  module Admin
7
- class ProcessParticipatorySpacePrivateUserImportCsv < Rectify::Command
7
+ class ProcessParticipatorySpacePrivateUserImportCsv < Decidim::Command
8
+ include Decidim::ProcessesFileLocally
9
+
8
10
  # Public: Initializes the command.
9
11
  #
10
12
  # form - the form object containing the uploaded file
@@ -32,8 +34,10 @@ module Decidim
32
34
  private
33
35
 
34
36
  def process_csv
35
- CSV.foreach(@form.file.path, encoding: "BOM|UTF-8") do |email, user_name|
36
- ImportParticipatorySpacePrivateUserCsvJob.perform_later(email, user_name, @private_users_to, @current_user) if email.present? && user_name.present?
37
+ process_file_locally(@form.file) do |file_path|
38
+ CSV.foreach(file_path, encoding: "BOM|UTF-8") do |email, user_name|
39
+ ImportParticipatorySpacePrivateUserCsvJob.perform_later(email, user_name, @private_users_to, @current_user) if email.present? && user_name.present?
40
+ end
37
41
  end
38
42
  end
39
43
  end
@@ -6,7 +6,9 @@ module Decidim
6
6
  module Admin
7
7
  # A command with all the business logic when processing the CSV to verify
8
8
  # user groups.
9
- class ProcessUserGroupVerificationCsv < Rectify::Command
9
+ class ProcessUserGroupVerificationCsv < Decidim::Command
10
+ include Decidim::ProcessesFileLocally
11
+
10
12
  # Public: Initializes the command.
11
13
  #
12
14
  # form - the form object containing the uploaded file
@@ -33,9 +35,11 @@ module Decidim
33
35
  verifier = @form.current_user
34
36
  organization = @form.current_organization
35
37
 
36
- CSV.foreach(@form.file.path) do |row|
37
- email = row[0]
38
- VerifyUserGroupFromCsvJob.perform_later(email, verifier, organization) if email.present?
38
+ process_file_locally(@form.file) do |file_path|
39
+ CSV.foreach(file_path) do |row|
40
+ email = row[0]
41
+ VerifyUserGroupFromCsvJob.perform_later(email, verifier, organization) if email.present?
42
+ end
39
43
  end
40
44
  end
41
45
  end
@@ -7,7 +7,7 @@ module Decidim
7
7
  # Managed users can be promoted to standard users. It means they
8
8
  # will be invited to the application and will lose the managed flag
9
9
  # so the user cannot be impersonated anymore.
10
- class PromoteManagedUser < Rectify::Command
10
+ class PromoteManagedUser < Decidim::Command
11
11
  # Public: Initializes the command.
12
12
  #
13
13
  # form - A form object with the params.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # This command gets called when a component is published from the admin panel.
6
- class PublishComponent < Rectify::Command
6
+ class PublishComponent < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # component - The component to publish.
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when rejecting a user_group.
6
- class RejectUserGroup < Rectify::Command
6
+ class RejectUserGroup < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # user_group - The user_group to reject
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command to remove the admin privilege to an user.
6
- class RemoveAdmin < Rectify::Command
6
+ class RemoveAdmin < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # user - the user that will no longer be an admin
@@ -4,7 +4,7 @@ module Decidim
4
4
  module Admin
5
5
  # A command that reorders a collection of content blocks. It also creates
6
6
  # the ones that might be missing.
7
- class ReorderContentBlocks < Rectify::Command
7
+ class ReorderContentBlocks < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # organization - the Organization where the content blocks reside
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic to transfer a managed user.
6
- class TransferUser < Rectify::Command
6
+ class TransferUser < Decidim::Command
7
7
  # Public: Initializes the command.
8
8
  #
9
9
  # form