decidim-admin 0.28.1 → 0.29.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/admin/content_block_cell.rb +0 -1
  3. data/app/cells/decidim/admin/results_per_page/show.erb +2 -2
  4. data/app/cells/decidim/admin/results_per_page_cell.rb +0 -2
  5. data/app/commands/decidim/admin/create_area.rb +4 -32
  6. data/app/commands/decidim/admin/create_area_type.rb +4 -33
  7. data/app/commands/decidim/admin/create_attachment.rb +5 -4
  8. data/app/commands/decidim/admin/create_attachment_collection.rb +3 -3
  9. data/app/commands/decidim/admin/create_category.rb +4 -37
  10. data/app/commands/decidim/admin/create_component.rb +7 -40
  11. data/app/commands/decidim/admin/create_newsletter.rb +11 -29
  12. data/app/commands/decidim/admin/create_participatory_space_private_user.rb +3 -3
  13. data/app/commands/decidim/admin/create_scope.rb +15 -32
  14. data/app/commands/decidim/admin/create_scope_type.rb +3 -32
  15. data/app/commands/decidim/admin/create_static_page.rb +6 -47
  16. data/app/commands/decidim/admin/create_static_page_topic.rb +4 -26
  17. data/app/commands/decidim/admin/deliver_newsletter.rb +4 -5
  18. data/app/commands/decidim/admin/destroy_area.rb +2 -25
  19. data/app/commands/decidim/admin/destroy_category.rb +4 -29
  20. data/app/commands/decidim/admin/destroy_component.rb +5 -42
  21. data/app/commands/decidim/admin/destroy_newsletter.rb +2 -30
  22. data/app/commands/decidim/admin/destroy_participatory_space_private_user.rb +5 -32
  23. data/app/commands/decidim/admin/destroy_scope.rb +6 -33
  24. data/app/commands/decidim/admin/officialize_user.rb +1 -1
  25. data/app/commands/decidim/admin/participatory_space/create_admin.rb +4 -4
  26. data/app/commands/decidim/admin/process_participatory_space_private_user_import_csv.rb +5 -4
  27. data/app/commands/decidim/admin/promote_managed_user.rb +4 -5
  28. data/app/commands/decidim/admin/unofficialize_user.rb +1 -1
  29. data/app/commands/decidim/admin/update_area.rb +2 -41
  30. data/app/commands/decidim/admin/update_area_type.rb +2 -42
  31. data/app/commands/decidim/admin/update_attachment.rb +10 -7
  32. data/app/commands/decidim/admin/update_attachment_collection.rb +3 -3
  33. data/app/commands/decidim/admin/update_category.rb +2 -45
  34. data/app/commands/decidim/admin/update_component.rb +4 -5
  35. data/app/commands/decidim/admin/update_component_permissions.rb +3 -3
  36. data/app/commands/decidim/admin/{update_external_domain_whitelist.rb → update_external_domain_allowlist.rb} +6 -5
  37. data/app/commands/decidim/admin/update_help_sections.rb +6 -3
  38. data/app/commands/decidim/admin/update_newsletter.rb +8 -8
  39. data/app/commands/decidim/admin/update_organization.rb +9 -53
  40. data/app/commands/decidim/admin/update_organization_appearance.rb +10 -81
  41. data/app/commands/decidim/admin/update_scope.rb +7 -40
  42. data/app/commands/decidim/admin/update_scope_type.rb +2 -42
  43. data/app/commands/decidim/admin/update_static_page.rb +5 -46
  44. data/app/commands/decidim/admin/update_static_page_topic.rb +2 -43
  45. data/app/constraints/decidim/admin/organization_dashboard_constraint.rb +1 -1
  46. data/app/controllers/concerns/decidim/admin/content_blocks/landing_page.rb +2 -2
  47. data/app/controllers/concerns/decidim/admin/filterable.rb +78 -3
  48. data/app/controllers/concerns/decidim/admin/global_moderation_context.rb +1 -1
  49. data/app/controllers/concerns/decidim/admin/needs_admin_tos_accepted.rb +0 -7
  50. data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +1 -1
  51. data/app/controllers/decidim/admin/application_controller.rb +1 -0
  52. data/app/controllers/decidim/admin/area_types_controller.rb +8 -9
  53. data/app/controllers/decidim/admin/areas_controller.rb +1 -1
  54. data/app/controllers/decidim/admin/authorization_workflows_controller.rb +3 -1
  55. data/app/controllers/decidim/admin/categories_controller.rb +2 -2
  56. data/app/controllers/decidim/admin/component_permissions_controller.rb +1 -1
  57. data/app/controllers/decidim/admin/components_controller.rb +2 -2
  58. data/app/controllers/decidim/admin/concerns/has_attachment_collections.rb +2 -2
  59. data/app/controllers/decidim/admin/concerns/has_attachments.rb +2 -2
  60. data/app/controllers/decidim/admin/concerns/has_private_users.rb +1 -1
  61. data/app/controllers/decidim/admin/concerns/has_private_users_csv_import.rb +1 -1
  62. data/app/controllers/decidim/admin/help_sections_controller.rb +1 -1
  63. data/app/controllers/decidim/admin/managed_users/promotions_controller.rb +1 -1
  64. data/app/controllers/decidim/admin/moderations/reports_controller.rb +4 -4
  65. data/app/controllers/decidim/admin/moderations_controller.rb +7 -7
  66. data/app/controllers/decidim/admin/newsletter_templates_controller.rb +1 -1
  67. data/app/controllers/decidim/admin/newsletters_controller.rb +5 -5
  68. data/app/controllers/decidim/admin/organization_appearance_controller.rb +1 -1
  69. data/app/controllers/decidim/admin/organization_controller.rb +8 -5
  70. data/app/controllers/decidim/admin/{organization_external_domain_whitelist_controller.rb → organization_external_domain_allowlist_controller.rb} +7 -7
  71. data/app/controllers/decidim/admin/scope_types_controller.rb +7 -8
  72. data/app/controllers/decidim/admin/scopes_controller.rb +1 -1
  73. data/app/controllers/decidim/admin/share_tokens_controller.rb +1 -1
  74. data/app/controllers/decidim/admin/static_page_topics_controller.rb +2 -2
  75. data/app/controllers/decidim/admin/static_pages_controller.rb +2 -2
  76. data/app/forms/decidim/admin/attachment_form.rb +7 -1
  77. data/app/forms/decidim/admin/organization_appearance_form.rb +0 -3
  78. data/app/forms/decidim/admin/{organization_external_domain_whitelist_form.rb → organization_external_domain_allowlist_form.rb} +3 -3
  79. data/app/forms/decidim/admin/organization_form.rb +2 -2
  80. data/app/forms/decidim/admin/static_page_form.rb +0 -1
  81. data/app/helpers/decidim/admin/filterable_helper.rb +19 -3
  82. data/app/helpers/decidim/admin/moderations/reports_helper.rb +3 -1
  83. data/app/helpers/decidim/admin/newsletters_helper.rb +3 -3
  84. data/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb +2 -2
  85. data/app/packs/entrypoints/decidim_admin.js +4 -1
  86. data/app/packs/src/decidim/admin/application.js +25 -16
  87. data/app/packs/src/decidim/admin/choose_language.js +2 -0
  88. data/app/packs/src/decidim/admin/css_preview.js +39 -0
  89. data/app/packs/src/decidim/admin/dynamic_fields.component.js +2 -1
  90. data/app/packs/src/decidim/admin/form.js +18 -1
  91. data/app/packs/src/decidim/admin/participatory_space_search.js +1 -1
  92. data/app/packs/src/decidim/admin/proposal_infinite_edit.js +2 -2
  93. data/app/packs/src/decidim/admin/sync_radio_buttons.js +27 -0
  94. data/app/packs/src/decidim/admin/text_copy.js +19 -0
  95. data/app/packs/stylesheets/decidim/admin/_cards.scss +1 -1
  96. data/app/packs/stylesheets/decidim/admin/_datepicker.scss +62 -0
  97. data/app/packs/stylesheets/decidim/admin/_item_edit.scss +1 -1
  98. data/app/packs/stylesheets/decidim/admin/_item_show.scss +8 -0
  99. data/app/packs/stylesheets/decidim/admin/_proposal_status.scss +5 -0
  100. data/app/packs/stylesheets/decidim/admin/application.scss +2 -0
  101. data/app/permissions/decidim/admin/permissions.rb +2 -2
  102. data/app/queries/decidim/admin/user_filter.rb +4 -4
  103. data/app/queries/decidim/admin/user_groups_evaluation.rb +1 -1
  104. data/app/views/decidim/admin/attachment_collections/index.html.erb +1 -1
  105. data/app/views/decidim/admin/attachments/_form.html.erb +21 -2
  106. data/app/views/decidim/admin/attachments/index.html.erb +2 -2
  107. data/app/views/decidim/admin/authorization_workflows/index.html.erb +26 -8
  108. data/app/views/decidim/admin/categories/index.html.erb +2 -2
  109. data/app/views/decidim/admin/components/_form.html.erb +1 -1
  110. data/app/views/decidim/admin/dashboard/_pending_moderations.html.erb +1 -1
  111. data/app/views/decidim/admin/dashboard/show.html.erb +1 -1
  112. data/app/views/decidim/admin/exports/_dropdown.html.erb +1 -1
  113. data/app/views/decidim/admin/impersonatable_users/index.html.erb +3 -3
  114. data/app/views/decidim/admin/imports/_dropdown.html.erb +1 -1
  115. data/app/views/decidim/admin/imports/new.html.erb +2 -2
  116. data/app/views/decidim/admin/logs/_filters.html.erb +3 -3
  117. data/app/views/decidim/admin/managed_users/promotions/new.html.erb +1 -1
  118. data/app/views/decidim/admin/moderated_users/index.html.erb +2 -2
  119. data/app/views/decidim/admin/moderations/index.html.erb +5 -5
  120. data/app/views/decidim/admin/moderations/reports/index.html.erb +6 -6
  121. data/app/views/decidim/admin/moderations/reports/show.html.erb +4 -4
  122. data/app/views/decidim/admin/newsletter_templates/index.html.erb +2 -2
  123. data/app/views/decidim/admin/newsletter_templates/show.html.erb +7 -7
  124. data/app/views/decidim/admin/newsletters/index.html.erb +1 -1
  125. data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +3 -3
  126. data/app/views/decidim/admin/newsletters/show.html.erb +1 -1
  127. data/app/views/decidim/admin/organization/_form.html.erb +3 -3
  128. data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +0 -3
  129. data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +5 -5
  130. data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/_external_domain.html.erb +4 -4
  131. data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/_form.html.erb +2 -2
  132. data/app/views/decidim/admin/{organization_external_domain_whitelist → organization_external_domain_allowlist}/edit.html.erb +2 -2
  133. data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +1 -1
  134. data/app/views/decidim/admin/participatory_space_private_users_csv_imports/new.html.erb +1 -1
  135. data/app/views/decidim/admin/share_tokens/_share_tokens.html.erb +1 -1
  136. data/app/views/decidim/admin/shared/_adjacent_navigation.html.erb +30 -0
  137. data/app/views/decidim/admin/shared/_admin_confirm_modal.html.erb +7 -7
  138. data/app/views/decidim/admin/shared/_filters.html.erb +1 -1
  139. data/app/views/decidim/admin/shared/_gallery.html.erb +1 -1
  140. data/app/views/decidim/admin/shared/_js-callout.html.erb +2 -2
  141. data/app/views/decidim/admin/shared/landing_page/_content_blocks.html.erb +2 -2
  142. data/app/views/decidim/admin/static_page_topics/index.html.erb +1 -1
  143. data/app/views/decidim/admin/static_pages/_form.html.erb +0 -4
  144. data/app/views/decidim/admin/users_statistics/_users_count.html.erb +2 -2
  145. data/app/views/layouts/decidim/admin/_admin_timeout_modal.html.erb +2 -2
  146. data/app/views/layouts/decidim/admin/_application.html.erb +4 -4
  147. data/app/views/layouts/decidim/admin/_callouts_full.html.erb +1 -1
  148. data/app/views/layouts/decidim/admin/_js_configuration.html.erb +3 -1
  149. data/app/views/layouts/decidim/admin/_sidebar_menu.html.erb +2 -2
  150. data/app/views/layouts/decidim/admin/_title_bar.html.erb +2 -2
  151. data/app/views/layouts/decidim/admin/_title_bar_responsive.html.erb +2 -2
  152. data/config/locales/ar.yml +1 -7
  153. data/config/locales/bg.yml +1013 -11
  154. data/config/locales/ca.yml +18 -11
  155. data/config/locales/cs.yml +17 -10
  156. data/config/locales/de.yml +25 -18
  157. data/config/locales/el.yml +1 -12
  158. data/config/locales/en.yml +18 -11
  159. data/config/locales/es-MX.yml +25 -18
  160. data/config/locales/es-PY.yml +25 -18
  161. data/config/locales/es.yml +34 -27
  162. data/config/locales/eu.yml +18 -11
  163. data/config/locales/fi-plain.yml +16 -9
  164. data/config/locales/fi.yml +16 -9
  165. data/config/locales/fr-CA.yml +16 -9
  166. data/config/locales/fr.yml +15 -8
  167. data/config/locales/ga-IE.yml +1 -3
  168. data/config/locales/gl.yml +1 -5
  169. data/config/locales/hu.yml +10 -10
  170. data/config/locales/id-ID.yml +1 -3
  171. data/config/locales/is-IS.yml +1 -3
  172. data/config/locales/it.yml +2 -8
  173. data/config/locales/ja.yml +18 -11
  174. data/config/locales/kaa.yml +0 -3
  175. data/config/locales/ko.yml +0 -6
  176. data/config/locales/lb.yml +1 -8
  177. data/config/locales/lt.yml +2 -13
  178. data/config/locales/lv.yml +1 -3
  179. data/config/locales/nl.yml +1 -8
  180. data/config/locales/no.yml +1 -8
  181. data/config/locales/pl.yml +17 -9
  182. data/config/locales/pt-BR.yml +9 -10
  183. data/config/locales/pt.yml +1 -8
  184. data/config/locales/ro-RO.yml +1 -12
  185. data/config/locales/ru.yml +1 -3
  186. data/config/locales/sk.yml +1 -3
  187. data/config/locales/sl.yml +1 -0
  188. data/config/locales/sq-AL.yml +410 -0
  189. data/config/locales/sr-CS.yml +1 -3
  190. data/config/locales/sv.yml +1 -8
  191. data/config/locales/th-TH.yml +98 -0
  192. data/config/locales/tr-TR.yml +1 -5
  193. data/config/locales/uk.yml +1 -3
  194. data/config/locales/zh-CN.yml +1 -3
  195. data/config/locales/zh-TW.yml +2 -12
  196. data/config/routes.rb +1 -1
  197. data/decidim-admin.gemspec +1 -1
  198. data/lib/decidim/admin/import/creator.rb +1 -1
  199. data/lib/decidim/admin/import/importer_factory.rb +2 -2
  200. data/lib/decidim/admin/menu.rb +4 -4
  201. data/lib/decidim/admin/test/admin_participatory_space_access_examples.rb +27 -0
  202. data/lib/decidim/admin/test/commands/create_attachment_collection_examples.rb +3 -2
  203. data/lib/decidim/admin/test/commands/create_category_examples.rb +4 -2
  204. data/lib/decidim/admin/test/commands/update_attachment_collection_examples.rb +3 -2
  205. data/lib/decidim/admin/test/commands/update_category_examples.rb +3 -2
  206. data/lib/decidim/admin/test/filterable_examples.rb +5 -3
  207. data/lib/decidim/admin/test/filters_participatory_space_user_roles_examples.rb +5 -5
  208. data/lib/decidim/admin/test/invite_participatory_space_admins_shared_examples.rb +180 -0
  209. data/lib/decidim/admin/test/invite_participatory_space_collaborators_shared_examples.rb +67 -0
  210. data/lib/decidim/admin/test/invite_participatory_space_moderators_shared_examples.rb +77 -0
  211. data/lib/decidim/admin/test/invite_participatory_space_users_shared_context.rb +33 -0
  212. data/lib/decidim/admin/test/manage_attachment_collections_examples.rb +24 -23
  213. data/lib/decidim/admin/test/manage_attachments_examples.rb +51 -15
  214. data/lib/decidim/admin/test/manage_categories_examples.rb +24 -21
  215. data/lib/decidim/admin/test/manage_component_permissions_examples.rb +5 -5
  216. data/lib/decidim/admin/test/manage_hide_content_examples.rb +8 -4
  217. data/lib/decidim/admin/test/manage_moderations_examples.rb +21 -21
  218. data/lib/decidim/admin/test/manage_paginated_collection_examples.rb +3 -3
  219. data/lib/decidim/admin/test/manage_participatory_space_publications_examples.rb +2 -2
  220. data/lib/decidim/admin/test.rb +1 -0
  221. data/lib/decidim/admin/version.rb +1 -1
  222. metadata +32 -27
  223. data/app/commands/decidim/admin/destroy_share_token.rb +0 -46
  224. data/app/commands/decidim/admin/destroy_static_page.rb +0 -40
  225. data/app/commands/decidim/admin/destroy_static_page_topic.rb +0 -40
  226. data/app/mailers/decidim/admin/application_mailer.rb +0 -12
  227. data/app/views/layouts/decidim/admin/login.html.erb +0 -19
  228. /data/app/packs/src/decidim/admin/{external_domain_whitelist.js → external_domain_allowlist.js} +0 -0
