decidim-core 0.29.2 → 0.29.4

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 (147) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/address/show.erb +3 -3
  3. data/app/cells/decidim/author/show.erb +2 -4
  4. data/app/cells/decidim/content_blocks/participatory_space_extra_data/extra_data.erb +2 -2
  5. data/app/cells/decidim/participatory_space_dropdown_metadata/metadata.erb +4 -4
  6. data/app/cells/decidim/participatory_space_dropdown_metadata/show.erb +5 -3
  7. data/app/cells/decidim/profile_actions/show.erb +1 -1
  8. data/app/cells/decidim/report_button/already_reported_modal.erb +2 -2
  9. data/app/cells/decidim/report_button/flag_modal.erb +13 -27
  10. data/app/cells/decidim/report_button_cell.rb +2 -8
  11. data/app/cells/decidim/report_user_button/already_reported_modal.erb +11 -0
  12. data/app/cells/decidim/report_user_button/flag_modal.erb +46 -0
  13. data/app/cells/decidim/report_user_button/show.erb +2 -0
  14. data/app/cells/decidim/report_user_button_cell.rb +59 -0
  15. data/app/cells/decidim/resource_types_filter/show.erb +1 -1
  16. data/app/cells/decidim/resource_types_filter_cell.rb +6 -6
  17. data/app/cells/decidim/user_activity/show.erb +1 -1
  18. data/app/commands/decidim/create_omniauth_registration.rb +14 -8
  19. data/app/commands/decidim/create_report.rb +6 -7
  20. data/app/commands/decidim/invite_user.rb +1 -1
  21. data/app/commands/decidim/search.rb +14 -0
  22. data/app/controllers/concerns/decidim/participatory_space_context.rb +4 -1
  23. data/app/controllers/decidim/profiles_controller.rb +2 -2
  24. data/app/controllers/decidim/reports_controller.rb +7 -2
  25. data/app/controllers/decidim/user_activities_controller.rb +1 -1
  26. data/app/forms/decidim/account_form.rb +5 -2
  27. data/app/forms/decidim/omniauth_registration_form.rb +1 -1
  28. data/app/forms/decidim/registration_form.rb +1 -1
  29. data/app/helpers/decidim/menu_helper.rb +2 -2
  30. data/app/helpers/decidim/orders_helper.rb +2 -1
  31. data/app/helpers/decidim/paginate_helper.rb +1 -1
  32. data/app/helpers/decidim/participatory_space_helpers.rb +1 -1
  33. data/app/helpers/decidim/tooltip_helper.rb +4 -1
  34. data/app/jobs/decidim/hide_child_resources_job.rb +24 -0
  35. data/app/mailers/decidim/notifications_digest_mailer.rb +7 -1
  36. data/app/mailers/decidim/reported_mailer.rb +18 -2
  37. data/app/models/decidim/action_log.rb +1 -9
  38. data/app/models/decidim/report.rb +1 -1
  39. data/app/models/decidim/user.rb +0 -4
  40. data/app/models/decidim/user_base_entity.rb +4 -0
  41. data/app/packs/src/decidim/datepicker/datepicker_functions.js +3 -3
  42. data/app/packs/src/decidim/index.js +4 -2
  43. data/app/packs/src/decidim/input_character_counter.js +1 -1
  44. data/app/packs/src/decidim/map/provider/here.js +1 -1
  45. data/app/packs/stylesheets/decidim/_cards.scss +1 -1
  46. data/app/packs/stylesheets/decidim/_content_blocks.scss +4 -0
  47. data/app/packs/stylesheets/decidim/_hashtags.scss +5 -0
  48. data/app/packs/stylesheets/decidim/_header.scss +65 -40
  49. data/app/packs/stylesheets/decidim/application.scss +1 -0
  50. data/app/permissions/decidim/default_permissions.rb +2 -0
  51. data/app/presenters/decidim/log/user_presenter.rb +1 -0
  52. data/app/presenters/decidim/notification_to_mailer_presenter.rb +7 -3
  53. data/app/presenters/decidim/user_presenter.rb +1 -1
  54. data/app/queries/decidim/last_activity.rb +25 -0
  55. data/app/services/decidim/base_diff_renderer.rb +2 -0
  56. data/app/services/decidim/static_map_generator.rb +1 -1
  57. data/app/views/decidim/last_activities/index.html.erb +1 -1
  58. data/app/views/decidim/messaging/conversations/_reply_form.html.erb +1 -2
  59. data/app/views/decidim/messaging/conversations/_start.html.erb +1 -1
  60. data/app/views/decidim/reported_mailer/hidden_automatically.html.erb +25 -0
  61. data/app/views/decidim/reported_mailer/hidden_manually.html.erb +25 -0
  62. data/app/views/decidim/reported_mailer/report.html.erb +1 -1
  63. data/app/views/decidim/searches/_count.html.erb +1 -1
  64. data/app/views/decidim/searches/_filters.html.erb +40 -38
  65. data/app/views/decidim/shared/_orders.html.erb +2 -2
  66. data/app/views/decidim/shared/_results_per_page.html.erb +1 -1
  67. data/app/views/kaminari/decidim/_page.html.erb +1 -1
  68. data/app/views/kaminari/decidim/_paginator.html.erb +1 -1
  69. data/app/views/layouts/decidim/_logo.html.erb +2 -2
  70. data/app/views/layouts/decidim/footer/_main_legal.html.erb +1 -1
  71. data/app/views/layouts/decidim/header/_menu_breadcrumb_main_dropdown_desktop.html.erb +5 -11
  72. data/app/views/layouts/decidim/header/_menu_breadcrumb_mobile_tablet.html.erb +5 -5
  73. data/config/locales/ar.yml +41 -34
  74. data/config/locales/bg.yml +10 -30
  75. data/config/locales/bs-BA.yml +2 -0
  76. data/config/locales/ca-IT.yml +2122 -0
  77. data/config/locales/ca.yml +69 -30
  78. data/config/locales/cs.yml +73 -36
  79. data/config/locales/de.yml +64 -26
  80. data/config/locales/el.yml +10 -21
  81. data/config/locales/en.yml +56 -17
  82. data/config/locales/eo.yml +2 -0
  83. data/config/locales/es-MX.yml +69 -30
  84. data/config/locales/es-PY.yml +74 -35
  85. data/config/locales/es.yml +72 -33
  86. data/config/locales/eu.yml +128 -91
  87. data/config/locales/fi-plain.yml +44 -34
  88. data/config/locales/fi.yml +46 -36
  89. data/config/locales/fr-CA.yml +72 -29
  90. data/config/locales/fr.yml +71 -28
  91. data/config/locales/ga-IE.yml +4 -4
  92. data/config/locales/gl.yml +25 -20
  93. data/config/locales/hu.yml +9 -29
  94. data/config/locales/id-ID.yml +24 -21
  95. data/config/locales/is-IS.yml +10 -6
  96. data/config/locales/it.yml +35 -32
  97. data/config/locales/ja.yml +70 -30
  98. data/config/locales/lb.yml +24 -27
  99. data/config/locales/lt.yml +5 -23
  100. data/config/locales/lv.yml +18 -20
  101. data/config/locales/nl.yml +23 -23
  102. data/config/locales/no.yml +18 -21
  103. data/config/locales/pl.yml +7 -27
  104. data/config/locales/pt-BR.yml +11 -30
  105. data/config/locales/pt.yml +18 -21
  106. data/config/locales/ro-RO.yml +239 -92
  107. data/config/locales/ru.yml +23 -13
  108. data/config/locales/sk.yml +29 -23
  109. data/config/locales/sl.yml +4 -0
  110. data/config/locales/sr-CS.yml +2 -0
  111. data/config/locales/sv.yml +49 -37
  112. data/config/locales/tr-TR.yml +25 -28
  113. data/config/locales/uk.yml +12 -7
  114. data/config/locales/zh-CN.yml +18 -20
  115. data/config/locales/zh-TW.yml +8 -22
  116. data/db/migrate/20171212103803_create_unique_nicknames.rb +1 -1
  117. data/db/migrate/20180221101934_fix_nickname_index.rb +1 -1
  118. data/db/migrate/20180706104107_add_nickname_to_managed_users.rb +1 -1
  119. data/db/migrate/20181001124950_move_users_groups_to_users_table.rb +1 -1
  120. data/db/migrate/20190412131728_fix_user_names.rb +1 -1
  121. data/lib/decidim/asset_router/storage.rb +7 -2
  122. data/lib/decidim/attributes/time_with_zone.rb +5 -1
  123. data/lib/decidim/content_parsers/blob_parser.rb +10 -8
  124. data/lib/decidim/content_parsers/user_parser.rb +1 -1
  125. data/lib/decidim/core/test/shared_examples/reports_examples.rb +48 -6
  126. data/lib/decidim/core/test/shared_examples/social_share_examples.rb +32 -0
  127. data/lib/decidim/core/test/shared_examples/uncommentable_component_examples.rb +26 -0
  128. data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +26 -0
  129. data/lib/decidim/core/version.rb +1 -1
  130. data/lib/decidim/map/provider/dynamic_map/here.rb +1 -40
  131. data/lib/decidim/map/provider/static_map/here.rb +34 -0
  132. data/lib/decidim/moderation_tools.rb +16 -2
  133. data/lib/decidim/nicknamizable.rb +6 -9
  134. data/lib/decidim/reportable.rb +6 -2
  135. data/lib/decidim/translatable_attributes.rb +5 -1
  136. data/lib/tasks/upgrade/clean_hidden_resources.rake +33 -0
  137. data/lib/tasks/upgrade/decidim_fix_nickname_uniqueness.rake +23 -20
  138. metadata +17 -15
  139. data/app/cells/decidim/author/flag.erb +0 -6
  140. data/app/cells/decidim/author/flag_user.erb +0 -14
  141. data/app/cells/decidim/flag_modal/flag_user.erb +0 -34
  142. data/app/cells/decidim/flag_modal/show.erb +0 -52
  143. data/app/cells/decidim/flag_modal_cell.rb +0 -56
  144. data/app/cells/decidim/profile_sidebar/show.erb +0 -167
  145. data/app/cells/decidim/profile_sidebar_cell.rb +0 -68
  146. data/app/packs/src/decidim/vendor/leaflet-tilelayer-here.js +0 -212
  147. data/app/views/decidim/reported_mailer/hide.html.erb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83ba22655575833dce2ce20e91060aa195abccf10cd5d185dbadbc04e79fcd93
