decidim-admin 0.23.6 → 0.24.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 (177) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/decidim_admin_manifest.js +1 -0
  3. data/app/assets/javascripts/decidim/admin/application.js.es6 +2 -0
  4. data/app/assets/javascripts/decidim/admin/budget_rule_toggler.component.js.es6 +23 -20
  5. data/app/assets/javascripts/decidim/admin/bundle.js +10 -17
  6. data/app/assets/javascripts/decidim/admin/bundle.js.map +1 -1
  7. data/app/assets/javascripts/decidim/admin/form.js.es6 +1 -0
  8. data/app/assets/javascripts/decidim/admin/import_guidance.js.es6 +29 -0
  9. data/app/assets/javascripts/decidim/admin/moderations.js.es6 +24 -0
  10. data/app/assets/javascripts/decidim/admin/proposal_infinite_edit.js.es6 +20 -0
  11. data/app/assets/javascripts/decidim/admin/user_moderations.js +2 -0
  12. data/app/assets/stylesheets/decidim/admin/_variables.scss +9 -0
  13. data/app/assets/stylesheets/decidim/admin/components/_dropdown-menu.scss +3 -0
  14. data/app/assets/stylesheets/decidim/admin/extra/_action-icon.scss +13 -0
  15. data/app/assets/stylesheets/decidim/admin/extra/_block_user.scss +5 -0
  16. data/app/assets/stylesheets/decidim/admin/extra/_title_bar.scss +1 -0
  17. data/app/assets/stylesheets/decidim/admin/modules/_moderations.scss +39 -0
  18. data/app/assets/stylesheets/decidim/admin/modules/_modules.scss +2 -0
  19. data/app/assets/stylesheets/decidim/admin/modules/_reveal.scss +5 -0
  20. data/app/assets/stylesheets/decidim/admin/modules/_secondary-nav.scss +6 -3
  21. data/app/assets/stylesheets/decidim/admin/modules/_user-login.scss +2 -2
  22. data/app/assets/stylesheets/decidim/admin/user_moderations.scss +3 -0
  23. data/app/assets/stylesheets/decidim/admin/utils/_settings.scss +1 -0
  24. data/app/cells/decidim/admin/content_block/show.erb +1 -1
  25. data/app/cells/decidim/admin/content_block_cell.rb +4 -0
  26. data/app/commands/decidim/admin/block_user.rb +70 -0
  27. data/app/commands/decidim/admin/create_import.rb +29 -0
  28. data/app/commands/decidim/admin/create_participatory_space_private_user.rb +1 -1
  29. data/app/commands/decidim/admin/create_static_page.rb +2 -1
  30. data/app/commands/decidim/admin/hide_resource.rb +21 -0
  31. data/app/commands/decidim/admin/impersonate_user.rb +17 -1
  32. data/app/commands/decidim/admin/promote_managed_user.rb +10 -0
  33. data/app/commands/decidim/admin/reorder_content_blocks.rb +6 -3
  34. data/app/commands/decidim/admin/transfer_user.rb +78 -0
  35. data/app/commands/decidim/admin/unblock_user.rb +48 -0
  36. data/app/commands/decidim/admin/unreport_user.rb +46 -0
  37. data/app/commands/decidim/admin/update_organization_appearance.rb +12 -4
  38. data/app/commands/decidim/admin/update_static_page.rb +2 -1
  39. data/app/commands/decidim/admin/verify_user_group.rb +1 -1
  40. data/app/controllers/concerns/decidim/admin/filterable.rb +1 -1
  41. data/app/controllers/concerns/decidim/admin/global_moderation_context.rb +51 -0
  42. data/app/controllers/concerns/decidim/admin/landing_page.rb +105 -0
  43. data/app/controllers/concerns/decidim/admin/landing_page_content_blocks.rb +118 -0
  44. data/app/controllers/concerns/decidim/moderations/admin/filterable.rb +54 -0
  45. data/app/controllers/decidim/admin/block_user_controller.rb +60 -0
  46. data/app/controllers/decidim/admin/components/base_controller.rb +1 -0
  47. data/app/controllers/decidim/admin/conflicts_controller.rb +46 -0
  48. data/app/controllers/decidim/admin/exports_controller.rb +1 -2
  49. data/app/controllers/decidim/admin/global_moderations/reports_controller.rb +18 -0
  50. data/app/controllers/decidim/admin/global_moderations_controller.rb +32 -0
  51. data/app/controllers/decidim/admin/impersonations_controller.rb +1 -1
  52. data/app/controllers/decidim/admin/imports_controller.rb +52 -0
  53. data/app/controllers/decidim/admin/moderated_users_controller.rb +44 -0
  54. data/app/controllers/decidim/admin/moderations/reports_controller.rb +39 -0
  55. data/app/controllers/decidim/admin/moderations_controller.rb +31 -7
  56. data/app/controllers/decidim/admin/officializations_controller.rb +3 -3
  57. data/app/controllers/decidim/admin/organization_homepage_controller.rb +6 -2
  58. data/app/controllers/decidim/admin/static_pages_controller.rb +7 -0
  59. data/app/events/decidim/resource_hidden_event.rb +37 -0
  60. data/app/forms/decidim/admin/block_user_form.rb +25 -0
  61. data/app/forms/decidim/admin/import_form.rb +85 -0
  62. data/app/forms/decidim/admin/organization_appearance_form.rb +1 -2
  63. data/app/forms/decidim/admin/static_page_form.rb +6 -1
  64. data/app/forms/decidim/admin/transfer_user_form.rb +19 -0
  65. data/app/helpers/decidim/admin/application_helper.rb +5 -4
  66. data/app/helpers/decidim/admin/exports_helper.rb +2 -2
  67. data/app/helpers/decidim/admin/filterable_helper.rb +3 -2
  68. data/app/helpers/decidim/admin/imports_helper.rb +43 -0
  69. data/app/helpers/decidim/admin/menu_helper.rb +10 -0
  70. data/app/helpers/decidim/admin/moderations/reports_helper.rb +40 -0
  71. data/app/helpers/decidim/admin/moderations_helper.rb +36 -0
  72. data/app/helpers/decidim/admin/newsletters_helper.rb +4 -10
  73. data/app/helpers/decidim/admin/settings_helper.rb +2 -1
  74. data/app/helpers/decidim/admin/sidebar_menu_helper.rb +13 -0
  75. data/app/helpers/decidim/admin/user_moderations_helper.rb +6 -0
  76. data/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb +1 -1
  77. data/app/jobs/decidim/admin/verify_user_group_from_csv_job.rb +1 -1
  78. data/app/permissions/decidim/admin/permissions.rb +7 -6
  79. data/app/presenters/decidim/admin/dashboard_metric_charts_presenter.rb +1 -1
  80. data/app/presenters/decidim/admin/secondary_menu_presenter.rb +26 -0
  81. data/app/queries/decidim/admin/active_users_counter.rb +1 -2
  82. data/app/queries/decidim/admin/user_filter.rb +1 -2
  83. data/app/views/decidim/admin/area_types/index.html.erb +2 -2
  84. data/app/views/decidim/admin/areas/index.html.erb +1 -1
  85. data/app/views/decidim/admin/attachment_collections/index.html.erb +1 -1
  86. data/app/views/decidim/admin/attachments/index.html.erb +1 -1
  87. data/app/views/decidim/admin/block_user/new.html.erb +22 -0
  88. data/app/views/decidim/admin/categories/index.html.erb +1 -1
  89. data/app/views/decidim/admin/components/_component.html.erb +12 -0
  90. data/app/views/decidim/admin/components/_form.html.erb +1 -1
  91. data/app/views/decidim/admin/conflicts/edit.html.erb +46 -0
  92. data/app/views/decidim/admin/conflicts/index.html.erb +34 -0
  93. data/app/views/decidim/admin/dashboard/show.html.erb +1 -0
  94. data/app/views/decidim/admin/exports/_dropdown.html.erb +1 -1
  95. data/app/views/decidim/admin/imports/_dropdown.html.erb +9 -0
  96. data/app/views/decidim/admin/imports/new.html.erb +57 -0
  97. data/app/views/decidim/admin/moderated_users/_report.html.erb +10 -0
  98. data/app/views/decidim/admin/moderated_users/index.html.erb +78 -0
  99. data/app/views/decidim/admin/moderations/_report.html.erb +1 -1
  100. data/app/views/decidim/admin/moderations/index.html.erb +27 -9
  101. data/app/views/decidim/admin/moderations/reports/index.html.erb +102 -0
  102. data/app/views/decidim/admin/moderations/reports/show.html.erb +62 -0
  103. data/app/views/decidim/admin/newsletters/index.html.erb +1 -1
  104. data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +3 -3
  105. data/app/views/decidim/admin/newsletters/show.html.erb +1 -1
  106. data/app/views/decidim/admin/officializations/index.html.erb +13 -4
  107. data/app/views/decidim/admin/organization_appearance/_form.html.erb +0 -4
  108. data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +1 -1
  109. data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +4 -4
  110. data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +1 -1
  111. data/app/views/decidim/admin/scopes/index.html.erb +1 -1
  112. data/app/views/decidim/admin/shared/landing_page/edit.html.erb +47 -0
  113. data/app/views/decidim/admin/shared/landing_page_content_blocks/edit.html.erb +15 -0
  114. data/app/views/decidim/admin/static_pages/_form.html.erb +6 -0
  115. data/app/views/decidim/admin/static_pages/_topic.html.erb +3 -3
  116. data/app/views/decidim/admin/users/index.html.erb +2 -2
  117. data/app/views/layouts/decidim/admin/_application.html.erb +5 -1
  118. data/app/views/layouts/decidim/admin/_title_bar.html.erb +2 -2
  119. data/app/views/layouts/decidim/admin/global_moderations.html.erb +7 -0
  120. data/app/views/layouts/decidim/admin/newsletters.erb +1 -1
  121. data/app/views/layouts/decidim/admin/pages.html.erb +2 -2
  122. data/app/views/layouts/decidim/admin/settings.html.erb +2 -33
  123. data/app/views/layouts/decidim/admin/users.html.erb +11 -0
  124. data/config/locales/ar.yml +0 -5
  125. data/config/locales/bg.yml +0 -1
  126. data/config/locales/ca.yml +33 -7
  127. data/config/locales/cs.yml +154 -9
  128. data/config/locales/de.yml +150 -5
  129. data/config/locales/el.yml +55 -5
  130. data/config/locales/en.yml +150 -5
  131. data/config/locales/es-MX.yml +42 -7
  132. data/config/locales/es-PY.yml +42 -7
  133. data/config/locales/es.yml +42 -7
  134. data/config/locales/eu.yml +0 -3
  135. data/config/locales/fi-plain.yml +148 -3
  136. data/config/locales/fi.yml +148 -3
  137. data/config/locales/fr-CA.yml +139 -4
  138. data/config/locales/fr.yml +139 -4
  139. data/config/locales/gl.yml +83 -12
  140. data/config/locales/hu.yml +13 -5
  141. data/config/locales/id-ID.yml +0 -3
  142. data/config/locales/is-IS.yml +19 -3
  143. data/config/locales/it.yml +59 -5
  144. data/config/locales/ja.yml +38 -5
  145. data/config/locales/lv.yml +0 -5
  146. data/config/locales/nl.yml +110 -4
  147. data/config/locales/no.yml +13 -7
  148. data/config/locales/pl.yml +159 -14
  149. data/config/locales/pt-BR.yml +0 -3
  150. data/config/locales/pt.yml +0 -5
  151. data/config/locales/ro-RO.yml +121 -133
  152. data/config/locales/ru.yml +0 -3
  153. data/config/locales/sk.yml +0 -5
  154. data/config/locales/sl.yml +0 -1
  155. data/config/locales/sr-CS.yml +0 -3
  156. data/config/locales/sv.yml +51 -5
  157. data/config/locales/tr-TR.yml +81 -4
  158. data/config/locales/uk.yml +0 -3
  159. data/config/locales/zh-CN.yml +0 -5
  160. data/config/routes.rb +21 -1
  161. data/lib/decidim/admin/engine.rb +76 -1
  162. data/lib/decidim/admin/import/creator.rb +82 -0
  163. data/lib/decidim/admin/import/importer.rb +82 -0
  164. data/lib/decidim/admin/import/importer_factory.rb +17 -0
  165. data/lib/decidim/admin/import/readers/base.rb +31 -0
  166. data/lib/decidim/admin/import/readers/csv.rb +23 -0
  167. data/lib/decidim/admin/import/readers/json.rb +25 -0
  168. data/lib/decidim/admin/import/readers/xls.rb +25 -0
  169. data/lib/decidim/admin/import/readers.rb +39 -0
  170. data/lib/decidim/admin/import.rb +12 -0
  171. data/lib/decidim/admin/test/commands/create_attachment_collection_examples.rb +6 -6
  172. data/lib/decidim/admin/test/commands/create_category_examples.rb +6 -6
  173. data/lib/decidim/admin/test/filterable_examples.rb +1 -8
  174. data/lib/decidim/admin/test/manage_moderations_examples.rb +49 -4
  175. data/lib/decidim/admin/version.rb +1 -1
  176. data/lib/decidim/admin.rb +6 -0
  177. metadata +72 -16
