decidim-admin 0.31.8 → 0.32.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -12
  3. data/app/cells/decidim/admin/attachments_privacy_warning/show.erb +1 -1
  4. data/app/cells/decidim/admin/attachments_privacy_warning_cell.rb +2 -6
  5. data/app/commands/decidim/admin/content_blocks/reorder_content_blocks.rb +1 -1
  6. data/app/commands/decidim/admin/create_newsletter.rb +1 -1
  7. data/app/commands/decidim/admin/create_taxonomy_filter.rb +2 -16
  8. data/app/commands/decidim/admin/participatory_space/create_member.rb +99 -0
  9. data/app/commands/decidim/admin/participatory_space/destroy_member.rb +30 -0
  10. data/app/commands/decidim/admin/participatory_space/import_member_csv.rb +46 -0
  11. data/app/commands/decidim/admin/participatory_space/publish_all_members.rb +52 -0
  12. data/app/commands/decidim/admin/participatory_space/unpublish_all_members.rb +52 -0
  13. data/app/commands/decidim/admin/participatory_space/update_member.rb +13 -0
  14. data/app/commands/decidim/admin/reorder_components.rb +1 -1
  15. data/app/commands/decidim/admin/reorder_taxonomies.rb +1 -1
  16. data/app/commands/decidim/admin/update_organization.rb +1 -1
  17. data/app/commands/decidim/admin/update_taxonomy_filter.rb +6 -24
  18. data/app/controllers/concerns/decidim/admin/component_taxonomies_helper.rb +1 -1
  19. data/app/controllers/concerns/decidim/admin/content_blocks/landing_page.rb +6 -5
  20. data/app/controllers/concerns/decidim/admin/content_blocks/landing_page_content_blocks.rb +3 -2
  21. data/app/controllers/concerns/decidim/admin/filterable.rb +4 -4
  22. data/app/controllers/concerns/decidim/admin/global_moderation_context.rb +0 -2
  23. data/app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb +1 -2
  24. data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +1 -3
  25. data/app/controllers/decidim/admin/admin_terms_controller.rb +0 -1
  26. data/app/controllers/decidim/admin/application_controller.rb +0 -2
  27. data/app/controllers/decidim/admin/area_types_controller.rb +2 -2
  28. data/app/controllers/decidim/admin/areas_controller.rb +3 -2
  29. data/app/controllers/decidim/admin/block_user_controller.rb +2 -6
  30. data/app/controllers/decidim/admin/component_permissions_controller.rb +1 -1
  31. data/app/controllers/decidim/admin/components/base_controller.rb +3 -4
  32. data/app/controllers/decidim/admin/components_controller.rb +5 -4
  33. data/app/controllers/decidim/admin/concerns/has_attachment_collections.rb +2 -4
  34. data/app/controllers/decidim/admin/concerns/has_attachments.rb +2 -4
  35. data/app/controllers/decidim/admin/concerns/has_breadcrumb_items.rb +0 -4
  36. data/app/controllers/decidim/admin/conflicts_controller.rb +6 -6
  37. data/app/controllers/decidim/admin/exports_controller.rb +1 -1
  38. data/app/controllers/decidim/admin/global_moderations/reports_controller.rb +0 -2
  39. data/app/controllers/decidim/admin/global_moderations_controller.rb +0 -2
  40. data/app/controllers/decidim/admin/help_sections_controller.rb +3 -3
  41. data/app/controllers/decidim/admin/impersonations_controller.rb +2 -3
  42. data/app/controllers/decidim/admin/imports_controller.rb +2 -1
  43. data/app/controllers/decidim/admin/managed_users/impersonation_logs_controller.rb +1 -1
  44. data/app/controllers/decidim/admin/managed_users/promotions_controller.rb +1 -1
  45. data/app/controllers/decidim/admin/moderated_users_controller.rb +0 -3
  46. data/app/controllers/decidim/admin/moderations_controller.rb +0 -4
  47. data/app/controllers/decidim/admin/newsletter_templates_controller.rb +1 -4
  48. data/app/controllers/decidim/admin/newsletters_controller.rb +9 -12
  49. data/app/controllers/decidim/admin/officializations_controller.rb +0 -2
  50. data/app/controllers/decidim/admin/organization_appearance_controller.rb +1 -1
  51. data/app/controllers/decidim/admin/organization_controller.rb +30 -1
  52. data/app/controllers/decidim/admin/organization_external_domain_allowlist_controller.rb +1 -1
  53. data/app/controllers/decidim/admin/organization_homepage_controller.rb +3 -7
  54. data/app/controllers/decidim/admin/participatory_space/concerns/has_members.rb +166 -0
  55. data/app/controllers/decidim/admin/participatory_space/concerns/has_members_csv_import.rb +67 -0
  56. data/app/controllers/decidim/admin/participatory_space/concerns/members_filterable.rb +36 -0
  57. data/app/controllers/decidim/admin/participatory_space/user_role_controller.rb +2 -2
  58. data/app/controllers/decidim/admin/reminders_controller.rb +1 -1
  59. data/app/controllers/decidim/admin/resource_permissions_controller.rb +1 -5
  60. data/app/controllers/decidim/admin/scope_types_controller.rb +2 -2
  61. data/app/controllers/decidim/admin/scopes_controller.rb +3 -2
  62. data/app/controllers/decidim/admin/share_tokens_controller.rb +2 -2
  63. data/app/controllers/decidim/admin/space_publications_controller.rb +2 -2
  64. data/app/controllers/decidim/admin/static_page_topics_controller.rb +2 -2
  65. data/app/controllers/decidim/admin/static_pages_controller.rb +27 -29
  66. data/app/controllers/decidim/admin/taxonomies_controller.rb +3 -3
  67. data/app/controllers/decidim/admin/taxonomy_filters_controller.rb +5 -5
  68. data/app/controllers/decidim/admin/taxonomy_filters_selector_controller.rb +1 -1
  69. data/app/controllers/decidim/admin/taxonomy_items_controller.rb +3 -3
  70. data/app/controllers/decidim/admin/users_controller.rb +1 -1
  71. data/app/forms/decidim/admin/content_block_form.rb +28 -1
  72. data/app/forms/decidim/admin/organization_form.rb +0 -1
  73. data/app/forms/decidim/admin/participatory_space/member_csv_import_form.rb +33 -0
  74. data/app/forms/decidim/admin/participatory_space/member_form.rb +26 -0
  75. data/app/forms/decidim/admin/participatory_space_admin_user_form.rb +1 -1
  76. data/app/forms/decidim/admin/selective_newsletter_form.rb +7 -7
  77. data/app/forms/decidim/admin/taxonomy_filter_form.rb +10 -11
  78. data/app/helpers/decidim/admin/newsletters_helper.rb +8 -5
  79. data/app/helpers/decidim/admin/search_form_helper.rb +17 -0
  80. data/app/helpers/decidim/admin/settings_helper.rb +2 -0
  81. data/app/jobs/decidim/admin/newsletter_job.rb +2 -1
  82. data/app/jobs/decidim/admin/participatory_space/destroy_members_follows_job.rb +36 -0
  83. data/app/jobs/decidim/admin/participatory_space/import_member_csv_job.rb +29 -0
  84. data/app/packs/src/decidim/admin/admin_autocomplete.js +10 -16
  85. data/app/packs/src/decidim/admin/controllers/access_mode/access_mode.test.js +68 -0
  86. data/app/packs/src/decidim/admin/controllers/access_mode/controller.js +52 -0
  87. data/app/packs/src/decidim/admin/newsletters.js +2 -2
  88. data/app/packs/stylesheets/decidim/admin/_datepicker.scss +0 -4
  89. data/app/packs/stylesheets/decidim/admin/_sidebar-menu.scss +1 -3
  90. data/app/packs/stylesheets/decidim/admin/application.scss +1 -1
  91. data/app/permissions/decidim/admin/permissions.rb +0 -16
  92. data/app/queries/decidim/admin/newsletter_recipients.rb +8 -8
  93. data/app/views/decidim/admin/admin_terms/show.html.erb +3 -1
  94. data/app/views/decidim/admin/area_types/index.html.erb +3 -2
  95. data/app/views/decidim/admin/areas/index.html.erb +3 -2
  96. data/app/views/decidim/admin/attachment_collections/edit.html.erb +2 -2
  97. data/app/views/decidim/admin/attachment_collections/index.html.erb +3 -3
  98. data/app/views/decidim/admin/attachment_collections/new.html.erb +2 -2
  99. data/app/views/decidim/admin/attachments/index.html.erb +3 -2
  100. data/app/views/decidim/admin/authorization_workflows/index.html.erb +2 -2
  101. data/app/views/decidim/admin/block_user/new.html.erb +1 -0
  102. data/app/views/decidim/admin/components/_actions.html.erb +1 -1
  103. data/app/views/decidim/admin/components/index.html.erb +2 -2
  104. data/app/views/decidim/admin/components/manage_trash.html.erb +2 -2
  105. data/app/views/decidim/admin/conflicts/edit.html.erb +3 -1
  106. data/app/views/decidim/admin/conflicts/index.html.erb +3 -2
  107. data/app/views/decidim/admin/dashboard/show.html.erb +4 -4
  108. data/app/views/decidim/admin/help_sections/update.html.erb +2 -0
  109. data/app/views/decidim/admin/impersonatable_users/index.html.erb +3 -2
  110. data/app/views/decidim/admin/impersonations/_form.html.erb +2 -2
  111. data/app/views/decidim/admin/impersonations/new.html.erb +3 -2
  112. data/app/views/decidim/admin/imports/new.html.erb +1 -0
  113. data/app/views/decidim/admin/logs/_logs_list.html.erb +1 -1
  114. data/app/views/decidim/admin/logs/index.html.erb +1 -1
  115. data/app/views/decidim/admin/managed_users/impersonation_logs/index.html.erb +6 -5
  116. data/app/views/decidim/admin/managed_users/promotions/new.html.erb +3 -2
  117. data/app/views/decidim/admin/{participatory_space_private_users → members}/edit.html.erb +2 -2
  118. data/app/views/decidim/admin/{participatory_space_private_users → members}/index.html.erb +25 -25
  119. data/app/views/decidim/admin/{participatory_space_private_users → members}/new.html.erb +2 -2
  120. data/app/views/decidim/admin/{participatory_space_private_users_csv_imports → members_csv_imports}/new.html.erb +2 -2
  121. data/app/views/decidim/admin/moderations/_moderation-tr.html.erb +3 -7
  122. data/app/views/decidim/admin/moderations/_moderations-thead.html.erb +0 -1
  123. data/app/views/decidim/admin/moderations/reports/index.html.erb +1 -1
  124. data/app/views/decidim/admin/newsletter_templates/show.html.erb +3 -2
  125. data/app/views/decidim/admin/newsletters/confirm_recipients.html.erb +4 -6
  126. data/app/views/decidim/admin/newsletters/index.html.erb +2 -2
  127. data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +2 -2
  128. data/app/views/decidim/admin/newsletters/show.html.erb +3 -2
  129. data/app/views/decidim/admin/officializations/index.html.erb +6 -4
  130. data/app/views/decidim/admin/officializations/show_email.html.erb +3 -7
  131. data/app/views/decidim/admin/organization/form/_extra_features.html.erb +2 -22
  132. data/app/views/decidim/admin/organization_external_domain_allowlist/_form.html.erb +2 -2
  133. data/app/views/decidim/admin/organization_external_domain_allowlist/edit.html.erb +2 -2
  134. data/app/views/decidim/admin/reminders/new.html.erb +8 -1
  135. data/app/views/decidim/admin/resource_permissions/edit.html.erb +2 -2
  136. data/app/views/decidim/admin/scope_types/index.html.erb +3 -2
  137. data/app/views/decidim/admin/scopes/index.html.erb +2 -2
  138. data/app/views/decidim/admin/share_tokens/index.html.erb +2 -0
  139. data/app/views/decidim/admin/shared/_gallery.html.erb +15 -0
  140. data/app/views/decidim/admin/shared/landing_page/_content_blocks.html.erb +0 -2
  141. data/app/views/decidim/admin/shared/landing_page/edit.html.erb +2 -0
  142. data/app/views/decidim/admin/shared/landing_page_content_blocks/edit.html.erb +1 -0
  143. data/app/views/decidim/admin/static_page_topics/index.html.erb +2 -2
  144. data/app/views/decidim/admin/static_pages/edit.html.erb +2 -1
  145. data/app/views/decidim/admin/static_pages/index.html.erb +2 -2
  146. data/app/views/decidim/admin/statistics/_statistics.html.erb +1 -1
  147. data/app/views/decidim/admin/statistics/index.html.erb +2 -0
  148. data/app/views/decidim/admin/taxonomies/_row.html.erb +1 -1
  149. data/app/views/decidim/admin/taxonomies/_row_children.html.erb +1 -1
  150. data/app/views/decidim/admin/taxonomies/_table.html.erb +1 -1
  151. data/app/views/decidim/admin/taxonomies/edit.html.erb +2 -2
  152. data/app/views/decidim/admin/taxonomies/index.html.erb +4 -4
  153. data/app/views/decidim/admin/taxonomy_filters/_table.html.erb +2 -2
  154. data/app/views/decidim/admin/taxonomy_filters/index.html.erb +2 -2
  155. data/app/views/decidim/admin/taxonomy_filters_selector/index.html.erb +2 -0
  156. data/app/views/decidim/admin/taxonomy_filters_selector/new.html.erb +2 -0
  157. data/app/views/decidim/admin/taxonomy_filters_selector/show.html.erb +2 -0
  158. data/app/views/decidim/admin/taxonomy_items/edit.html.erb +2 -0
  159. data/app/views/decidim/admin/taxonomy_items/new.html.erb +2 -0
  160. data/app/views/decidim/admin/users/index.html.erb +3 -2
  161. data/app/views/layouts/decidim/admin/_application.html.erb +1 -1
  162. data/config/locales/ar.yml +9 -49
  163. data/config/locales/bg.yml +9 -57
  164. data/config/locales/bs-BA.yml +4 -24
  165. data/config/locales/ca-IT.yml +130 -117
  166. data/config/locales/ca.yml +130 -117
  167. data/config/locales/cs.yml +126 -116
  168. data/config/locales/de.yml +114 -123
  169. data/config/locales/el.yml +17 -45
  170. data/config/locales/en.yml +130 -116
  171. data/config/locales/eo.yml +0 -7
  172. data/config/locales/es-MX.yml +130 -117
  173. data/config/locales/es-PY.yml +130 -117
  174. data/config/locales/es.yml +130 -117
  175. data/config/locales/eu.yml +189 -176
  176. data/config/locales/fi-plain.yml +129 -116
  177. data/config/locales/fi.yml +129 -116
  178. data/config/locales/fr-CA.yml +91 -149
  179. data/config/locales/fr.yml +91 -149
  180. data/config/locales/ga-IE.yml +0 -13
  181. data/config/locales/gl.yml +57 -649
  182. data/config/locales/he-IL.yml +1 -5
  183. data/config/locales/hu.yml +10 -52
  184. data/config/locales/id-ID.yml +4 -34
  185. data/config/locales/is-IS.yml +1 -16
  186. data/config/locales/it.yml +8 -69
  187. data/config/locales/ja.yml +129 -118
  188. data/config/locales/kaa.yml +4 -16
  189. data/config/locales/ko.yml +6 -40
  190. data/config/locales/lb.yml +9 -41
  191. data/config/locales/lt.yml +10 -52
  192. data/config/locales/lv.yml +8 -38
  193. data/config/locales/nl.yml +10 -46
  194. data/config/locales/no.yml +10 -46
  195. data/config/locales/pl.yml +9 -54
  196. data/config/locales/pt-BR.yml +121 -104
  197. data/config/locales/pt.yml +9 -42
  198. data/config/locales/ro-RO.yml +15 -51
  199. data/config/locales/ru.yml +4 -35
  200. data/config/locales/sk.yml +8 -814
  201. data/config/locales/sl.yml +1 -7
  202. data/config/locales/sq-AL.yml +1 -21
  203. data/config/locales/sr-CS.yml +4 -24
  204. data/config/locales/sv.yml +80 -121
  205. data/config/locales/th-TH.yml +0 -8
  206. data/config/locales/tr-TR.yml +33 -93
  207. data/config/locales/uk.yml +0 -26
  208. data/config/locales/val-ES.yml +0 -1
  209. data/config/locales/zh-CN.yml +9 -38
  210. data/config/locales/zh-TW.yml +10 -52
  211. data/config/routes.rb +4 -0
  212. data/decidim-admin.gemspec +7 -10
  213. data/lib/decidim/admin/engine.rb +5 -2
  214. data/lib/decidim/admin/form_builder.rb +3 -1
  215. data/lib/decidim/admin/menu.rb +1 -1
  216. data/lib/decidim/admin/test/admin_members_shared_examples.rb +119 -0
  217. data/lib/decidim/admin/test/admin_participatory_space_access_examples.rb +3 -3
  218. data/lib/decidim/admin/test/filterable_examples.rb +20 -11
  219. data/lib/decidim/admin/test/invite_participatory_space_admins_shared_examples.rb +17 -17
  220. data/lib/decidim/admin/test/invite_participatory_space_collaborators_shared_examples.rb +1 -1
  221. data/lib/decidim/admin/test/invite_participatory_space_moderators_shared_examples.rb +1 -1
  222. data/lib/decidim/admin/test/invite_participatory_space_users_shared_context.rb +1 -1
  223. data/lib/decidim/admin/test/manage_attachment_collections_examples.rb +3 -3
  224. data/lib/decidim/admin/test/manage_attachments_examples.rb +6 -6
  225. data/lib/decidim/admin/test/manage_component_permissions_examples.rb +5 -5
  226. data/lib/decidim/admin/test/manage_moderations_examples.rb +6 -6
  227. data/lib/decidim/admin/test/manage_participatory_space_publications_examples.rb +2 -2
  228. data/lib/decidim/admin/test/manage_resource_soft_deletion_examples.rb +3 -3
  229. data/lib/decidim/admin/version.rb +1 -1
  230. data/lib/decidim/admin.rb +0 -2
  231. metadata +40 -36
  232. data/app/commands/decidim/admin/create_participatory_space_private_user.rb +0 -98
  233. data/app/commands/decidim/admin/destroy_participatory_space_private_user.rb +0 -28
  234. data/app/commands/decidim/admin/process_participatory_space_private_user_import_csv.rb +0 -44
  235. data/app/commands/decidim/admin/publish_all_participatory_space_private_users.rb +0 -50
  236. data/app/commands/decidim/admin/unpublish_all_participatory_space_private_users.rb +0 -50
  237. data/app/commands/decidim/admin/update_participatory_space_private_user.rb +0 -11
  238. data/app/controllers/concerns/decidim/participatory_space_private_users/admin/filterable.rb +0 -34
  239. data/app/controllers/decidim/admin/concerns/has_private_users.rb +0 -173
  240. data/app/controllers/decidim/admin/concerns/has_private_users_csv_import.rb +0 -67
  241. data/app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb +0 -31
  242. data/app/forms/decidim/admin/participatory_space_private_user_form.rb +0 -24
  243. data/app/jobs/decidim/admin/destroy_private_users_follows_job.rb +0 -37
  244. data/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb +0 -27
  245. data/app/views/decidim/admin/devise/mailers/password_change.html.erb +0 -3
  246. data/app/views/decidim/admin/devise/mailers/reset_password_instructions.html.erb +0 -8
  247. data/app/views/decidim/admin/shared/_attachments.html.erb +0 -15
  248. /data/app/views/decidim/admin/{participatory_space_private_users → members}/_form.html.erb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b09d289923eeba25084f2ef02203d589e66d9f9112ab0c07663f5cabcc27fa6