4
- data.tar.gz: a53c89d6b0c01046408b2872119406ffbd1a80a50b943256b872c8575b069e4a
3
+ metadata.gz: c870efc9a61fb35a4d203542d3c151236fa734857034cd0218962c0d8a5889a2
4
+ data.tar.gz: 870b0671cef65194a32e2fc33e430b92bab41f347c8b1068fe954dcc8e5b2990
5
5
  SHA512:
6
- metadata.gz: 07db0787cc696b27044eb8765477b338a16f7263cd29d9231dfd8e7145f5c4b63b19753a90b4d35c5e7614c1a69d47104435fcb2ecf12badea9a1163709ccbef
7
- data.tar.gz: 034e07f956b0ad613172afdd3a56cbb3e37e273555537919073bf75b63dfe8b2ab7ec5502ecf87fb224cd5d525ad009a01e0db6742815ce61eec643c0fa1f1ae
6
+ metadata.gz: 3370c446ba0ebc647b221e031500993fd56719e96908a38832d62497103893295a46a33da7eadb42f110f119a4f4abf634cfd8c5a8ae707009c9a186ca31352b
7
+ data.tar.gz: babce000ab8d7cd3fa51f6c8f81a2e5d6791817dda5e3336369af31316d8d7ba061e85cb38fd5f97885100b74f06f61e05b109d91fc9d1b67c2f49dc77e96c34
@@ -4,13 +4,13 @@
4
4
  <%= icon "map-pin-line" %>
