decidim-admin 0.23.1 → 0.24.0.rc2

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 (184) 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/subform_multi_toggler.component.js.es6 +2 -2
  12. data/app/assets/javascripts/decidim/admin/subform_toggler.component.js.es6 +2 -2
  13. data/app/assets/javascripts/decidim/admin/user_moderations.js +2 -0
  14. data/app/assets/stylesheets/decidim/admin/_variables.scss +9 -0
  15. data/app/assets/stylesheets/decidim/admin/components/_dropdown-menu.scss +3 -0
  16. data/app/assets/stylesheets/decidim/admin/extra/_action-icon.scss +13 -0
  17. data/app/assets/stylesheets/decidim/admin/extra/_block_user.scss +5 -0
  18. data/app/assets/stylesheets/decidim/admin/extra/_title_bar.scss +1 -0
  19. data/app/assets/stylesheets/decidim/admin/modules/_buttons.scss +1 -0
  20. data/app/assets/stylesheets/decidim/admin/modules/_moderations.scss +39 -0
  21. data/app/assets/stylesheets/decidim/admin/modules/_modules.scss +2 -0
  22. data/app/assets/stylesheets/decidim/admin/modules/_reveal.scss +5 -0
  23. data/app/assets/stylesheets/decidim/admin/modules/_secondary-nav.scss +6 -3
  24. data/app/assets/stylesheets/decidim/admin/modules/_user-login.scss +2 -2
  25. data/app/assets/stylesheets/decidim/admin/user_moderations.scss +3 -0
  26. data/app/assets/stylesheets/decidim/admin/utils/_settings.scss +1 -0
  27. data/app/cells/decidim/admin/content_block/show.erb +1 -1
  28. data/app/cells/decidim/admin/content_block_cell.rb +4 -0
  29. data/app/commands/decidim/admin/block_user.rb +70 -0
  30. data/app/commands/decidim/admin/create_import.rb +29 -0
  31. data/app/commands/decidim/admin/create_participatory_space_admin_user_actions.rb +98 -0
  32. data/app/commands/decidim/admin/create_participatory_space_private_user.rb +1 -1
  33. data/app/commands/decidim/admin/create_static_page.rb +2 -1
  34. data/app/commands/decidim/admin/hide_resource.rb +21 -0
  35. data/app/commands/decidim/admin/impersonate_user.rb +17 -1
  36. data/app/commands/decidim/admin/promote_managed_user.rb +10 -0
  37. data/app/commands/decidim/admin/reorder_content_blocks.rb +6 -3
  38. data/app/commands/decidim/admin/transfer_user.rb +78 -0
  39. data/app/commands/decidim/admin/unblock_user.rb +48 -0
  40. data/app/commands/decidim/admin/unreport_user.rb +46 -0
  41. data/app/commands/decidim/admin/update_organization_appearance.rb +12 -4
  42. data/app/commands/decidim/admin/update_static_page.rb +2 -1
  43. data/app/commands/decidim/admin/verify_user_group.rb +1 -1
  44. data/app/controllers/concerns/decidim/admin/filterable.rb +1 -1
  45. data/app/controllers/concerns/decidim/admin/global_moderation_context.rb +51 -0
  46. data/app/controllers/concerns/decidim/admin/landing_page.rb +105 -0
  47. data/app/controllers/concerns/decidim/admin/landing_page_content_blocks.rb +118 -0
  48. data/app/controllers/concerns/decidim/moderations/admin/filterable.rb +54 -0
  49. data/app/controllers/decidim/admin/block_user_controller.rb +60 -0
  50. data/app/controllers/decidim/admin/components/base_controller.rb +1 -0
  51. data/app/controllers/decidim/admin/conflicts_controller.rb +46 -0
  52. data/app/controllers/decidim/admin/exports_controller.rb +1 -2
  53. data/app/controllers/decidim/admin/global_moderations/reports_controller.rb +18 -0
  54. data/app/controllers/decidim/admin/global_moderations_controller.rb +32 -0
  55. data/app/controllers/decidim/admin/impersonations_controller.rb +1 -1
  56. data/app/controllers/decidim/admin/imports_controller.rb +52 -0
  57. data/app/controllers/decidim/admin/moderated_users_controller.rb +44 -0
  58. data/app/controllers/decidim/admin/moderations/reports_controller.rb +39 -0
  59. data/app/controllers/decidim/admin/moderations_controller.rb +31 -7
  60. data/app/controllers/decidim/admin/officializations_controller.rb +3 -3
  61. data/app/controllers/decidim/admin/organization_homepage_controller.rb +6 -2
  62. data/app/controllers/decidim/admin/static_pages_controller.rb +7 -0
  63. data/app/events/decidim/resource_hidden_event.rb +37 -0
  64. data/app/forms/decidim/admin/block_user_form.rb +25 -0
  65. data/app/forms/decidim/admin/import_form.rb +85 -0
  66. data/app/forms/decidim/admin/organization_appearance_form.rb +1 -2
  67. data/app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb +4 -5
  68. data/app/forms/decidim/admin/participatory_space_private_user_form.rb +0 -5
  69. data/app/forms/decidim/admin/selective_newsletter_form.rb +6 -0
  70. data/app/forms/decidim/admin/static_page_form.rb +6 -1
  71. data/app/forms/decidim/admin/transfer_user_form.rb +19 -0
  72. data/app/helpers/decidim/admin/admin_terms_helper.rb +0 -7
  73. data/app/helpers/decidim/admin/application_helper.rb +5 -4
  74. data/app/helpers/decidim/admin/exports_helper.rb +2 -2
  75. data/app/helpers/decidim/admin/filterable_helper.rb +3 -2
  76. data/app/helpers/decidim/admin/imports_helper.rb +43 -0
  77. data/app/helpers/decidim/admin/menu_helper.rb +10 -0
  78. data/app/helpers/decidim/admin/moderations/reports_helper.rb +40 -0
  79. data/app/helpers/decidim/admin/moderations_helper.rb +36 -0
  80. data/app/helpers/decidim/admin/newsletters_helper.rb +4 -10
  81. data/app/helpers/decidim/admin/settings_helper.rb +2 -1
  82. data/app/helpers/decidim/admin/sidebar_menu_helper.rb +13 -0
  83. data/app/helpers/decidim/admin/user_moderations_helper.rb +6 -0
  84. data/app/jobs/decidim/admin/import_participatory_space_private_user_csv_job.rb +1 -1
  85. data/app/jobs/decidim/admin/verify_user_group_from_csv_job.rb +1 -1
  86. data/app/permissions/decidim/admin/permissions.rb +7 -6
  87. data/app/presenters/decidim/admin/dashboard_metric_charts_presenter.rb +1 -1
  88. data/app/presenters/decidim/admin/secondary_menu_presenter.rb +26 -0
  89. data/app/queries/decidim/admin/active_users_counter.rb +1 -2
  90. data/app/queries/decidim/admin/newsletter_recipients.rb +0 -7
  91. data/app/queries/decidim/admin/user_filter.rb +1 -2
  92. data/app/views/decidim/admin/admin_terms/show.html.erb +1 -1
  93. data/app/views/decidim/admin/attachment_collections/index.html.erb +1 -1
  94. data/app/views/decidim/admin/attachments/index.html.erb +1 -1
  95. data/app/views/decidim/admin/block_user/new.html.erb +22 -0
  96. data/app/views/decidim/admin/categories/index.html.erb +1 -1
  97. data/app/views/decidim/admin/components/_component.html.erb +12 -0
  98. data/app/views/decidim/admin/components/_form.html.erb +1 -1
  99. data/app/views/decidim/admin/conflicts/edit.html.erb +46 -0
  100. data/app/views/decidim/admin/conflicts/index.html.erb +34 -0
  101. data/app/views/decidim/admin/dashboard/show.html.erb +2 -1
  102. data/app/views/decidim/admin/exports/_dropdown.html.erb +1 -1
  103. data/app/views/decidim/admin/imports/_dropdown.html.erb +9 -0
  104. data/app/views/decidim/admin/imports/new.html.erb +57 -0
  105. data/app/views/decidim/admin/moderated_users/_report.html.erb +10 -0
  106. data/app/views/decidim/admin/moderated_users/index.html.erb +78 -0
  107. data/app/views/decidim/admin/moderations/_report.html.erb +1 -1
  108. data/app/views/decidim/admin/moderations/index.html.erb +27 -9
  109. data/app/views/decidim/admin/moderations/reports/index.html.erb +102 -0
  110. data/app/views/decidim/admin/moderations/reports/show.html.erb +62 -0
  111. data/app/views/decidim/admin/newsletters/index.html.erb +1 -1
  112. data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +2 -2
  113. data/app/views/decidim/admin/officializations/index.html.erb +13 -4
  114. data/app/views/decidim/admin/organization_appearance/_form.html.erb +0 -4
  115. data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +1 -1
  116. data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +4 -4
  117. data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +1 -1
  118. data/app/views/decidim/admin/shared/_gallery.html.erb +1 -1
  119. data/app/views/decidim/admin/shared/landing_page/edit.html.erb +47 -0
  120. data/app/views/decidim/admin/shared/landing_page_content_blocks/edit.html.erb +15 -0
  121. data/app/views/decidim/admin/static_pages/_form.html.erb +6 -0
  122. data/app/views/decidim/admin/users/index.html.erb +1 -1
  123. data/app/views/layouts/decidim/admin/_application.html.erb +5 -1
  124. data/app/views/layouts/decidim/admin/_title_bar.html.erb +2 -2
  125. data/app/views/layouts/decidim/admin/global_moderations.html.erb +7 -0
  126. data/app/views/layouts/decidim/admin/newsletters.erb +1 -1
  127. data/app/views/layouts/decidim/admin/settings.html.erb +2 -33
  128. data/app/views/layouts/decidim/admin/users.html.erb +11 -0
  129. data/config/locales/ar.yml +0 -9
  130. data/config/locales/bg.yml +0 -5
  131. data/config/locales/ca.yml +151 -8
  132. data/config/locales/cs.yml +194 -51
  133. data/config/locales/de.yml +172 -28
  134. data/config/locales/el.yml +62 -9
  135. data/config/locales/en.yml +152 -9
  136. data/config/locales/es-MX.yml +150 -7
  137. data/config/locales/es-PY.yml +150 -7
  138. data/config/locales/es.yml +150 -7
  139. data/config/locales/eu.yml +18 -21
  140. data/config/locales/fi-plain.yml +150 -7
  141. data/config/locales/fi.yml +150 -7
  142. data/config/locales/fr-CA.yml +141 -8
  143. data/config/locales/fr.yml +142 -9
  144. data/config/locales/gl.yml +225 -4
  145. data/config/locales/hu.yml +13 -9
  146. data/config/locales/id-ID.yml +0 -3
  147. data/config/locales/is-IS.yml +36 -6
  148. data/config/locales/it.yml +74 -9
  149. data/config/locales/ja.yml +43 -12
  150. data/config/locales/lv.yml +0 -9
  151. data/config/locales/nl.yml +120 -11
  152. data/config/locales/no.yml +16 -9
  153. data/config/locales/pl.yml +168 -24
  154. data/config/locales/pt-BR.yml +0 -3
  155. data/config/locales/pt.yml +0 -9
  156. data/config/locales/ro-RO.yml +21 -9
  157. data/config/locales/ru.yml +0 -7
  158. data/config/locales/si-LK.yml +1 -0
  159. data/config/locales/sk.yml +0 -9
  160. data/config/locales/sl.yml +0 -5
  161. data/config/locales/sr-CS.yml +0 -7
  162. data/config/locales/sv.yml +53 -9
  163. data/config/locales/sw-KE.yml +1 -0
  164. data/config/locales/tr-TR.yml +206 -11
  165. data/config/locales/uk.yml +0 -3
  166. data/config/locales/zh-CN.yml +0 -9
  167. data/config/routes.rb +21 -1
  168. data/lib/decidim/admin.rb +6 -0
  169. data/lib/decidim/admin/engine.rb +76 -1
  170. data/lib/decidim/admin/import.rb +12 -0
  171. data/lib/decidim/admin/import/creator.rb +82 -0
  172. data/lib/decidim/admin/import/importer.rb +82 -0
  173. data/lib/decidim/admin/import/importer_factory.rb +17 -0
  174. data/lib/decidim/admin/import/readers.rb +39 -0
  175. data/lib/decidim/admin/import/readers/base.rb +31 -0
  176. data/lib/decidim/admin/import/readers/csv.rb +23 -0
  177. data/lib/decidim/admin/import/readers/json.rb +25 -0
  178. data/lib/decidim/admin/import/readers/xls.rb +25 -0
  179. data/lib/decidim/admin/test/commands/create_attachment_collection_examples.rb +6 -6
  180. data/lib/decidim/admin/test/commands/create_category_examples.rb +6 -6
  181. data/lib/decidim/admin/test/filterable_examples.rb +1 -8
  182. data/lib/decidim/admin/test/manage_moderations_examples.rb +49 -4
  183. data/lib/decidim/admin/version.rb +1 -1
  184. metadata +78 -19