4
- data.tar.gz: ac243685d31770727448e905d9cd8d92afc6681c2418f26c92336075d9c91df2
3
+ metadata.gz: 9da138630750a0739cd6fd8b161f7093193e6293fa32a00e24355c7c0fca9a0c
4
+ data.tar.gz: ba05f9d1e15ac506f29ce14428c7952be077fd8f251c886be250267a1b32fbb9
5
5
  SHA512:
6
- metadata.gz: 988427f2e29e0dc9d8ea2284421e014a690f65b90f0374a4c6acafaf5cbf0a566ea09c3678d420b0d24f6f2ac475f145f7a28dd84011bcf649f158c1527beec1
7
- data.tar.gz: ca646ce7ca7f693b7c37f164504c2c076cfcf1cf231ec8450c675b82b94c058a856cd76659c020cf74ebf10ffecde940448111c138fe5d2974663eb696114079
6
+ metadata.gz: 135c143b735ee0ada94c33046c6f9c5cbf81027b91ee609677a66b3fd04db2051781eab9b465836666acf5b3268ba372ab69ed823509d4cba115f2b600cd1a83
7
+ data.tar.gz: 501dd3d2f79cc2b1699830d82b7f411ebeb8656aab4ac0de1da085b7ec5a4882053187796221a38687544a5a24446d4df752bdecee3fd445b581c9ef7481b7fe
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Decidim::Admin
1
+ # decidim-admin
2
2
 