5
5
  <div class="address">
6
6
  <% if has_location? %>
7
- <div class="address__location"><%= location %></div>
7
+ <p class="address__location"><%= location %></p>
8
8
  <% end %>
9
9
 
10
- <div class="address__address"><%= address %></div>
10
+ <p class="address__address"><%= address %></p>
11
11
 
12
12
  <% if has_location_hints? %>
13
- <div class="address__hints"><%= location_hints %></div>
13
+ <p class="address__hints"><%= location_hints %></p>
14
14
  <% end %>
15
15
  </div>
16
16
  </div>
@@ -1,7 +1,5 @@
1
- <%# If the options hash has the demo key it means we are in the decidim-design engine, so it is not a real-world scenario with actual users %>
2
- <% tooltip = options.has_key?(:demo) ? { tooltip: render(:profile_minicard).html_safe } : nil %>
3
- <%= content_tag(:span, class: :author, data: ) do %>
4
- <%= content_tag :span, class: "author__container#{" is-compact" if layout == :compact}", data: tooltip do %>
1
+ <%= content_tag(:p, class: :author, data: ) do %>
2
+ <%= content_tag :span, class: "author__container#{" is-compact" if layout == :compact}" do %>
5
3
  <% if layout == :compact %>
6
4
  <%= render :avatar %>
7
5
 
@@ -2,10 +2,10 @@
2
2
  <div class="participatory-space__metadata-item">
3
3
  <div class="participatory-space__metadata-item-title">
4
4
  <%= icon item[:icon] %>
5
- <span><%= item[:title] %></span>
5
+ <h2><%= item[:title] %></h2>
6
6
  </div>
7
7
  <% if item[:text].present? %>
8
- <%= content_tag :span, item[:text] %>
8
+ <%= content_tag :p, item[:text] %>
9
9
  <% elsif item[:partial].present? %>
10
10
  <%= render item[:partial] %>
11
11
  <% end %>
@@ -1,9 +1,9 @@
1
1
  <h4 class="menu-bar__secondary-dropdown__title"><%= title %></h4>
2
- <div class="menu-bar__secondary-dropdown__metadata">
3
- <% if hashtag.present? %>
2
+ <% if hashtag.present? %>
3
+ <div class="menu-bar__secondary-dropdown__metadata">
4
4
  <span>
5
5
  <%= icon "twitter-x-line", class: "text-gray fill-current" %>
6
6
  <%= link_to "##{hashtag}", twitter_hashtag_url(hashtag), target: "_blank", class: "text-secondary underline" %>
7
7
  </span>
8
- <% end %>
9
- </div>
8
+ </div>
9
+ <% end %>
@@ -3,7 +3,9 @@
3
3
  <%= render :metadata %>
4
4
  <%= cell "decidim/content_blocks/menu_breadcrumb_last_activity", model, hide_participatory_space: true %>
5
5
  </div>