@@ -1,5 +1,6 @@
1
1
  // = require ./budget_rule_toggler.component
2
2
  // = require ./scope_picker_enabler.component
3
+ // = require ./proposal_infinite_edit
3
4
 
4
5
  ((exports) => {
5
6
  const { BudgetRuleTogglerComponent } = exports.DecidimAdmin;
@@ -0,0 +1,29 @@
1
+ (() => {
2
+ const $creatorSelect = $("#import_creator");
3
+ const $creatorGuidances = $(".creator-guidances").find(".guidance");
4
+
5
+ const showGuidance = (text) => {
6
+ const formatted = text.replace(/\s/g, "").toLocaleLowerCase();
7
+ $.each($creatorGuidances, (_index, currentValue) => {
8
+ if (currentValue.className.includes(formatted)) {
9
+ const elem = $(currentValue)
10
+ elem.show();
11
+ }
12
+ })
13
+ }
14
+
15
+ $creatorSelect.on("change", function() {
16
+ const text = $("#import_creator option:selected").text()
17
+ $creatorGuidances.hide();
18
+ if (text) {
19
+ showGuidance(text)
20
+ }
21
+ })
22
+
23
+ if ($creatorSelect.children("option").length < 2) {
24
+ $("label[for='import_creator']").hide();
25
+ }
26
+ $creatorGuidances.hide();
27
+ $creatorGuidances.first().show();
28
+ })();
29
+
@@ -0,0 +1,24 @@
1
+ ((exports) => {
2
+ const $ = exports.$; // eslint-disable-line
3
+
4
+ $(() => {
5
+ const $moderationDetails = $(".moderation-details");
6
+ const $toggleContentButton = $moderationDetails.find(".toggle-content");
7
+ const $reportedContent = $moderationDetails.find(".reported-content");
8
+ const $currentContent = $reportedContent.find(".current");
9
+ const $originalContent = $reportedContent.find(".original");
10
+
11
+ $originalContent.hide();
12
+
13
+ $toggleContentButton.on("click", () => {
14
+ $currentContent.toggle();
15
+ $originalContent.toggle();
16
+
17
+ if ($currentContent.is(":hidden")) {
18
+ $toggleContentButton.html($toggleContentButton.data("see-current-button-label"));
19
+ } else {
20
+ $toggleContentButton.html($toggleContentButton.data("see-original-button-label"));
21
+ }
22
+ })
23
+ })
24
+ })(window)
@@ -0,0 +1,20 @@
1
+ $(() => {
2
+ const $limitiedTimeLabel = $("label[for='component_settings_proposal_edit_time_limited']")
3
+ const $limitedTimeRadioButton = $("#component_settings_proposal_edit_time_limited")
4
+ const $infiniteTimeRadioButton = $("#component_settings_proposal_edit_time_infinite")
5
+ const $editTimeContainer = $(".proposal_edit_before_minutes_container")
6
+
7
+ $editTimeContainer.detach().appendTo($limitiedTimeLabel)
8
+
9
+ if ($infiniteTimeRadioButton.is(":checked")) {
10
+ $editTimeContainer.hide();
11
+ }
12
+
13
+ $limitedTimeRadioButton.on("click", () => {
14
+ $editTimeContainer.show();
15
+ })
16
+
17
+ $infiniteTimeRadioButton.on("click", () => {
18
+ $editTimeContainer.hide();
19
+ })
20
+ })
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -1,3 +1,12 @@
1
+ // Foundation Variables
2
+ $primary-color: null;
3
+ $secondary-color: null;
4
+ $success-color: null;
5
+ $warning-color: null;
6
+ $alert-color: null;
7
+ $-zf-size: null;
8
+ $-zf-bp-value: null;
9
+
1
10
  // Variables
2
11
 
3
12
  $brand: #9675ce !default;
@@ -0,0 +1,3 @@
1
+ .dropdown .is-dropdown-submenu a{
2
+ color: $secondary;
3
+ }
@@ -9,6 +9,19 @@
9
9
  color: $warning-color;
10
10
  vertical-align: bottom;
11
11
  }
12
+
13
+ &.action-icon--success{
14
+ color: $success-color;
15
+ vertical-align: bottom;
16
+ }
17
+ }
18
+
19
+ .action-space{
20
+ display: inline-block;
21
+
22
+ &:not(:last-child){
23
+ margin-right: 1rem;
24
+ }
12
25
  }