3
3
  Adds an administration dashboard so users can manage their
4
4
  organization, participatory processes and all other entities.
@@ -10,17 +10,7 @@ It is included by default with Decidim.
10
10
 
11
11
  ## Installation
12
12
 
13
- Add this line to your application's Gemfile:
14
-
15
- ```ruby
16
- gem 'decidim-admin'
17
- ```
18
-
19
- And then execute:
20
-
21
- ```bash
22
- bundle
23
- ```
13
+ This is on the default Decidim installation so you should not change anything to use this module.
24
14
 
25
15
  ## Components
26
16
 
@@ -1,3 +1,3 @@
1
- <% if private_space? && !(transparent_space?) %>
1
+ <% if restricted_space? %>
2
2
  <%= cell("decidim/announcement", t("decidim.admin.attachments_privacy_warning.message"), callout_class: "warning") %>
3
3
  <% end %>
@@ -7,12 +7,8 @@ module Decidim
7
7
 
8
8
  private
9
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)
10
+ def restricted_space?
11
+ current_participatory_space.respond_to?(:restricted?) && current_participatory_space.restricted?
16
12
  end
17
13
  end
18
14
  end
@@ -59,7 +59,7 @@ module Decidim
59
59
 
60
60
  data.each do |id, weight|
61
61
  content_block = collection.find_by(id:)