@@ -5,16 +5,16 @@ module Decidim
5
5
  # This command gets called when permissions for a component are updated
6
6
  # in the admin panel.
7
7
  class UpdateComponentPermissions < Decidim::Command
8
+ delegate :current_user, to: :form
8
9
  # Public: Initializes the command.
9
10
  #
10
11
  # form - The form from which the data in this component comes from.
11
12
  # component - The component to update.
12
13
  # resource - The resource to update.
13
- def initialize(form, component, resource, user)
14
+ def initialize(form, component, resource)
14
15
  @form = form
15
16
  @component = component
16
17
  @resource = resource
17
- @user = user
18
18
  end
19
19
 
20
20
  # Public: Sets the permissions for a component.
@@ -23,7 +23,7 @@ module Decidim
23
23
  def call
24
24
  return broadcast(:invalid) unless form.valid?
25
25
 
26
- Decidim.traceability.perform_action!("update_permissions", @component, @user) do
26
+ Decidim.traceability.perform_action!("update_permissions", @component, current_user) do
27
27
  transaction do
28
28
  update_permissions
29
29
  run_hooks
@@ -2,19 +2,20 @@
2
2
 
3
3
  module Decidim
4
4
  module Admin
5
- class UpdateExternalDomainWhitelist < Decidim::Command
5
+ class UpdateExternalDomainAllowlist < Decidim::Command
6
6
  attr_reader :form, :organization