13
26
  }
14
27
 
@@ -0,0 +1,5 @@
1
+ .new_user_block{
2
+ .form-error{
3
+ margin-top: 0;
4
+ }
5
+ }
@@ -70,6 +70,7 @@
70
70
  margin-left: 0;
71
71
 
72
72
  .dropdown.menu > li.is-dropdown-submenu-parent > a::after{
73
+ border-color: var(--secondary);
73
74
  border-width: 3px;
74
75
  right: 10px;
75
76
  margin-top: 0;
@@ -0,0 +1,39 @@
1
+ .moderation-details{
2
+ .toggle-content{
3
+ cursor: pointer;
4
+ margin-left: .5rem;
5
+ font-size: .9rem;
6
+ }
7
+
8
+ .reported-content{
9
+ .original{
10
+ display: none;
11
+ }
12
+ }
13
+
14
+ .callout{
15
+ &-text{
16
+ margin-left: .5rem;
17
+
18
+ .icon{
19
+ width: .6rem;
20
+ margin: 0 .2rem;
21
+ }
22
+ }
23
+ }
24
+
25
+ dd{
26
+ padding: $global-padding;
27
+ background-color: $light-gray;
28
+ margin-bottom: .5rem;
29
+ }
30
+
31
+ .reportable-authors{
32
+ list-style: none;
33
+ margin: 0;
34
+
35
+ .icon{
36
+ margin-left: .5rem;
37
+ }
38
+ }
39
+ }
@@ -30,6 +30,7 @@
30
30
  @import "draggable-list";
31
31
  @import "loading-spinner";
32
32
  @import "import_result";
33
+ @import "reveal";
33
34
 
34
35
  // mentions__container
35
36
  @import "decidim/modules/tags";
@@ -39,3 +40,4 @@
39
40
 
40
41
  //Admin dashboard
41
42
  @import "users_statistics";
43
+ @import "moderations";
@@ -0,0 +1,5 @@
1
+ .reveal__buttons{
2
+ display: flex;
3
+ justify-content: space-between;
4
+ padding: 0 1rem;
5
+ }
@@ -62,7 +62,8 @@ $process-title-height: 3rem;
62
62
  }