62
- content_block.update!(weight:) if content_block.present?
62
+ (content_block.presence&.update!(weight:))
63
63
  end
64
64
  end
65
65
 
@@ -31,7 +31,7 @@ module Decidim
31
31
  @content_block = content_block
32
32
  end
33
33
  on(:invalid) do
34
- raise Decidim::Commands::HookError, "There was a problem persisting the changes to the content block"
34
+ raise "There was a problem persisting the changes to the content block"
35
35
  end
36
36
  end
37
37
  end
@@ -5,34 +5,20 @@ module Decidim
5
5
  # A command with all the business logic to create a new taxonomy filter in the
6
6
  # system.
7
7
  class CreateTaxonomyFilter < Decidim::Commands::CreateResource
8
- fetch_form_attributes :root_taxonomy_id, :internal_name, :name, :participatory_space_manifests
8
+ fetch_form_attributes :root_taxonomy_id, :filter_items, :internal_name, :name, :participatory_space_manifests
9
9
 
10
10
  protected
11
11
 
12
12
  def resource_class = Decidim::TaxonomyFilter
13
13
 
14
- def run_after_hooks
15
- create_filter_items!
16
- end
17
-
18
14
  def extra_params
19
15
  {
20
16
  extra: {
21
17
  taxonomy_name: form.root_taxonomy.name,
22
- filter_items_count: selected_taxonomy_item_ids.size
18
+ filter_items_count: form.filter_items.count
23
19
  }
24
20
  }