7
7
 
8
- def initialize(form, organization, user)
8
+ delegate :current_user, to: :form
9
+
10
+ def initialize(form, organization)
9
11
  @form = form
10
12
  @organization = organization
11
- @user = user
12
13
  end
13
14
 
14
15
  def call
15
16
  return broadcast(:invalid) if form.invalid?
16
17
 
17
- Decidim.traceability.perform_action!("update_external_domain", @organization, @user) do
18
+ Decidim.traceability.perform_action!("update_external_domain", @organization, current_user) do
18
19
  save_domains!
19
20
  end
20
21
 
@@ -24,7 +25,7 @@ module Decidim
24
25
  private
25
26
 
26
27
  def save_domains!
27
- organization.external_domain_whitelist = form.external_domains.filter_map do |external_domain_form|
28
+ organization.external_domain_allowlist = form.external_domains.filter_map do |external_domain_form|
28
29
  external_domain_form.value unless external_domain_form.deleted
29
30
  end.flatten
30
31
 
@@ -5,10 +5,11 @@ module Decidim
5
5
  # This command gets called when a content block is updated from the admin
6
6
  # panel.
7
7
  class UpdateHelpSections < Decidim::Command
8
- def initialize(form, organization, user)
8
+ delegate :current_user, to: :form
9
+
10
+ def initialize(form, organization)
9
11
  @form = form