@@ -32,7 +32,7 @@ module Decidim
32
32
  on(:ok) do |user|
33
33
  notice = I18n.t("officializations.create.success", scope: "decidim.admin")
34
34
 
35
- redirect_to officializations_path(q: user.name), notice: notice
35
+ redirect_to officializations_path(q: { name_or_nickname_or_email_cont: user.name }), notice: notice
36
36
  end
37
37
  end
38
38
  end
@@ -44,7 +44,7 @@ module Decidim
44
44
  on(:ok) do
45
45
  notice = I18n.t("officializations.destroy.success", scope: "decidim.admin")
46
46
 
47
- redirect_to officializations_path(q: user.name), notice: notice
47
+ redirect_to officializations_path(q: { name_or_nickname_or_email_cont: user.name }), notice: notice
48
48
  end
49
49
  end
50
50
  end
@@ -60,7 +60,7 @@ module Decidim
60
60
  private
61
61
 
62
62
  def collection
63
- @collection ||= current_organization.users.not_deleted
63
+ @collection ||= current_organization.users.not_deleted.left_outer_joins(:user_moderation)
64
64
  end
65
65
 
66
66
  def user
@@ -31,11 +31,15 @@ module Decidim
31
31
  end
32
32
 
33
33
  def active_blocks
34
- @active_blocks ||= content_blocks.published
34
+ @active_blocks ||= content_blocks.published.where(manifest_name: Decidim.content_blocks.for(:homepage).map(&:name))
35
+ end
36
+
37
+ def unpublished_blocks
38
+ @unpublished_blocks ||= content_blocks.unpublished.where(manifest_name: Decidim.content_blocks.for(:homepage).map(&:name))
35
39
  end