25
21
  end
26
-
27
- private
28
-
29
- def create_filter_items!
30
- selected_taxonomy_item_ids.each { |taxonomy_item_id| resource.filter_items.create!(taxonomy_item_id:) }
31
- end
32
-
33
- def selected_taxonomy_item_ids
34
- form.taxonomy_items.map(&:to_i).uniq
35
- end
36
22
  end
37
23
  end
38
24
  end
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ module ParticipatorySpace
6
+ # A command with all the business logic when creating a new participatory space
7
+ # member in the system.
8
+ class CreateMember < Decidim::Command
9
+ delegate :current_user, to: :form
10
+ # Public: Initializes the command.
11
+ #
12
+ # form - A form object with the params.
13
+ # member_to - The member_to that will hold the
14
+ # user role
15
+ def initialize(form, member_to, via_csv: false)
16
+ @form = form
17
+ @member_to = member_to
18
+ @via_csv = via_csv
19
+ end
20
+
21
+ # Executes the command. Broadcasts these events:
22
+ #
23
+ # - :ok when everything is valid.
24
+ # - :invalid if the form was not valid and we could not proceed.
25
+ #
26
+ # Returns nothing.
27
+ def call
28
+ return broadcast(:invalid) if form.invalid?
29
+
30
+ ActiveRecord::Base.transaction do
31
+ @user ||= existing_user || new_user
32
+ create_member
33
+ end
34
+
35
+ broadcast(:ok)
36
+ rescue ActiveRecord::RecordInvalid
37
+ form.errors.add(:email, :taken)
38
+ broadcast(:invalid)
39
+ end
40
+
41
+ private
42
+
43
+ attr_reader :form, :member_to, :user
44
+
45
+ def create_member
46
+ action = @via_csv ? "create_via_csv" : "create"
47
+ Decidim.traceability.perform_action!(
48
+ action,
49
+ Decidim::ParticipatorySpace::Member,
50
+ current_user,
51
+ resource: {
52
+ title: user.name
53
+ }
54
+ ) do
55
+ member = Decidim::ParticipatorySpace::Member.where(user:, participatory_space: @member_to).first_or_initialize
56
+ member.role = form.role
57
+ member.published = form.published
58
+ member.save!
59
+ member
60
+ end
61
+ end
62
+
63
+ def existing_user
64
+ return @existing_user if defined?(@existing_user)
65
+
66
+ @existing_user = User.find_by(
67
+ email: form.email.downcase,
68
+ organization: member_to.organization
69
+ )
70
+
71
+ InviteUserAgain.call(@existing_user, invitation_instructions) if @existing_user&.invitation_pending?
72
+
73
+ @existing_user
74
+ end
75
+
76
+ def new_user
77
+ @new_user ||= InviteUser.call(user_form) do
78
+ on(:ok) do |user|
79
+ return user
80
+ end
81
+ end
82
+ end
83
+
84
+ def user_form
85
+ OpenStruct.new(name: form.name,
86
+ email: form.email.downcase,
87
+ organization: member_to.organization,
88
+ admin: false,
89
+ invited_by: current_user,
90
+ invitation_instructions:)
91
+ end
92
+
93
+ def invitation_instructions
94
+ "invite_member"
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ module ParticipatorySpace
6
+ # A command with all the business logic to destroy a member.
7
+ class DestroyMember < Decidim::Commands::DestroyResource
8
+ private
9
+
10
+ def extra_params
11
+ {
12
+ resource: {
13
+ title: resource.user.name
14
+ }
15
+ }
16
+ end
17
+
18
+ def run_after_hooks
19
+ return unless resource.participatory_space.respond_to?(:restricted?)
20
+ return unless resource.participatory_space.restricted?
21
+ return if resource.participatory_space.respond_to?(:transparent?) && resource.participatory_space.transparent?
22
+
23
+ # When member is destroyed, a hook to destroy the follows of user on restricted or transparent spaces
24
+ # and the follows of their children
25
+ DestroyMembersFollowsJob.perform_later(resource.decidim_user_id, resource.participatory_space)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "csv"
4
+
5
+ module Decidim
6
+ module Admin
7
+ module ParticipatorySpace
8
+ class ImportMemberCsv < Decidim::Command
9
+ include Decidim::Admin::CustomImport
10
+
11
+ delegate :current_user, to: :form
12
+ # Public: Initializes the command.
13
+ #
14
+ # form - the form object containing the uploaded file
15
+ # members_to - The members_to that will hold the user role
16
+ def initialize(form, members_to)
17
+ @form = form
18
+ @members_to = members_to
19
+ end
20
+
21
+ # Executes the command. Broadcasts these events:
22
+ #
23
+ # - :ok when everything is valid.
24
+ # - :invalid if the form was not valid and we could not proceed.
25
+ #
26
+ # Returns nothing.
27
+ def call
28
+ return broadcast(:invalid) unless @form.valid?
29
+
30
+ process_csv
31
+ broadcast(:ok)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :form
37
+
38
+ def process_csv
39
+ process_import_file(@form.file) do |(email, user_name)|
40
+ ImportMemberCsvJob.perform_later(email, user_name, @members_to, current_user) if email.present? && user_name.present?
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ module ParticipatorySpace
6
+ class PublishAllMembers < Decidim::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # participatory_space - the participatory space
10
+ # current_user - the current user
11
+ def initialize(participatory_space, current_user)
12
+ @participatory_space = participatory_space
13
+ @current_user = current_user
14
+ end
15
+
16
+ # Executes the command. Broadcasts these events:
17
+ #
18
+ # - :ok when everything is valid.
19
+ # - :invalid if the form was not valid and we could not proceed.
20
+ #
21
+ # Returns nothing.
22
+ def call
23
+ publish_all
24
+ create_action_log
25
+ broadcast(:ok)
26
+ rescue ActiveRecord::RecordInvalid
27
+ broadcast(:invalid)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :participatory_space, :current_user
33
+
34
+ def publish_all
35
+ # rubocop:disable Rails/SkipsModelValidations
36
+ # Using update_all for performance reasons
37
+ participatory_space.members.update_all(published: true)
38
+ # rubocop:enable Rails/SkipsModelValidations
39
+ end
40
+
41
+ def create_action_log
42
+ Decidim.traceability.perform_action!(
43
+ "publish_all_members",
44
+ participatory_space,
45
+ current_user,
46
+ members_ids: participatory_space.members.pluck(:id)
47
+ )
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ module ParticipatorySpace
6
+ class UnpublishAllMembers < Decidim::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # participatory_space - the participatory space
10
+ # current_user - the current user
11
+ def initialize(participatory_space, current_user)
12
+ @participatory_space = participatory_space
13
+ @current_user = current_user
14
+ end
15
+
16
+ # Executes the command. Broadcasts these events:
17
+ #
18
+ # - :ok when everything is valid.
19
+ # - :invalid if the form was not valid and we could not proceed.
20
+ #
21
+ # Returns nothing.
22
+ def call
23
+ unpublish_all
24
+ create_action_log
25
+ broadcast(:ok)
26
+ rescue ActiveRecord::RecordInvalid
27
+ broadcast(:invalid)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :participatory_space, :current_user
33
+
34
+ def unpublish_all
35
+ # rubocop:disable Rails/SkipsModelValidations
36
+ # Using update_all for performance reasons
37
+ participatory_space.members.update_all(published: false)
38
+ # rubocop:enable Rails/SkipsModelValidations
39
+ end
40
+
41
+ def create_action_log
42
+ Decidim.traceability.perform_action!(
43
+ "unpublish_all_members",
44
+ participatory_space,
45
+ current_user,
46
+ members_ids: participatory_space.members.pluck(:id)
47
+ )
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ module ParticipatorySpace
6
+ # A command with all the business logic when updating a participatory space
7
+ # member.
8
+ class UpdateMember < Decidim::Commands::UpdateResource
9
+ fetch_form_attributes :role, :published
10
+ end
11
+ end
12
+ end
13
+ end
@@ -38,7 +38,7 @@ module Decidim
38
38
  transaction do