10
12
  @organization = organization
11
- @user = user
12
13
  end
13
14
 
14
15
  def call
@@ -18,7 +19,7 @@ module Decidim
18
19
  @form.sections.each do |section|
19
20
  next unless content_has_changed?(section)
20
21
 
21
- Decidim.traceability.perform_action!("update", ContextualHelpSection, @user, { "resource" => { "title" => section.id.humanize } }) do
22
+ Decidim.traceability.perform_action!("update", ContextualHelpSection, current_user, { "resource" => { "title" => section.id.humanize } }) do
22
23
  ContextualHelpSection.set_content(@organization, section.id, section.content)
23
24
  ContextualHelpSection.find_by(organization: @organization, section_id: section.id)
24
25
  end
@@ -30,6 +31,8 @@ module Decidim
30
31
 
31
32
  private
32
33
 
34
+ attr_reader :form
35
+
33
36
  def content_has_changed?(section)
34
37
  return if ContextualHelpSection.find_by(organization: @organization, section_id: section.id).nil? && section.content.compact_blank.blank?
35
38
 
@@ -4,17 +4,16 @@ module Decidim
4
4
  module Admin
5
5
  # Updates the newsletter given form data.
6
6
  class UpdateNewsletter < Decidim::Command
7
+ delegate :current_user, to: :form
7
8
  # Initializes the command.