6
- <ul class="menu-bar__secondary-dropdown__menu">
7
- <%= render :links %>
8
- </ul>
6
+ <nav role="navigation" aria-label="<%= t("decidim.accessibility.secondary_menu") %>">
7
+ <ul class="menu-bar__secondary-dropdown__menu">
8
+ <%= render :links %>
9
+ </ul>
10
+ </nav>
9
11
  </div>
@@ -7,6 +7,6 @@
7
7
  <%= cell("decidim/follow_button", profile_holder) %>
8
8
 
9
9
  <% if user_flaggable? && model.try(:id) != current_user.try(:id) %>
10
- <%= cell("decidim/report_button", profile_holder) %>
10
+ <%= cell("decidim/report_user_button", profile_holder) %>
11
11
  <% end %>
12
12
  </div>
@@ -1,10 +1,10 @@
1
1
  <%= decidim_modal id: modal_id, class: "flag-modal" do %>
2
2
  <div data-dialog-container>
3
3
  <%= icon "flag-line" %>
4
- <h2 id="dialog-title-flagModal" tabindex="-1" data-dialog-title><%= t("decidim.shared.flag_modal.title") %></h2>
4
+ <h2 tabindex="-1" data-dialog-title><%= t("decidim.shared.flag_modal.title") %></h2>
5
5
  <div>
6
6
  <div class="form__wrapper flag-modal__form">
7
- <p id="dialog-desc-flagModal" class="flag-modal__form-description"><%= t("decidim.shared.flag_modal.already_reported") %></p>
7
+ <p class="flag-modal__form-description"><%= t("decidim.shared.flag_modal.already_reported") %></p>
8
8
  </div>
9
9
  </div>
10
10
  </div>
@@ -2,7 +2,7 @@
2
2
  <%= form_for report_form, builder:, url: report_path, method: :post, html: { id: nil } do |f| %>
3
3
  <div data-dialog-container>
4
4
  <%= icon "flag-line" %>
5
- <h2 id="dialog-title-<%= modal_id %>" tabindex="-1" data-dialog-title><%= t("decidim.shared.flag_modal.title") %></h2>
5
+ <h2 tabindex="-1" data-dialog-title><%= t("decidim.shared.flag_modal.title") %></h2>
6
6
  <div>
7
7
  <div class="form__wrapper flag-modal__form">
8
8
  <p id="dialog-desc-<%= modal_id %>" class="flag-modal__form-description"><%= t("decidim.shared.flag_modal.description") %></p>
@@ -18,32 +18,18 @@
18
18
  <%= f.text_area :details, rows: 4, label_options: { class: "flag-modal__form-textarea-label", for: nil }, id: nil %>
19
19
 
20
20
  <% if frontend_administrable? %>
21
- <% if user_reportable? %>
22
- <% if current_user&.admin? %>
23
- <%= f.check_box :block,
24
- label: t("decidim.shared.flag_user_modal.block"),
25
- include_hidden: false,
26
- data: {
27
- label_action: t("decidim.shared.flag_user_modal.block"),
28
- label_report: t("decidim.shared.flag_user_modal.report"),
29
- block: "true"
30
- } %>
31
- <%= f.check_box :hide, label: t("decidim.shared.flag_user_modal.hide"), label_options: { class: :invisible, id: "block_and_hide" } %>
32
- <% end %>
33
- <% else %>
34
- <%= f.check_box :hide,
35
- label: t("decidim.shared.flag_modal.hide_content"),
36
- include_hidden: false,
37
- id: hide_checkbox_id,
38
- data: {
39
- label_action: t("decidim.shared.flag_modal.hide"),
40
- label_report: t("decidim.shared.flag_modal.report"),
41
- hide: "true"
42
- },
43
- label_options: {
44
- for: hide_checkbox_id
45
- } %>
46
- <% end %>
21
+ <%= f.check_box :hide,
22
+ label: t("decidim.shared.flag_modal.hide_content"),
23
+ include_hidden: false,
24
+ id: hide_checkbox_id,
25
+ data: {
26
+ label_action: t("decidim.shared.flag_modal.hide"),
27
+ label_report: t("decidim.shared.flag_modal.report"),
28
+ hide: "true"
29
+ },
30
+ label_options: {
31
+ for: hide_checkbox_id
32
+ } %>
47
33
  <% end %>
48
34
 
49
35
  </div>
@@ -11,8 +11,6 @@ module Decidim
11
11
  end
12
12
 
13
13
  def frontend_administrable?
14
- return true if user_reportable? && current_user&.admin?
15
-
16
14
  user_entity? &&
17
15
  model.can_be_administered_by?(current_user) &&
18
16
  (model.respond_to?(:official?) && !model.official?)
@@ -47,16 +45,12 @@ module Decidim
47
45
  options[:modal_id] || "flagModal"
48
46
  end
49
47
 
50
- def user_reportable?
51
- model.is_a?(Decidim::UserReportable)
52
- end
53
-
54
48
  def report_form