39
39
  order.each_with_index do |id, index|
40
40
  component = components.find_by(id:)
41
- component.update!(weight: index + 1) if component.present?
41
+ (component.presence&.update!(weight: index + 1))
42
42
  end
43
43
  end
44
44
  end
@@ -54,7 +54,7 @@ module Decidim
54
54
 
55
55
  data.each do |id, weight|
56
56
  item = collection.find_by(id:)
57
- item.update!(weight:) if item.present?
57
+ (item.presence&.update!(weight:))
58
58
  end
59
59
  end
60
60
 
@@ -10,7 +10,7 @@ module Decidim
10
10
  fetch_form_attributes :name, :description, :default_locale, :reference_prefix, :time_zone, :twitter_handler,
11
11
  :facebook_handler, :instagram_handler, :youtube_handler, :github_handler, :badges_enabled,
12
12
  :comments_max_length, :enable_machine_translations, :admin_terms_of_service_body,
13
- :rich_text_editor_in_public_views, :enable_participatory_space_filters, :official_url,
13
+ :rich_text_editor_in_public_views, :official_url,
14
14
  :enable_omnipresent_banner, :omnipresent_banner_url, :omnipresent_banner_title,
15
15
  :omnipresent_banner_short_description
16
16
 
@@ -2,45 +2,27 @@
2
2
 