36
40
 
37
41
  def inactive_blocks
38
- @inactive_blocks ||= content_blocks.unpublished + unused_manifests
42
+ @inactive_blocks ||= unpublished_blocks + unused_manifests
39
43
  end
40
44
 
41
45
  def used_manifests
@@ -82,6 +82,13 @@ module Decidim
82
82
  form_params = params.to_unsafe_hash
83
83
  form_params["static_page"] ||= {}
84
84
  form_params["static_page"]["organization"] = current_organization
85
+ form_params["static_page"]["allow_public_access"] ||= begin
86
+ if page
87
+ page.allow_public_access
88
+ else
89
+ false
90
+ end
91
+ end
85
92
 
86
93
  return form_params unless page
87
94
 
@@ -0,0 +1,37 @@
1
+ # frozen-string_literal: true
2
+
3
+ module Decidim
4
+ class ResourceHiddenEvent < Decidim::Events::SimpleEvent
5
+ i18n_attributes :resource_path, :report_reasons, :resource_type, :resource_content
6
+
7
+ def resource_path
8
+ @resource.reported_content_url
9
+ end
10
+
11
+ def resource_url
12
+ @resource.reported_content_url
13
+ end
14
+
15
+ def report_reasons
16
+ extra["report_reasons"].map do |reason|
17
+ I18n.t("decidim.admin.moderations.report.reasons.#{reason}").downcase
18
+ end.join(", ")
19
+ end
20
+
21
+ def resource_title
22
+ nil
23
+ end
24
+
25
+ def resource_content
26
+ translated_attribute(@resource[@resource.reported_attributes.first]).truncate(100, separator: " ")
27
+ end
28
+
29
+ def resource_text
30
+ "<i>#{resource_content}</i>"
31
+ end
32
+
33
+ def resource_type
34
+ @resource.model_name.human.downcase
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ # A form object used to officialize users from the admin dashboard.
6
+ class BlockUserForm < Form
7
+ attribute :user_id, Integer
8
+ attribute :justification, String
9
+
10
+ validates :user, presence: true
11
+ validates :justification, presence: true, length: { minimum: UserBlock::MINIMUM_JUSTIFICATION_LENGTH }
12
+
13
+ def map_model(user)
14
+ self.user_id = user.id
15
+ end
16
+
17
+ def user
18
+ @user ||= Decidim::User.find_by(
19
+ id: user_id,
20
+ organization: current_organization
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ class ImportForm < Form
6
+ ACCEPTED_MIME_TYPES = Decidim::Admin::Import::Readers::ACCEPTED_MIME_TYPES
7
+
8
+ attribute :creator, String, default: ->(form, _attribute) { form.creators.first[:creator].to_s }
9
+ attribute :file
10
+ attribute :user_group_id, Integer
11
+
12
+ validates :file, presence: true
13
+ validates :creator, presence: true
14
+ validate :accepted_mime_type
15
+ validate :check_invalid_lines
16
+
17
+ def check_invalid_lines
18
+ return if file.blank? || !accepted_mime_type
19
+
20
+ importer.prepare
21
+ invalid_lines = importer.invalid_lines
22
+ errors.add(:file, I18n.t("decidim.admin.imports.invalid_lines", invalid_lines: invalid_lines.join(","))) unless invalid_lines.empty?
23
+ end
24
+
25
+ def file_path
26
+ file&.path
27
+ end
28
+
29
+ def mime_type
30
+ file&.content_type
31
+ end
32
+
33
+ def accepted_mime_type
34
+ accepted_mime_types = ACCEPTED_MIME_TYPES.values
35
+ return true if accepted_mime_types.include?(mime_type)
36
+ # Avoid duplicating error messages
37
+ return false if errors[:file].present?
38
+
39
+ errors.add(
40
+ :file,
41
+ I18n.t(
42
+ "activemodel.errors.new_import.attributes.file.invalid_mime_type",
43
+ valid_mime_types: ACCEPTED_MIME_TYPES.keys.map do |m|
44
+ I18n.t("decidim.admin.new_import.accepted_mime_types.#{m}")
45
+ end.join(", ")
46
+ )
47
+ )
48
+ false
49
+ end
50
+
51
+ def creators
52
+ @creators ||= current_component.manifest.import_manifests.map do |manifest|
53
+ { creator: manifest.creator, name: manifest.creator.to_s.split("::").last.downcase }
54
+ end
55
+ end
56
+
57
+ def creator_class
58
+ return creator.constantize if creator.is_a?(String)
59
+
60
+ creator
61
+ end
62
+
63
+ def user_group
64
+ @user_group ||= Decidim::UserGroup.find_by(
65
+ organization: current_organization,
66
+ id: user_group_id.to_i
67
+ )
68
+ end
69
+
70
+ def importer
71
+ @importer ||= importer_for(file_path, mime_type)
72
+ end
73
+
74
+ def importer_for(filepath, mime_type)
75
+ context[:user_group] = user_group
76
+ Import::ImporterFactory.build(
77
+ filepath,
78
+ mime_type,
79
+ context: context,
80
+ creator: creator_class
81
+ )
82
+ end
83
+ end
84
+ end
85
+ end
@@ -20,7 +20,6 @@ module Decidim
20
20
  attribute :official_img_footer
21
21
  attribute :remove_official_img_footer
22
22
  attribute :official_url
23
- attribute :show_statistics, Boolean
24
23
  attribute :header_snippets, String
25
24
  attribute :cta_button_path, String
26
25
  attribute :highlighted_content_banner_enabled, Boolean, default: false
@@ -47,7 +46,7 @@ module Decidim
47
46
  translatable_attribute :omnipresent_banner_title, String
48
47
  translatable_attribute :omnipresent_banner_short_description, String
49
48
 
50
- validates :cta_button_path, format: { with: %r{\A[a-zA-Z]+[a-zA-Z0-9\-\_/]+\z} }, allow_blank: true
49
+ validates :cta_button_path, format: { with: %r{\A[a-zA-Z]+[a-zA-Z0-9\-_/]+\z} }, allow_blank: true
51
50
  validates :official_img_header,
52
51
  :official_img_footer,
53
52
  :logo,
@@ -15,11 +15,10 @@ module Decidim
15
15
  validate :validate_csv
16
16
 
17
17
  def validate_csv
18
- if file.present?
19
- CSV.foreach(file.path) do |email, user_name|
20
- errors.add(:user_name, :invalid) unless user_name.match?(UserBaseEntity::REGEXP_NAME)
21
- errors.add(:email, :taken) if context && context.current_organization && context.current_organization.admins.where(email: email).exists?
22
- end
18
+ return if file.blank?
19
+
20
+ CSV.foreach(file.path) do |_email, user_name|
21
+ errors.add(:user_name, :invalid) unless user_name.match?(UserBaseEntity::REGEXP_NAME)
23
22
  end
24
23
  end
25
24
  end
@@ -14,11 +14,6 @@ module Decidim
14
14
  validates :name, :email, presence: true
15
15
 
16
16
  validates :name, format: { with: UserBaseEntity::REGEXP_NAME }
17
- validate :admin_uniqueness
18
-
19
- def admin_uniqueness
20
- errors.add(:email, :taken) if context && context.current_organization && context.current_organization.admins.where(email: email).exists?
21
- end
22
17
  end
23
18
  end
24
19
  end
@@ -24,6 +24,12 @@ module Decidim
24
24
  end
25
25
  end
26
26
 
27
+ # Make sure the empty scope is not passed because then some logic could
28
+ # assume erroneously that some scope is selected.
29
+ def scope_ids
30
+ super.select(&:presence)
31
+ end
32
+
27
33
  private
28
34
 
29
35
  def at_least_one_participatory_space_selected
@@ -11,6 +11,7 @@ module Decidim
11
11
  translatable_attribute :content, String
12
12
  attribute :changed_notably, Boolean
13
13
  attribute :show_in_footer, Boolean
14
+ attribute :allow_public_access, Boolean
14
15
  attribute :weight, Integer
15
16
  attribute :topic_id, Integer
16
17
 
@@ -18,7 +19,7 @@ module Decidim
18
19
 
19
20
  validates :slug, presence: true
20
21
  validates :title, :content, translatable_presence: true
21
- validates :slug, format: { with: %r{\A[a-zA-Z]+[a-zA-Z0-9\-\_/]+\z} }, allow_blank: true
22
+ validates :slug, format: { with: %r{\A[a-zA-Z]+[a-zA-Z0-9\-_/]+\z} }, allow_blank: true
22
23
 
23
24
  validate :slug, :slug_uniqueness
24
25
 
@@ -41,6 +42,10 @@ module Decidim
41
42
  )