8
9
  #
9
10
  # newsletter - The Newsletter to update.
10
11
  # form - The form object containing the data to update.
11
- # user - The user that updates the newsletter.
12
- def initialize(newsletter, form, user)
12
+ def initialize(newsletter, form)
13
13
  @newsletter = newsletter
14
14
  @content_block = newsletter.template
15
15
  @form = form
16
- @user = user
17
- @organization = user.organization
16
+ @organization = form.current_organization
18
17
  end
19
18
 
20
19
  def call
@@ -32,19 +31,20 @@ module Decidim
32
31
 
33
32
  private
34
33
 
35
- attr_reader :user, :newsletter, :content_block, :organization, :form
34
+ attr_reader :newsletter, :content_block, :organization, :form
36
35
 
37
36
  def update_newsletter
37
+ # pp current_user.inspect
38
38
  @newsletter = Decidim.traceability.update!(
39
39
  newsletter,
40
- user,
40
+ current_user,
41
41
  subject: form.subject,
42
- author: user
42
+ author: current_user
43
43
  )
44
44
  end
45
45
 
46
46
  def update_content_block
47
- ContentBlocks::UpdateContentBlock.call(form, content_block, user) do
47
+ ContentBlocks::UpdateContentBlock.call(form, content_block, current_user) do
48
48
  on(:ok) do |content_block|
49
49
  @content_block = content_block
50
50
  end