3
3
  module Decidim
4
4
  module Admin
5
- # A command with all the business logic to update an existing taxonomy filter
6
- # in the system.
5
+ # A command with all the business logic to create a new taxonomy filter in the
6
+ # system.
7
7
  class UpdateTaxonomyFilter < Decidim::Commands::UpdateResource
8
- fetch_form_attributes :internal_name, :name, :participatory_space_manifests
8
+ fetch_form_attributes :filter_items, :internal_name, :name, :participatory_space_manifests
9
9
 
10
10
  protected
11
11
 
12
12
  def resource_class = Decidim::TaxonomyFilter
13
13
 
14
- def run_after_hooks
15
- sync_filter_items!
14
+ def run_before_hooks
15
+ resource.filter_items.destroy_all
16
16
  end
17
17
 
18
18
  def extra_params
19
19
  {
20
20
  extra: {
21
21
  taxonomy_name: resource.root_taxonomy.name,
22
- filter_items_count: selected_taxonomy_item_ids.size
22
+ filter_items_count: form.filter_items.count
23
23
  }
24
24
  }
25
25
  end
26
-
27
- private
28
-
29
- def sync_filter_items!
30
- removed_ids = current_taxonomy_item_ids - selected_taxonomy_item_ids
31
- added_ids = selected_taxonomy_item_ids - current_taxonomy_item_ids
32
-
33
- resource.filter_items.where(taxonomy_item_id: removed_ids).destroy_all if removed_ids.any?
34
- added_ids.each { |taxonomy_item_id| resource.filter_items.create!(taxonomy_item_id:) }
35
- end
36
-
37
- def current_taxonomy_item_ids
38
- resource.filter_items.pluck(:taxonomy_item_id)
39
- end
40
-
41
- def selected_taxonomy_item_ids
42
- form.taxonomy_items.map(&:to_i).uniq
43
- end
44
26
  end
45
27
  end
46
28
  end
@@ -10,7 +10,7 @@ module Decidim
10
10
  end
11
11
 
12
12
  def current_component_taxonomy_filters
13
- @current_component_taxonomy_filters ||= TaxonomyFilter.for(current_organization) # rubocop:disable Decidim/OrganizationScopedFinder -- .for scopes by decidim_organization_id internally
13
+ @current_component_taxonomy_filters ||= TaxonomyFilter.for(current_organization)
14
14
  .for_manifest(current_participatory_space.manifest.name)
15
15
  .where(id: current_component.settings.taxonomy_filters)
16
16
  end
@@ -5,11 +5,12 @@ module Decidim
5
5
  module ContentBlocks
6
6
  module LandingPage
7
7
  extend ActiveSupport::Concern
8
+
8
9
  included do
9
10
  helper_method :active_blocks, :active_content_blocks_title, :add_content_block_text, :available_manifests,
10
11
  :content_block_destroy_confirmation_text, :content_blocks_title, :inactive_blocks,
11
12
  :inactive_content_blocks_title, :resource_content_block_cell, :resource_create_url,
12
- :resource_sort_url, :scoped_resource
13
+ :resource_sort_url
13
14
  def edit
14
15
  enforce_permission_to_update_resource
15
16
 
@@ -29,6 +30,10 @@ module Decidim
29
30
  end
30
31
  end
31
32
 
33
+ # Method that specifies the i18n scope for this controller. This can be overwritten in your controller.
34
+ # so that you can pass a different scope to the i18n methods.
35
+ def i18n_scope = "decidim.admin.content_blocks"
36
+
32
37
  # Method to be implemented at the controller. Returns a string