63
63
 
64
64
  .secondary-nav__title,
65
- .process-title-content{
65
+ .process-title-content,
66
+ .voting-title-content{
66
67
  margin-bottom: 1.5rem;
67
68
  font-size: .8rem;
68
69
  letter-spacing: .1em;
@@ -90,13 +91,15 @@ $process-title-height: 3rem;
90
91
  color: $body-font-color;
91
92
  }
92
93
 
93
- .process-title{
94
+ .process-title,
95
+ .voting-title{
94
96
  @include breakpoint(large){
95
97
  margin-bottom: $process-title-height;
96
98
  }
97
99
  }
98
100
 
99
- .process-title-content{
101
+ .process-title-content,
102
+ .voting-title-content{
100
103
  @include breakpoint(large){
101
104
  position: absolute;
102
105
  left: 120px;
@@ -18,8 +18,8 @@
18
18
 
19
19
  .dropdown.menu > li.is-dropdown-submenu-parent > a::after{
20
20
  border-top-color: $white;
21
- border-width: 4px;
21
+ border-width: 6px;
22
22
  right: 0;
23
- margin-top: -1px;
23
+ margin-top: -3px;
24
24
  }
25
25
  }
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the UserModerations controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: https://sass-lang.com/
@@ -75,6 +75,7 @@ $foundation-palette: (
75
75
  warning: #ffb300,
76
76
  alert: #e66a5d,
77
77
  );
78
+
78
79
  $lighter-gray: #f6f6f6;
79
80
  $light-gray: #eee;
80
81
  $medium-gray: #adadad;
@@ -3,7 +3,7 @@
3
3
  <%= t(public_name_key) %>
4
4
  <div>
5
5
  <% if has_settings? %>
6
- <%= link_to decidim_admin.edit_organization_homepage_content_block_path(manifest_name), class: "mr-s text-muted" do %>
6
+ <%= link_to edit_content_block_path, class: "mr-s text-muted" do %>
7
7
  <%= icon "pencil", role: "img" %>
8
8
  <% end %>
9
9
  <% end %>
@@ -11,6 +11,10 @@ module Decidim
11
11
  model.try(:manifest_name) || model.name
12
12
  end
13
13
 
14
+ def edit_content_block_path
15
+ decidim_admin.edit_organization_homepage_content_block_path(manifest_name)
16
+ end
17
+
14
18
  def decidim_admin
15
19
  Decidim::Admin::Engine.routes.url_helpers
16
20
  end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ class BlockUser < Rectify::Command
6
+ # Public: Initializes the command.
7
+ #
8
+ # form - BlockUserForm
9
+ def initialize(form)
10
+ @form = form
11
+ end
12
+
13
+ # Executes the command. Broadcasts these events:
14
+ #
15
+ # - :ok when everything is valid, together with the resource.
16
+ # - :invalid if the resource is not reported
17
+ #
18
+ # Returns nothing.
19
+ def call
20
+ return broadcast(:invalid) unless form.valid?
21
+
22
+ transaction do
23
+ block!
24
+ register_justification!
25
+ notify_user!
26
+ end
27
+
28
+ broadcast(:ok, form.user)
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :form
34
+
35
+ def register_justification!
36
+ @current_blocking = UserBlock.create!(
37
+ justification: form.justification,
38
+ user: form.user,
39
+ blocking_user: form.current_user
40
+ )
41
+ end
42
+
43
+ def notify_user!
44
+ Decidim::BlockUserJob.perform_later(
45
+ @current_blocking.user,
46
+ @current_blocking.justification
47
+ )
48
+ end
49
+
50
+ def block!
51
+ Decidim.traceability.perform_action!(
52
+ "block",
53
+ form.user,
54
+ form.current_user,
55
+ extra: {
56
+ reportable_type: form.user.class.name,
57
+ current_justification: form.justification
58
+ }
59
+ ) do
60
+ form.user.blocked = true
61
+ form.user.blocked_at = Time.current
62
+ form.user.blocking = @current_blocking
63
+ form.user.extended_data["user_name"] = form.user.name
64
+ form.user.name = "Blocked user"
65
+ form.user.save!
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ class CreateImport < Rectify::Command
6
+ def initialize(form)
7
+ @form = form
8
+ end
9
+
10
+ def call
11
+ return broadcast(:invalid) if form.invalid?
12
+
13
+ imported_data = form.importer.prepare
14
+ transaction do
15
+ form.importer.import!
16
+
17
+ return broadcast(:ok, imported_data)
18
+ rescue StandardError
19
+ raise ActiveRecord::Rollback
20
+ end
21
+
22
+ # Something went wrong with import/finish
23
+ broadcast(:invalid)
24
+ end
25
+
26
+ attr_reader :form
27
+ end
28
+ end
29
+ end
@@ -10,7 +10,7 @@ module Decidim
10
10
  # form - A form object with the params.
11
11
  # private_user_to - The private_user_to that will hold the
12
12
  # user role
13
- def initialize(form, current_user, private_user_to, via_csv = false)
13
+ def initialize(form, current_user, private_user_to, via_csv: false)
14
14
  @form = form
15
15
  @current_user = current_user
16
16
  @private_user_to = private_user_to
@@ -40,7 +40,8 @@ module Decidim
40
40
  show_in_footer: form.show_in_footer,
41
41
  weight: form.weight,
42
42
  topic: form.topic,
43
- organization: form.organization
43
+ organization: form.organization,
44
+ allow_public_access: form.allow_public_access
44
45
  )
45
46
  end
46
47
 
@@ -23,6 +23,9 @@ module Decidim
23
23
  return broadcast(:invalid) unless hideable?
24
24
 
25
25
  hide!
26
+
27
+ send_hide_notification_to_author
28
+
26
29
  broadcast(:ok, @reportable)
27
30
  end
28
31
 
@@ -44,6 +47,24 @@ module Decidim
44
47
  @reportable.moderation.update!(hidden_at: Time.current)
45
48
  end
46
49
  end
50
+
51
+ def send_hide_notification_to_author
52
+ data = {
53
+ event: "decidim.events.reports.resource_hidden",
54
+ event_class: Decidim::ResourceHiddenEvent,
55
+ resource: @reportable,
56
+ extra: {
57
+ report_reasons: report_reasons
58
+ },
59
+ affected_users: @reportable.try(:authors) || [@reportable.try(:normalized_author)]
60
+ }
61
+
62
+ Decidim::EventsManager.publish(data)
63
+ end
64
+
65
+ def report_reasons
66
+ @reportable.moderation.reports.pluck(:reason).uniq
67
+ end
47
68
  end
48
69
  end
49
70
  end
@@ -26,7 +26,8 @@ module Decidim
26
26
 
27
27
  create_authorization
28
28
 
29
- create_impersonation_log
29
+ impersonation_log = create_impersonation_log
30
+ create_action_log(impersonation_log)
30
31
  end
31
32
 
32
33
  enqueue_expire_job
@@ -60,6 +61,21 @@ module Decidim
60
61
  .set(wait: Decidim::ImpersonationLog::SESSION_TIME_IN_MINUTES.minutes)
61
62
  .perform_later(user, form.current_user)
62
63
  end
64
+
65
+ def create_action_log(impersonation_log)
66
+ Decidim.traceability.perform_action!(
67
+ "manage",
68
+ impersonation_log,
69
+ form.current_user,
70
+ resource: {
71
+ name: user.name,
72
+ id: user.id,
73
+ nickname: user.nickname
74
+ },
75
+ visibility: "admin-only",
76
+ reason: form.reason
77
+ )
78
+ end
63
79
  end
64
80
  end
65
81
  end
@@ -30,6 +30,7 @@ module Decidim
30
30
 
31
31
  promote_user
32
32
  invite_user
33
+ create_action_log
33
34
 
34
35
  broadcast(:ok)
35
36
  end
@@ -51,6 +52,15 @@ module Decidim
51
52
  def email_already_exists?
52
53
  Decidim::User.where(email: form.email.downcase).any?
53
54
  end
55
+
56
+ def create_action_log
57
+ Decidim.traceability.perform_action!(
58
+ "promote",
59
+ user,
60
+ form.current_user,
61
+ visibility: "admin-only"
62
+ )
63
+ end
54
64
  end
55
65
  end
56
66
  end
@@ -10,10 +10,12 @@ module Decidim
10
10
  # organization - the Organization where the content blocks reside
11
11
  # scope - the scope applied to the content blocks
12
12
  # order - an Array holding the order of IDs of published content blocks.
13
- def initialize(organization, scope, order)
13
+ # scoped_resource_id - (optional) The id of the resource the content blocks belongs to.
14
+ def initialize(organization, scope, order, scoped_resource_id = nil)
14
15
  @organization = organization
15
16
  @scope = scope
16
17
  @order = order
18
+ @scoped_resource_id = scoped_resource_id
17
19
  end
18
20
 
19
21
  # Executes the command. Broadcasts these events:
@@ -31,7 +33,7 @@ module Decidim
31
33
 
32
34
  private
33
35
 
34
- attr_reader :organization, :scope
36
+ attr_reader :organization, :scope, :scoped_resource_id
35
37
 
36
38
  def reorder_steps
37
39
  transaction do
@@ -78,6 +80,7 @@ module Decidim
78
80
  Decidim::ContentBlock.create!(
79
81
  organization: organization,
80
82
  scope_name: scope,
83
+ scoped_resource_id: scoped_resource_id.presence,
81
84
  weight: weight,
82
85
  manifest_name: manifest_name
83
86
  )
@@ -90,7 +93,7 @@ module Decidim
90
93
  end
91
94
 
92
95
  def collection
93
- @collection ||= Decidim::ContentBlock.for_scope(scope, organization: organization)
96
+ @collection ||= Decidim::ContentBlock.for_scope(scope, organization: organization).where(scoped_resource_id: scoped_resource_id)
94
97
  end
95
98
  end
96
99
  end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ # A command with all the business logic to transfer a managed user.
6
+ class TransferUser < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # form
10
+ # user - The current user
11
+ # managed_user - The managed User
12
+ def initialize(form)
13
+ @form = form
14
+ end
15
+
16
+ # Executes the command. Broadcasts these events:
17
+ #
18
+ # - :ok when everything is valid.
19
+ # - :invalid if the impersonation is not valid.
20
+ #
21
+ # Returns nothing.
22
+ def call
23
+ return broadcast(:invalid) unless form.valid?
24
+
25
+ transaction do
26
+ update_managed_user
27
+ mark_conflict_as_solved
28
+ create_action_log
29
+ end
30
+
31
+ broadcast(:ok)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :form
37
+
38
+ def new_user
39
+ form.conflict.current_user
40
+ end
41
+
42
+ def managed_user
43
+ form.conflict.managed_user
44
+ end
45
+
46
+ def current_user
47
+ form.current_user
48
+ end
49
+
50
+ def update_managed_user
51
+ clean_email_and_delete_new_user if form.email == new_user.email
52
+ managed_user.email = form.email
53
+ managed_user.encrypted_password = new_user.encrypted_password
54
+ managed_user.confirmed_at = new_user.confirmed_at
55
+ managed_user.managed = false
56
+ managed_user.skip_reconfirmation!
57
+ managed_user.save!
58
+ end
59
+
60
+ def clean_email_and_delete_new_user
61
+ new_user.update(deleted_at: Time.now.utc, email: "")
62
+ end
63
+
64
+ def mark_conflict_as_solved
65
+ form.conflict.update(solved: true)
66
+ end
67
+
68
+ def create_action_log
69
+ Decidim.traceability.perform_action!(
70
+ "transfer",
71
+ form.conflict.managed_user,
72
+ current_user,
73
+ visibility: "admin-only"
74
+ )
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ class UnblockUser < Rectify::Command
6
+ # Public: Initializes the command.
7
+ #
8
+ # blocked_user - the user that is unblocked
9
+ # current_user - the user performing the action
10
+ def initialize(blocked_user, current_user)
11
+ @blocked_user = blocked_user
12
+ @current_user = current_user
13
+ end
14
+
15
+ # Executes the command. Broadcasts these events:
16
+ #
17
+ # - :ok when everything is valid, together with the resource.
18
+ # - :invalid if the resource is not reported
19
+ #
20
+ # Returns nothing.
21
+ def call
22
+ return broadcast(:invalid) unless @blocked_user.blocked?
23
+
24
+ unblock!
25
+ broadcast(:ok, @blocked_user)
26
+ end
27
+
28
+ private
29
+
30
+ def unblock!
31
+ Decidim.traceability.perform_action!(
32
+ "unblock",
33
+ @blocked_user,
34
+ @current_user,
35
+ extra: {
36
+ reportable_type: @blocked_user.class.name
37
+ }
38
+ ) do
39
+ @blocked_user.blocked = false
40
+ @blocked_user.blocked_at = nil
41
+ @blocked_user.block_id = nil
42
+ @blocked_user.name = @blocked_user.user_name
43
+ @blocked_user.save!
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end