55
- @report_form ||= user_reportable? ? Decidim::ReportForm.from_params(reason: "spam") : Decidim::ReportForm.new(reason: "spam")
49
+ @report_form ||= Decidim::ReportForm.new(reason: "spam")
56
50
  end
57
51
 
58
52
  def report_path
59
- @report_path ||= user_reportable? ? decidim.report_user_path(sgid: model.to_sgid.to_s) : decidim.report_path(sgid: model.to_sgid.to_s)
53
+ @report_path ||= decidim.report_path(sgid: model.to_sgid.to_s)
60
54
  end
61
55
 
62
56
  def builder
@@ -0,0 +1,11 @@
1
+ <%= decidim_modal id: modal_id, class: "flag-user-modal" do %>
2
+ <div data-dialog-container>
3
+ <%= icon "flag-line" %>
4
+ <h2 tabindex="-1" data-dialog-title><%= t("decidim.shared.flag_user_modal.title") %></h2>
5
+ <div>
6
+ <div class="form__wrapper flag-modal__form">
7
+ <p class="flag-modal__form-description"><%= t("decidim.shared.flag_user_modal.already_reported") %></p>
8
+ </div>
9
+ </div>
10
+ </div>
11
+ <% end %>
@@ -0,0 +1,46 @@
1
+ <%= decidim_modal id: modal_id, class: "flag-user-modal" do %>
2
+ <%= form_for report_form, builder:, url: report_path, method: :post, html: { id: nil } do |f| %>
3
+ <div data-dialog-container>
4
+ <%= icon "flag-line" %>
5
+ <h2 tabindex="-1" data-dialog-title><%= t("decidim.shared.flag_user_modal.title") %></h2>
6
+ <div>
7
+ <div class="form__wrapper flag-modal__form">
8
+ <p class="flag-modal__form-description"><%= t("decidim.shared.flag_user_modal.description") %></p>
9
+ <p class="flag-modal__form-reason"><%= t("decidim.shared.flag_modal.reason") %>:</p>
10
+ <%= f.collection_radio_buttons :reason, [
11
+ [:spam, t("decidim.shared.flag_user_modal.spam")],
12
+ [:offensive, t("decidim.shared.flag_user_modal.offensive")],
13
+ [:does_not_belong, t("decidim.shared.flag_user_modal.does_not_belong", organization_name: current_organization_name)]
14
+ ], :first, :last do |builder|
15
+ builder.label(for: nil, class: "form__wrapper-checkbox-label") { builder.radio_button(id: nil) + builder.text }
16
+ end %>
17
+
18
+ <%= f.text_area :details, rows: 4, label_options: { class: "flag-modal__form-textarea-label", for: nil }, id: nil %>
19
+
20
+ <% if frontend_administrable? %>
21
+ <%= f.check_box :block,
22
+ label: t("decidim.shared.flag_user_modal.block"),
23
+ include_hidden: false,
24
+ data: {
25
+ label_action: t("decidim.shared.flag_user_modal.block"),
26
+ label_report: t("decidim.shared.flag_user_modal.report"),
27
+ block: "true"
28
+ } %>
29
+ <%= f.check_box :hide, label: t("decidim.shared.flag_user_modal.hide"), label_options: { class: :invisible, id: "block_and_hide" } %>
30
+ <% end %>
31
+ </div>
32
+ </div>
33
+ </div>
34
+
35
+ <div data-dialog-actions>
36
+ <button type="button" class="button button__lg button__transparent-secondary" data-dialog-close="<%= modal_id %>">
37
+ <%= t("decidim.shared.confirm_modal.cancel") %>
38
+ </button>
39
+
40
+ <button type="submit" class="button button__lg button__secondary">
41
+ <span><%= t("decidim.shared.flag_modal.report") %></span>
42
+ <%= icon "arrow-right-line", class: "fill-current" %>
43
+ </button>
44
+ </div>
45
+ <% end %>
46
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <%= render :button %>
2
+ <%= flag_modal unless only_button? %>
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ class ReportUserButtonCell < ButtonCell
5
+ include ActionView::Helpers::FormOptionsHelper
6
+
7
+ def flag_modal
8
+ return render :already_reported_modal if model.reported_by?(current_user)
9
+
10
+ render
11
+ end
12
+
13
+ private
14
+
15
+ def report_form
16
+ @report_form ||= Decidim::ReportForm.from_params(reason: "spam")
17
+ end
18
+
19
+ def report_path
20
+ @report_path ||= decidim.report_user_path(sgid: model.to_sgid.to_s)
21
+ end
22
+
23
+ def user_reportable?
24
+ model.is_a?(Decidim::UserReportable)
25
+ end
26
+
27
+ def frontend_administrable?
28
+ current_user&.admin?
29
+ end
30
+
31
+ def builder
32
+ Decidim::FormBuilder
33
+ end
34
+
35
+ def only_button?
36
+ options[:only_button]
37
+ end
38
+
39
+ def modal_id
40
+ options[:modal_id] || "flagUserModal"
41
+ end
42
+
43
+ def button_classes
44
+ options[:button_classes] || "button button__sm button__text button__text-secondary"
45
+ end
46
+
47
+ def text
48
+ t("decidim.shared.flag_modal.report")
49
+ end
50
+
51
+ def icon_name
52
+ "flag-line"
53
+ end
54
+
55
+ def html_options
56
+ { data: { "dialog-open": current_user ? modal_id : "loginModal" } }
57
+ end
58
+ end
59
+ end
@@ -11,7 +11,7 @@
11
11
  <ul id="dropdown-menu-resource">