33
38
  # with the text for the title of content blocks
34
39
  #
@@ -66,10 +71,6 @@ module Decidim
66
71
 
67
72
  private
68
73
 
69
- # Method that specifies the i18n scope for this controller. This can be overwritten in your controller.
70
- # so that you can pass a different scope to the i18n methods.
71
- def i18n_scope = "decidim.admin.content_blocks"
72
-
73
74
  # Method to be implemented at the controller. You need to
74
75
  # return a symbol that defines the content block scope.
75
76
  # Examples of scopes could be `:homepage` or `:landing_page`.
@@ -5,6 +5,7 @@ module Decidim
5
5
  module ContentBlocks
6
6
  module LandingPageContentBlocks
7
7
  extend ActiveSupport::Concern
8
+
8
9
  included do
9
10
  helper_method :content_block, :resource_landing_page_content_block_path, :scoped_resource, :submit_button_text
10
11
 
@@ -48,14 +49,14 @@ module Decidim
48
49
  def update
49
50
  enforce_permission_to_update_resource
50
51
 
51
- @form = form(ContentBlockForm).from_params(params)
52
+ @form = form(ContentBlockForm).from_params(params, content_block:)
52
53
 
53
54
  UpdateContentBlock.call(@form, content_block, content_block_scope) do
54
55
  on(:ok) do
55
56
  redirect_to edit_resource_landing_page_path
56
57
  end
57
58
  on(:invalid) do
58
- render "decidim/admin/shared/landing_page_content_blocks/edit", status: :unprocessable_entity
59
+ render "decidim/admin/shared/landing_page_content_blocks/edit", status: :unprocessable_content
59
60
  end
60
61
  end
61
62
  end
@@ -77,7 +77,7 @@ module Decidim
77
77
  # the query
78
78
  def adjacent_items(item)
79
79
  query =
80
- <<-SQL.squish
80
+ <<~SQL.squish
81
81
  WITH
82
82
  collection AS (#{session_filtered_collection.select(:id).to_sql}),
83
83
  successors AS (
@@ -162,7 +162,7 @@ module Decidim
162
162
  # - FilterableHelper#applied_filters_hidden_field_tags
163
163
  # To ensure that filters are kept in the search_form_for.
164
164
  def filters
165
- [:private_space_eq, :published_at_null]
165
+ [:published_at_null]
166
166
  end
167
167
 
168
168
  # Informs which filters are being used OUTSIDE the dropdown.
@@ -198,8 +198,8 @@ module Decidim
198
198
  filtered_taxonomies = taxonomies.roots.or(taxonomies.where(id: available_taxonomy_ids))
199
199
  return nil if filtered_taxonomies.blank?
200
200
 
201
- filtered_taxonomies.each_with_object({}) do |taxonomy, hash|
202
- hash[taxonomy.id] = taxonomy_ids_hash(taxonomy.children)
201
+ filtered_taxonomies.to_h do |taxonomy|
202
+ [taxonomy.id, taxonomy_ids_hash(taxonomy.children)]
203
203
  end
204
204
  end
205
205
 
@@ -8,8 +8,6 @@ module Decidim
8
8
  extend ActiveSupport::Concern
9
9
 
10
10
  included do
11
- protected
12
-
13
11
  # Private: Overwrites the method from the parent controller so that the
14
12
  # permission system does not overwrite permissions.
15
13
  def authorization_scope
@@ -8,8 +8,6 @@ module Decidim
8
8
  extend ActiveSupport::Concern
9
9
 
10
10
  class_methods do
11
- protected
12
-
13
11
  # Public: Called on a controller, it sets up all the surrounding methods to render a
14
12
  # participatory space's admin template. It expects the method `current_participatory_space`
15
13
  # to be defined, from which it will extract the participatory manifest.
@@ -27,6 +25,7 @@ module Decidim
27
25
  included do
28
26
  include Decidim::NeedsOrganization
29
27
  include Decidim::Admin::ParticipatorySpaceAdminBreadcrumb
28
+
30
29
  helper ParticipatorySpaceHelpers
31
30
 
32
31
  helper_method :current_participatory_space
@@ -17,13 +17,11 @@ module Decidim
17
17
 
18
18
  flash[:notice] = t("decidim.admin.exports.notice")
19
19
 
20
- redirect_back(fallback_location: after_export_path)
20
+ redirect_back_or_to(after_export_path)
21
21
  end
22
22
 
23
23
  # Public: To be implemented at the controller. You need to
24
24
  # return the space that will be exported.
25
- protected
26
-
27
25
  def exportable_space
28
26
  raise NotImplementedError
29
27
  end
@@ -6,7 +6,6 @@ module Decidim
6
6
  # Terms of service agreement.
7
7
  class AdminTermsController < Decidim::Admin::ApplicationController
8
8
  def accept
9
- enforce_permission_to :accept, :admin_terms
10
9
  current_user.admin_terms_accepted_at = Time.current
11
10
  if current_user.save!
12
11
  flash[:notice] = t("accept.success", scope: "decidim.admin.admin_terms_of_service")
@@ -44,8 +44,6 @@ module Decidim
44
44
  register_permissions(::Decidim::Admin::ApplicationController,
45
45
  ::Decidim::Admin::Permissions)
46
46
 
47
- protected
48
-
49
47
  def user_has_no_permission_path
50
48
  decidim_admin.root_path
51
49
  end