42
43
  end
43
44
 
45
+ def control_public_access?
46
+ current_organization.force_users_to_authenticate_before_access_organization?
47
+ end
48
+
44
49
  private
45
50
 
46
51
  def slug_uniqueness
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ # A form object used to transfer conflicted users from the admin dashboard.
6
+ #
7
+ # This form will contain a dynamic attribute for the user authorization.
8
+ # This authorization will be selected by the admin user if more than one exists.
9
+ class TransferUserForm < Form
10
+ attribute :email, String
11
+ attribute :reason, String
12
+ attribute :current_user, Decidim::User
13
+ attribute :conflict, Decidim::Verifications::Conflict
14
+
15
+ validates :current_user, presence: true
16
+ validates :conflict, presence: true
17
+ end
18
+ end
19
+ end
@@ -8,13 +8,6 @@ module Decidim
8
8
  current_organization.admin_terms_of_use_body.symbolize_keys[I18n.locale].html_safe
9
9
  end
10
10
 
11
- def admin_terms_announcement_args
12
- {
13
- callout_class: current_user.admin_terms_accepted? ? "success" : "warning",
14
- announcement: announcement_body
15
- }
16
- end
17
-
18
11
  def announcement_body
19
12
  if current_user.admin_terms_accepted?
20
13
  t("accept.success", scope: "decidim.admin.admin_terms_of_use")