12
12
  <% resource_types.each do |resource_type| %>
13
13
  <li role="menuitem">
14
- <%= link_to decidim.last_activities_path(filter: { with_resource_type: resource_type[0] } ), class: "filter#{" is-active" if filter_param == resource_type[0]}" do %>
14
+ <%= link_to filter_url(resource_type[0]), class: "filter#{" is-active" if filter_param == resource_type[0]}" do %>
15
15
  <span class="sr-only"><%= resource_type[1] %></span>
16
16
  <%= text_with_resource_icon(*resource_type) %>
17
17
  <% end %>
@@ -27,8 +27,12 @@ module Decidim
27
27
  options[:id] || "filters"
28
28
  end
29
29
 
30
- def form_path
31
- options[:form_path]
30
+ def filter_url(resource_type)
31
+ if options[:source] == :last_activities
32
+ last_activities_path(filter: { with_resource_type: resource_type })
33
+ else
34
+ profile_activity_path(nickname: params[:nickname], filter: { resource_type: })
35
+ end
32
36
  end
33
37
 
34
38
  def filter_param_key
@@ -39,10 +43,6 @@ module Decidim
39
43
  @filter_param ||= params.dig(:filter, filter_param_key) || all_types_key
40
44
  end
41
45
 
42
- def filter
43
- options[:filter]
44
- end
45
-
46
46
  def all_resource_types_option
47
47
  [all_types_key, I18n.t("all", scope: "decidim.last_activities")]
48
48
  end
@@ -1,5 +1,5 @@
1
1
  <div class="profile__activity">
2
- <%= cell "decidim/resource_types_filter", resource_types, form_path: url_for, filter: %>
2
+ <%= cell "decidim/resource_types_filter", resource_types, source: :profile_activity %>
3
3
  <div class="profile__activity__container" id="activities-container">
4
4
  <% if activities.length == 0 %>
5
5
  <%= cell "decidim/announcement", t("decidim.user_activity.index.no_activities_warning") %>
@@ -45,6 +45,8 @@ module Decidim
45
45
 
46
46
  attr_reader :form, :verified_email
47
47
 