@@ -4,62 +4,18 @@ module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic for updating the current
6
6
  # organization.
7
- class UpdateOrganization < Decidim::Command
8
- # Public: Initializes the command.
9
- #
10
- # organization - The Organization that will be updated.
11
- # form - A form object with the params.
12
- def initialize(organization, form)
13
- @organization = organization
14
- @form = form
15
- end
16
-
17
- # Executes the command. Broadcasts these events:
18
- #
19
- # - :ok when everything is valid.
20
- # - :invalid if the form was not valid and we could not proceed.
21
- #
22
- # Returns nothing.
23
- def call
24
- return broadcast(:invalid) if form.invalid?
25
-
26
- return broadcast(:ok, @organization) if update_organization
27
-
28
- broadcast(:invalid)
29
- end
7
+ class UpdateOrganization < Decidim::Commands::UpdateResource
8
+ fetch_form_attributes :name, :default_locale, :reference_prefix, :time_zone, :twitter_handler,
9
+ :facebook_handler, :instagram_handler, :youtube_handler, :github_handler, :badges_enabled,
10
+ :user_groups_enabled, :comments_max_length, :enable_machine_translations,
11
+ :admin_terms_of_service_body, :rich_text_editor_in_public_views, :enable_participatory_space_filters
30
12
 
31
13
  private
32
14
 
33
- attr_reader :form, :organization
34
-
35
- def update_organization
36
- @organization = Decidim.traceability.update!(
37
- @organization,
38
- form.current_user,
39
- attributes
40
- )
41
- end
42
-
43
15
  def attributes
44
- {
45
- name: form.name,
46
- default_locale: form.default_locale,
47
- reference_prefix: form.reference_prefix,
48
- time_zone: form.time_zone,
49
- twitter_handler: form.twitter_handler,
50
- facebook_handler: form.facebook_handler,
51
- instagram_handler: form.instagram_handler,
52
- youtube_handler: form.youtube_handler,
53
- github_handler: form.github_handler,
54
- badges_enabled: form.badges_enabled,
55
- user_groups_enabled: form.user_groups_enabled,
56
- comments_max_length: form.comments_max_length,
57
- enable_machine_translations: form.enable_machine_translations,
58
- admin_terms_of_service_body: form.admin_terms_of_service_body,
59
- rich_text_editor_in_public_views: form.rich_text_editor_in_public_views,
60
- enable_participatory_space_filters: form.enable_participatory_space_filters
61
- }.merge(welcome_notification_attributes)
62
- .merge(machine_translation_attributes || {})
16
+ super
17
+ .merge(welcome_notification_attributes)
18
+ .merge(machine_translation_attributes)
63
19
  end
64
20
 
65
21
  def welcome_notification_attributes
@@ -71,7 +27,7 @@ module Decidim
71
27
  end
72
28
 
73
29
  def machine_translation_attributes
74
- return unless Decidim.config.enable_machine_translations
30
+ return {} unless Decidim.config.enable_machine_translations
75
31
 