@@ -15,10 +15,6 @@ module Decidim
15
15
  include Decidim::Admin::UserRolesHelper
16
16
  include Decidim::Admin::ResourceScopeHelper
17
17
 
18
- def title
19
- current_organization.name
20
- end
21
-
22
18
  # Adds a link to the secondary navigation so admins can easily access the public page of the
23
19
  # element their working on.
24
20
  #
@@ -32,6 +28,11 @@ module Decidim
32
28
  end
33
29
  end
34
30
  end
31
+
32
+ def participatory_space_active_link?(component)
33
+ endpoints = component.manifest.admin_engine.try(:participatory_space_endpoints)
34
+ endpoints && is_active_link?(decidim_admin_participatory_processes.components_path(current_participatory_space), %r{/\d+/manage/(#{endpoints.join("|")})\b})
35
+ end
35
36
  end
36
37
  end
37
38
  end
@@ -10,8 +10,8 @@ module Decidim
10
10
  # current component.
11
11
  #
12
12
  # Returns a rendered dropdown.
13
- def export_dropdown(component = current_component)
14
- render partial: "decidim/admin/exports/dropdown", locals: { component: component }
13
+ def export_dropdown(component = current_component, resource_id = nil)
14
+ render partial: "decidim/admin/exports/dropdown", locals: { component: component, resource_id: resource_id }
15
15
  end
16
16
 
17
17
  # Routes to the correct exporter for a component.
@@ -15,9 +15,10 @@ module Decidim
15
15
 
16
16
  filters_with_values.each_with_object({}) do |(filter, values), hash|
17
17
  link = filter_link_label(filter, i18n_scope)
18
- hash[link] = if values.is_a?(Array)
18
+ hash[link] = case values
19
+ when Array
19
20
  build_submenu_options_tree_from_array(filter, values, i18n_scope)
20
- elsif values.is_a?(Hash)
21
+ when Hash
21
22
  build_submenu_options_tree_from_hash(filter, values, i18n_scope)
22
23
  end
23
24
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Admin
5
+ module ImportsHelper
6
+ # Renders an import dropdown for the provided component. Additional dropdown items
7
+ # can be given as block.
8
+ #
9
+ # component - The component to render the export dropdown for. Defaults to the
10
+ # current component.
11
+ #
12
+ # resource_id - The resource id that is passed to route.
13
+ #
14
+ # Returns a rendered dropdown.
15
+ def import_dropdown(component = current_component, resource_id = nil)
16
+ locals = { component: component, resource_id: resource_id }
17
+ locals[:block] = yield if block_given?
18
+ render partial: "decidim/admin/imports/dropdown", locals: locals
19
+ end
20
+
21
+ # Routes to the correct importer for a component.
22
+ #
23
+ # component - The component to be routed.
24
+ # options - Extra options that need to be passed to the route.
25
+ #
26
+ # Returns the path to the component importer.
27
+ def admin_imports_path(component, options)
28
+ EngineRouter.admin_proxy(component.participatory_space).new_component_import_path(options.merge(component_id: component))
29
+ end
30
+
31
+ # Public: A formatted collection of mime_type to be used in forms.
32
+ def mime_types
33
+ accepted_mime_types = Decidim::Admin::Import::Readers::ACCEPTED_MIME_TYPES.keys
34
+ accepted_mime_types.map { |mime_type| t("decidim.admin.imports.new.accepted_mime_types.#{mime_type}") }.join(", ")
35
+ end
36
+
37
+ # Returns verified user groups of current user
38
+ def user_groups
39
+ Decidim::UserGroups::ManageableUserGroups.for(current_user).verified
40
+ end
41
+ end
42
+ end
43
+ end
@@ -4,6 +4,8 @@ module Decidim
4
4
  module Admin
5
5
  # This module includes helpers to manage menus in admin layout
6
6
  module MenuHelper
7
+ include Decidim::Admin::SidebarMenuHelper
8
+
7
9
  # Public: Returns the main menu presenter object
8
10
  def main_menu
9
11
  @main_menu ||= ::Decidim::MenuPresenter.new(
@@ -12,6 +14,14 @@ module Decidim
12
14
  active_class: "is-active"
13
15
  )
14
16
  end
17
+
18
+ def global_moderation_menu
19
+ @global_moderation_menu ||= sidebar_menu(:admin_global_moderation_menu)
20
+ end
21
+
22
+ def organization_settings_menu
23
+ @organization_settings_menu ||= sidebar_menu(:admin_settings_menu)
24
+ end
15
25
  end
16
26
  end
17
27
  end