48
+ REGEXP_SANITIZER = /[<>?%&\^*#@()\[\]=+:;"{}\\|]/
49
+
48
50
  def create_or_find_user
49
51
  @user = User.find_or_initialize_by(
50
52
  email: verified_email,
@@ -63,16 +65,11 @@ module Decidim
63
65
  @user.save!
64
66
  else
65
67
  @user.email = (verified_email || form.email)
66
- @user.name = form.name
68
+ @user.name = form.name.gsub(REGEXP_SANITIZER, "")
67
69
  @user.nickname = form.normalized_nickname
68
70
  @user.newsletter_notifications_at = nil
69
71
  @user.password = SecureRandom.hex
70
- if form.avatar_url.present?
71
- url = URI.parse(form.avatar_url)
72
- filename = File.basename(url.path)
73
- file = url.open
74
- @user.avatar.attach(io: file, filename:)
75
- end
72
+ attach_avatar(form.avatar_url) if form.avatar_url.present?
76
73
  @user.skip_confirmation! if verified_email
77
74
  @user.tos_agreement = "1"
78
75
  @user.save!
@@ -81,6 +78,15 @@ module Decidim
81
78
  end
82
79
  end
83
80
 
81
+ def attach_avatar(avatar_url)
82
+ url = URI.parse(avatar_url)
83
+ filename = File.basename(url.path)
84
+ file = url.open
85
+ @user.avatar.attach(io: file, filename:)
86
+ rescue OpenURI::HTTPError, Errno::ECONNREFUSED
87
+ # Do not attach the avatar, as it fails to fetch it.
88
+ end
89
+
84
90
  def create_identity
85
91
  @user.identities.create!(
86
92
  provider: form.provider,
@@ -126,7 +132,7 @@ module Decidim
126
132
  provider: form.provider,
127
133
  uid: form.uid,
128
134
  email: form.email,
129
- name: form.name,
135
+ name: form.name.gsub(REGEXP_SANITIZER, ""),
130
136
  nickname: form.normalized_nickname,
131
137
  avatar_url: form.avatar_url,
132
138
  raw_data: form.raw_data
@@ -34,7 +34,7 @@ module Decidim
34
34
  send_report_notification_to_moderators
35
35
 
36
36
  if hideable?
37
- hide!
37
+ @tool.hide!
38
38
  send_hide_notification_to_moderators
39
39
  end
40
40
 
@@ -72,16 +72,15 @@ module Decidim
72
72
  hidden_by_admin? || (!@reportable.hidden? && moderation.report_count >= Decidim.max_reports_before_hiding)
73
73
  end
74
74
 
75
- def hide!
76
- @tool.hide!
77
- @tool.send_notification_to_author
78
- end
79
-
80
75
  def send_hide_notification_to_moderators
81
76
  participatory_space_moderators.each do |moderator|
82
77
  next unless moderator.email_on_moderations
83
78
 
84
- ReportedMailer.hide(moderator, @report).deliver_later
79
+ if hidden_by_admin?
80
+ ReportedMailer.hidden_manually(moderator, @report, current_user).deliver_later
81
+ else
82
+ ReportedMailer.hidden_automatically(moderator, @report).deliver_later
83
+ end
85
84
  end
86
85
  end
87
86
 
@@ -41,7 +41,7 @@ module Decidim
41
41
  @user = Decidim::User.new(
42
42
  name: form.name,
43
43
  email: form.email.downcase,
44
- nickname: UserBaseEntity.nicknamize(form.name, organization: form.organization),
44
+ nickname: UserBaseEntity.nicknamize(form.name, form.organization.id),
45
45
  organization: form.organization,
46
46
  admin: form.role == "admin",
47
47
  roles: form.role == "admin" ? [] : [form.role].compact
@@ -37,6 +37,12 @@ module Decidim
37
37
  klass.order_by_id_list(result_ids.take(HIGHLIGHTED_RESULTS_COUNT))
38
38
  end
39
39
 
40
+ uncommentable_resources = uncommentable_resources(results) if results.present?
41
+ if uncommentable_resources.present?
42
+ results -= uncommentable_resources
43
+ results_count -= uncommentable_resources.count
44
+ end
45
+
40
46
  results_by_type.update(class_name => {
41
47
  count: results_count,
42
48
  results:
@@ -89,5 +95,13 @@ module Decidim
89
95
  query = query.global_search(I18n.transliterate(term)) if term.present?
90
96
  query
91
97
  end
98
+
99
+ def uncommentable_resources(results)
100
+ results.where(id: results.select { |obj| related_uncommentable_resources?(obj) }.map(&:id))
101
+ end
102
+
103
+ def related_uncommentable_resources?(object)
104
+ object.respond_to?(:commentable) && !object.commentable.commentable?
105
+ end
92
106
  end
93
107
  end
@@ -9,6 +9,7 @@ module Decidim
9
9
 
10
10
  included do
11
11
  include Decidim::NeedsOrganization
12
+ include Decidim::UserRoleChecker
12
13
 
13
14
  helper ParticipatorySpaceHelpers, IconHelper, ContextualHelpHelper
14
15
  helper_method :current_participatory_space
@@ -81,8 +82,10 @@ module Decidim
81
82
  return true unless current_participatory_space.try(:private_space?) &&
82
83
  !current_participatory_space.try(:is_transparent?)
83
84
  return false unless current_user
85
+ return true if current_user.admin?
86
+ return true if user_has_any_role?(current_user, current_participatory_space, broad_check: true)
84
87
 
85
- current_user.admin || current_participatory_space.users.include?(current_user)
88
+ current_participatory_space.users.include?(current_user)
86
89
  end
87
90
 
88
91
  def help_section
@@ -24,7 +24,7 @@ module Decidim
24
24
  def show
25
25
  return redirect_to profile_members_path if profile_holder.is_a?(Decidim::UserGroup)
26
26
 
27
- redirect_to profile_activity_path(nickname: params[:nickname])
27
+ redirect_to profile_activity_path(nickname: params[:nickname].downcase)
28
28
  end
29
29
 
30
30
  def tooltip
@@ -116,7 +116,7 @@ module Decidim
116
116
  def profile_holder
117
117
  return if params[:nickname].blank?
118
118
 
119
- @profile_holder ||= Decidim::UserBaseEntity.find_by("LOWER(nickname) = ? AND decidim_organization_id = ?", params[:nickname].downcase, current_organization.id)
119
+ @profile_holder ||= Decidim::UserBaseEntity.find_by("nickname = ? AND decidim_organization_id = ?", params[:nickname].downcase, current_organization.id)
120
120
  end
121
121
  end
122
122
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  # Exposes the report resource so users can report a reportable.
5
+ # Unless the reportable is marked as hideable, the resource notice will change accordingly.
5
6
  class ReportsController < Decidim::ApplicationController
6
7
  include FormFactory
7
8
  include NeedsPermission
@@ -15,8 +16,12 @@ module Decidim
15
16
 
16
17
  CreateReport.call(@form, reportable) do
17
18
  on(:ok) do
18
- flash[:notice] = I18n.t("decidim.reports.create.success")
19
- redirect_back fallback_location: root_path
19
+ flash[:notice] = if hideable?
20
+ I18n.t("decidim.reports.hide.success")
21
+ else
22
+ I18n.t("decidim.reports.create.success")
23
+ end
24
+ redirect_to reportable.reload.reported_content_url
20
25
  end
21
26
 
22
27
  on(:invalid) do
@@ -22,7 +22,7 @@ module Decidim
22
22
  def user
23
23
  return unless params[:nickname]
24
24
 
25
- @user ||= current_organization.users.find_by("LOWER(nickname) = ?", params[:nickname].downcase)
25
+ @user ||= current_organization.users.find_by("nickname = ?", params[:nickname].downcase)
26
26
  end
27
27
 
28
28
  def activities
@@ -21,7 +21,10 @@ module Decidim
21
21
 
22
22
  validates :name, presence: true, format: { with: Decidim::User::REGEXP_NAME }
23
23
  validates :email, presence: true, "valid_email_2/email": { disposable: true }
24
- validates :nickname, presence: true, format: { with: Decidim::User::REGEXP_NICKNAME }
24
+ validates :nickname,
25
+ presence: true,
26
+ format: { with: Decidim::User::REGEXP_NICKNAME, message: :format },
27
+ length: { maximum: Decidim::User.nickname_max_length }
25
28
 
26
29
  validates :nickname, length: { maximum: Decidim::User.nickname_max_length, allow_blank: true }
27
30
  validates :password, password: { name: :name, email: :email, username: :nickname }, if: -> { password.present? }
@@ -66,7 +69,7 @@ module Decidim
66
69
 
67
70
  def unique_nickname
68
71
  return true if Decidim::UserBaseEntity.where(
69
- "decidim_organization_id = ? AND LOWER(nickname) = ? ",
72
+ "decidim_organization_id = ? AND nickname = ? ",
70
73
  context.current_organization.id,
71
74
  nickname.downcase
72
75
  ).where.not(id: context.current_user.id).empty?
@@ -25,7 +25,7 @@ module Decidim
25
25
  end
26
26
 
27
27
  def normalized_nickname
28
- UserBaseEntity.nicknamize(nickname || name, organization: current_organization)
28
+ UserBaseEntity.nicknamize(nickname || name, current_organization.id)
29
29
  end
30
30
  end
31
31
  end
@@ -37,7 +37,7 @@ module Decidim
37
37
  end
38
38
 
39
39
  def generate_nickname(name, organization)
40
- Decidim::UserBaseEntity.nicknamize(name, organization:)
40
+ Decidim::UserBaseEntity.nicknamize(name, organization.id)
41
41
  end
42
42
 
43
43
  def valid_users
@@ -39,7 +39,7 @@ module Decidim
39
39
  @breadcrumb_root_menu ||= ::Decidim::BreadcrumbRootMenuPresenter.new(
40
40
  :menu,
41
41
  self,
42
- container_options: { class: "menu-bar__main-dropdown__menu" }
42
+ container_options: { class: "menu-bar__dropdown-menu" }
43
43
  )
44
44
  end
45
45
 
@@ -47,7 +47,7 @@ module Decidim
47
47
  @mobile_breadcrumb_root_menu ||= ::Decidim::BreadcrumbRootMenuPresenter.new(
48
48
  :mobile_menu,
49
49
  self,
50
- container_options: { class: "menu-bar__main-dropdown__menu" }
50
+ container_options: { class: "menu-bar__main-dropdown__top-menu" }
51
51
  )
52
52
  end
53
53
 
@@ -13,7 +13,8 @@ module Decidim
13
13
  def order_selector(orders, options = {})
14
14
  render partial: "decidim/shared/orders", locals: {
15
15
  orders:,
16
- i18n_scope: options[:i18n_scope]
16
+ i18n_scope: options[:i18n_scope],
17
+ css_class: options[:css_class]
17
18
  }
18
19
  end
19
20
 
@@ -13,7 +13,7 @@ module Decidim
13
13
 
14
14
  per_page = (params[:per_page] || paginate_params[:per_page] || Decidim::Paginable::OPTIONS.first).to_i
15
15
 
16
- content_tag :div, class: "flex flex-col-reverse md:flex-row items-center justify-between gap-1 py-8 md:py-16", data: { pagination: "" } do
16
+ content_tag :div, class: "flex flex-col-reverse md:flex-row items-center justify-between gap-1 py-8 md:py-16 md:flex-wrap", data: { pagination: "" } do
17
17
  template = ""
18
18
  template += render(partial: "decidim/shared/results_per_page", locals: { per_page: }, formats: [:html]) if collection.total_pages.positive?
19
19
  template += paginate collection, window: 2, outer_window: 1, theme: "decidim", params: paginate_params
@@ -28,7 +28,7 @@ module Decidim
28
28
  end
29
29
 
30
30
  def participatory_space_floating_help
31
- return if help_section.blank?
31
+ return if help_section.blank? || strip_tags(translated_attribute(help_section).html_safe).blank?
32
32
 
33
33
  floating_help(help_id) { translated_attribute(help_section).html_safe }
34
34
  end