76
32
  {
77
33
  machine_translation_display_priority: form.machine_translation_display_priority
@@ -4,59 +4,20 @@ module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic for updating the current
6
6
  # organization appearance.
7
- class UpdateOrganizationAppearance < Decidim::Command
8
- include ::Decidim::AttachmentAttributesMethods
7
+ class UpdateOrganizationAppearance < Decidim::Commands::UpdateResource
8
+ fetch_file_attributes :logo, :highlighted_content_banner_image, :favicon, :official_img_footer
9
9
 
10
- # Public: Initializes the command.
11
- #
12
- # organization - The Organization that will be updated.
13
- # form - A form object with the params.
14
- def initialize(organization, form)
15
- @organization = organization
16
- @form = form
17
- end
18
-
19
- # Executes the command. Broadcasts these events:
20
- #
21
- # - :ok when everything is valid.
22
- # - :invalid if the form was not valid and we could not proceed.
23
- #
24
- # Returns nothing.
25
- def call
26
- return broadcast(:invalid) if form.invalid?
27
-
28
- begin
29
- update_organization
30
- broadcast(:ok, organization)
31
- rescue ActiveRecord::RecordInvalid
32
- image_fields.each do |field|
33
- form.errors.add(field, organization.errors[field]) if organization.errors.include? field
34
- end
35
- broadcast(:invalid)
36
- end
37
- end
10
+ fetch_form_attributes :cta_button_path, :cta_button_text, :description, :official_url,
11
+ :highlighted_content_banner_enabled, :highlighted_content_banner_action_url,
12
+ :highlighted_content_banner_title, :highlighted_content_banner_short_description,
13
+ :highlighted_content_banner_action_title,
14
+ :highlighted_content_banner_action_subtitle, :enable_omnipresent_banner, :omnipresent_banner_url,
15
+ :omnipresent_banner_title, :omnipresent_banner_short_description
38
16
 
39
17
  private
40
18
 
41
- def image_fields
42
- [:logo, :highlighted_content_banner_image, :favicon, :official_img_footer]
43
- end
44
-
45
- attr_reader :form, :organization
46
-
47
- def update_organization
48
- @organization = Decidim.traceability.update!(
49
- organization,
50
- form.current_user,
51
- attributes
52
- )
53
- end
54
-
55
19
  def attributes
56
- appearance_attributes
57
- .merge(attachment_attributes(*image_fields))
58
- .merge(highlighted_content_banner_attributes)
59
- .merge(omnipresent_banner_attributes)
20
+ super
60
21
  .merge(colors_attributes)
61
22
  .delete_if { |_k, val| val.is_a?(Decidim::ApplicationUploader) }
62
23
  .tap do |attributes|
@@ -64,44 +25,12 @@ module Decidim
64
25
  end
65
26
  end
66
27
 
67
- def appearance_attributes
68
- {
69
- cta_button_path: form.cta_button_path,
70
- cta_button_text: form.cta_button_text,
71
- description: form.description,
72
- official_url: form.official_url
73
- }
74
- end
75
-
76
- def highlighted_content_banner_attributes
77
- {
78
- highlighted_content_banner_enabled: form.highlighted_content_banner_enabled,
79
- highlighted_content_banner_action_url: form.highlighted_content_banner_action_url,
80
- highlighted_content_banner_title: form.highlighted_content_banner_title,
81
- highlighted_content_banner_short_description: form.highlighted_content_banner_short_description,
82
- highlighted_content_banner_action_title: form.highlighted_content_banner_action_title,
83
- highlighted_content_banner_action_subtitle: form.highlighted_content_banner_action_subtitle
84
- }
85
- end
86
-
87
- def omnipresent_banner_attributes
88
- {
89
- enable_omnipresent_banner: form.enable_omnipresent_banner,
90
- omnipresent_banner_url: form.omnipresent_banner_url,
91
- omnipresent_banner_short_description: form.omnipresent_banner_short_description,
92
- omnipresent_banner_title: form.omnipresent_banner_title
93
- }
94
- end
95
-
96
28
  def colors_attributes
97
29
  {
98
30
  colors: {
99
31
  primary: form.primary_color,
100
32
  secondary: form.secondary_color,
101
- tertiary: form.tertiary_color,
102
- success: form.success_color,
103
- warning: form.warning_color,
104
- alert: form.alert_color
33
+ tertiary: form.tertiary_color
105
34
  }.compact_blank
106
35
  }
107
36
  end
@@ -3,50 +3,17 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when updating a scope.
6
- class UpdateScope < Decidim::Command
7
- # Public: Initializes the command.
8
- #
9
- # scope - The Scope to update
10
- # form - A form object with the params.
11
- def initialize(scope, form)
12
- @scope = scope
13
- @form = form
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
- return broadcast(:invalid) if form.invalid?
24
-
25
- update_scope
26
- broadcast(:ok)
27
- end
28
-
29
- private
6
+ class UpdateScope < Decidim::Commands::UpdateResource
7
+ fetch_form_attributes :name, :code, :scope_type
30
8
 
31
- attr_reader :form
9
+ protected
32
10
 
33
- def update_scope
34
- Decidim.traceability.update!(
35
- @scope,
36
- form.current_user,
37
- attributes,
11
+ def extra_params
12
+ {
38
13
  extra: {
39
- parent_name: @scope.parent.try(:name),
40
- scope_type_name: form.scope_type.try(:name)
14
+ parent_name: resource.parent.try(:name),
15
+ scope_type_name: resource.scope_type.try(:name)
41
16
  }
42
- )
43
- end
44
-
45
- def attributes
46
- {
47
- name: form.name,
48
- code: form.code,
49
- scope_type: form.scope_type
50
17
  }
51
18
  end
52
19
  end
@@ -3,48 +3,8 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when updating a scope type.
6
- class UpdateScopeType < Decidim::Command
7
- # Public: Initializes the command.
8
- #
9
- # scope_type - The ScopeType to update
10
- # form - A form object with the params.
11
- def initialize(scope_type, form, user)
12
- @scope_type = scope_type
13
- @form = form
14
- @user = user
15
- end
16
-
17
- # Executes the command. Broadcasts these events:
18
- #
19
- # - :ok when everything is valid.
20
- # - :invalid if the form was not valid and we could not proceed.
21
- #
22
- # Returns nothing.
23
- def call
24
- return broadcast(:invalid) if form.invalid?
25
-
26
- update_scope_type
27
- broadcast(:ok)
28
- end
29
-
30
- private
31
-
32
- attr_reader :form
33
-
34
- def update_scope_type
35
- Decidim.traceability.update!(
36
- @scope_type,
37
- @user,
38
- attributes
39
- )
40
- end
41
-
42
- def attributes
43
- {
44
- name: form.name,
45
- plural: form.plural
46
- }
47
- end
6
+ class UpdateScopeType < Decidim::Commands::UpdateResource
7
+ fetch_form_attributes :name, :plural
48
8
  end
49
9
  end
50
10
  end
@@ -3,56 +3,15 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when updating a static page.
6
- class UpdateStaticPage < Decidim::Command
7
- # Public: Initializes the command.
8
- #
9
- # page - The StaticPage to update
10
- # form - A form object with the params.
11
- def initialize(page, form)
12
- @page = page
13
- @form = form
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
- return broadcast(:invalid) if form.invalid?
24
-
25
- update_page
26
- update_organization_tos_version if form.changed_notably
27
- broadcast(:ok)
28
- end
6
+ class UpdateStaticPage < Decidim::Commands::UpdateResource
7
+ fetch_form_attributes :title, :slug, :weight, :topic, :content, :allow_public_access
29
8
 
30
9
  private
31
10
 
32
- attr_reader :form
33
-
34
- def update_page
35
- Decidim.traceability.update!(
36
- @page,
37
- form.current_user,
38
- attributes
39
- )
40
- end
41
-
42
- def attributes
43
- {
44
- title: form.title,
45
- slug: form.slug,
46
- show_in_footer: form.show_in_footer,
47
- weight: form.weight,
48
- topic: form.topic,
49
- content: form.content,
50
- allow_public_access: form.allow_public_access
51
- }
52
- end
11
+ def run_after_hooks
12
+ return unless form.changed_notably
53
13
 
54
- def update_organization_tos_version
55
- UpdateOrganizationTosVersion.call(@form.organization, @page, @form)
14
+ UpdateOrganizationTosVersion.call(form.organization, resource, form)
56
15
  end
57
16
  end
58
17
  end
@@ -3,49 +3,8 @@
3
3
  module Decidim
4
4
  module Admin
5
5
  # A command with all the business logic when updating a static page topic.
6
- class UpdateStaticPageTopic < Decidim::Command
7
- # Public: Initializes the command.
8
- #
9
- # page - The StaticPageTopic to update
10
- # form - A form object with the params.
11
- def initialize(topic, form)
12
- @topic = topic
13
- @form = form
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
- return broadcast(:invalid) if form.invalid?
24
-
25
- update_topic
26
- broadcast(:ok)
27
- end
28
-
29
- private
30
-
31
- attr_reader :form
32
-
33
- def update_topic
34
- Decidim.traceability.update!(
35
- @topic,
36
- form.current_user,
37
- attributes
38
- )
39
- end
40
-
41
- def attributes
42
- {
43
- title: form.title,
44
- description: form.description,
45
- show_in_footer: form.show_in_footer,
46
- weight: form.weight
47
- }
48
- end
6
+ class UpdateStaticPageTopic < Decidim::Commands::UpdateResource
7
+ fetch_form_attributes :title, :description, :show_in_footer, :weight
49
8
  end
50
9
  end
51
10
  end
@@ -5,7 +5,7 @@ module Decidim
5
5
  # A Rails routes constraint to only allow access to an Organization admin to
6
6
  # the organization dashboard.
7
7
  class OrganizationDashboardConstraint
8
- # Initializes the contraint.
8
+ # Initializes the constraint.
9
9
  #
10
10
  # request [Rack::Request]
11
11
  def initialize(request)
@@ -79,7 +79,7 @@ module Decidim
79
79
 
80
80
  # Method to be implemented at the controller. Defines the permissions for
81
81
  # edit and update actions.
82
- # For example `enforce_permission_to :manage_landing_page, :voting, voting: current_space`.
82
+ # For example `enforce_permission_to :update, :process, process: scoped_resource
83
83
  def enforce_permission_to_update_resource
84
84
  raise "#{self.class.name} is expected to implement #enforce_permission_to_update_resource"
85
85
  end
@@ -99,7 +99,7 @@ module Decidim
99
99
  # Method to be implemented at the controller. Returns a string
100
100
  # with the cell name to be used for the drag'n'drop for each content_block.
101
101
  #
102
- # Example: "decidim/votings/content_block"
102
+ # Example: "decidim/participatory_processes/content_block"
103
103
  def resource_content_block_cell
104
104
  raise "#{self.class.name} is expected to implement #resource_content_block_cell"
105
105
  end