decidim-core 0.27.3 → 0.27.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/activities_cell.rb +1 -7
  3. data/app/cells/decidim/collapsible_list/show.erb +1 -1
  4. data/app/cells/decidim/content_blocks/last_activity_cell.rb +1 -4
  5. data/app/cells/decidim/tags_cell.rb +13 -2
  6. data/app/cells/decidim/upload_modal/modal.erb +4 -1
  7. data/app/cells/decidim/upload_modal_cell.rb +8 -4
  8. data/app/cells/decidim/version_cell.rb +1 -1
  9. data/app/cells/decidim/versions_list_cell.rb +1 -1
  10. data/app/commands/decidim/create_omniauth_registration.rb +2 -2
  11. data/app/commands/decidim/endorse_resource.rb +2 -0
  12. data/app/commands/decidim/search.rb +1 -1
  13. data/app/commands/decidim/unendorse_resource.rb +1 -1
  14. data/app/controllers/concerns/decidim/force_authentication.rb +6 -2
  15. data/app/controllers/decidim/authorization_modals_controller.rb +1 -1
  16. data/app/controllers/decidim/devise/registrations_controller.rb +1 -1
  17. data/app/controllers/decidim/last_activities_controller.rb +1 -7
  18. data/app/controllers/decidim/links_controller.rb +1 -1
  19. data/app/controllers/decidim/searches_controller.rb +1 -1
  20. data/app/controllers/decidim/short_links_controller.rb +1 -1
  21. data/app/controllers/decidim/user_timeline_controller.rb +1 -1
  22. data/app/forms/decidim/account_form.rb +1 -1
  23. data/app/forms/decidim/notifications_settings_form.rb +1 -9
  24. data/app/forms/decidim/registration_form.rb +1 -1
  25. data/app/forms/url_validator.rb +1 -1
  26. data/app/helpers/decidim/decidim_form_helper.rb +1 -0
  27. data/app/helpers/decidim/layout_helper.rb +4 -1
  28. data/app/helpers/decidim/omniauth_helper.rb +2 -0
  29. data/app/helpers/decidim/resource_helper.rb +2 -0
  30. data/app/helpers/decidim/short_link_helper.rb +1 -1
  31. data/app/jobs/decidim/download_your_data_export_job.rb +2 -1
  32. data/app/jobs/decidim/open_data_job.rb +2 -0
  33. data/app/models/decidim/organization.rb +6 -0
  34. data/app/models/decidim/user.rb +13 -3
  35. data/app/packs/images/decidim/icons.svg +1 -1
  36. data/app/packs/images/decidim/vendor/social-share-button/x.svg +6 -0
  37. data/app/packs/src/decidim/autocomplete.js +11 -2
  38. data/app/packs/src/decidim/data_picker.js +1 -0
  39. data/app/packs/src/decidim/direct_uploads/upload_field.js +6 -4
  40. data/app/packs/src/decidim/direct_uploads/upload_modal.js +10 -8
  41. data/app/packs/src/decidim/direct_uploads/uploader.js +4 -1
  42. data/app/packs/src/decidim/geocoding/attach_input.js +4 -1
  43. data/app/packs/src/decidim/geocoding/provider/here.js +17 -21
  44. data/app/packs/src/decidim/geocoding/provider/photon.js +1 -1
  45. data/app/packs/src/decidim/input_character_counter.js +1 -1
  46. data/app/packs/src/decidim/map/controller/drag_marker.js +0 -2
  47. data/app/packs/src/decidim/map/controller/markers.js +0 -1
  48. data/app/packs/src/decidim/map/controller/static.js +0 -1
  49. data/app/packs/src/decidim/map/controller.js +0 -2
  50. data/app/packs/src/decidim/map/factory.js +4 -1
  51. data/app/packs/src/decidim/map/icon.js +0 -1
  52. data/app/packs/src/decidim/map/legacy.js +0 -1
  53. data/app/packs/src/decidim/map/provider/default.js +2 -0
  54. data/app/packs/src/decidim/map/provider/here.js +2 -1
  55. data/app/packs/src/decidim/utilities/text.js +17 -0
  56. data/app/packs/stylesheets/decidim/_variables.scss +1 -1
  57. data/app/packs/stylesheets/decidim/vendor/_social_share_button.scss +4 -0
  58. data/app/queries/decidim/last_activity.rb +96 -0
  59. data/app/queries/decidim/metrics/users_metric_manage.rb +6 -6
  60. data/app/queries/decidim/public_activities.rb +5 -57
  61. data/app/services/decidim/email_notification_generator.rb +7 -1
  62. data/app/services/decidim/send_push_notification.rb +1 -1
  63. data/app/uploaders/decidim/application_uploader.rb +2 -0
  64. data/app/views/decidim/notifications_settings/show.html.erb +1 -1
  65. data/app/views/decidim/scopes/_scopes_picker_input.html.erb +1 -1
  66. data/app/views/decidim/searches/_filters.html.erb +3 -1
  67. data/app/views/decidim/shared/_share_modal.html.erb +1 -1
  68. data/app/views/decidim/shared/participatory_space_filters/_filters.html.erb +1 -1
  69. data/app/views/layouts/decidim/_social_media_links.html.erb +2 -2
  70. data/config/environment.rb +3 -0
  71. data/config/locales/ar.yml +11 -17
  72. data/config/locales/bg.yml +8 -16
  73. data/config/locales/ca.yml +19 -14
  74. data/config/locales/cs.yml +31 -11
  75. data/config/locales/de.yml +113 -46
  76. data/config/locales/el.yml +157 -13
  77. data/config/locales/en.yml +6 -1
  78. data/config/locales/eo.yml +5 -3
  79. data/config/locales/es-MX.yml +16 -11
  80. data/config/locales/es-PY.yml +18 -13
  81. data/config/locales/es.yml +17 -12
  82. data/config/locales/eu.yml +494 -345
  83. data/config/locales/fi-plain.yml +29 -3
  84. data/config/locales/fi.yml +19 -14
  85. data/config/locales/fr-CA.yml +16 -11
  86. data/config/locales/fr.yml +17 -12
  87. data/config/locales/ga-IE.yml +9 -5
  88. data/config/locales/gl.yml +10 -20
  89. data/config/locales/hu.yml +46 -18
  90. data/config/locales/id-ID.yml +12 -19
  91. data/config/locales/is-IS.yml +7 -3
  92. data/config/locales/it.yml +14 -10
  93. data/config/locales/ja.yml +39 -21
  94. data/config/locales/kaa.yml +10 -0
  95. data/config/locales/lb.yml +16 -12
  96. data/config/locales/lt.yml +57 -9
  97. data/config/locales/lv.yml +8 -16
  98. data/config/locales/nl.yml +8 -8
  99. data/config/locales/no.yml +15 -11
  100. data/config/locales/pl.yml +24 -6
  101. data/config/locales/pt-BR.yml +164 -7
  102. data/config/locales/pt.yml +12 -8
  103. data/config/locales/ro-RO.yml +8 -7
  104. data/config/locales/ru.yml +6 -17
  105. data/config/locales/sk.yml +21 -19
  106. data/config/locales/sl.yml +0 -5
  107. data/config/locales/sq-AL.yml +1 -0
  108. data/config/locales/sr-CS.yml +8 -0
  109. data/config/locales/sv.yml +34 -16
  110. data/config/locales/th-TH.yml +1 -0
  111. data/config/locales/tr-TR.yml +21 -12
  112. data/config/locales/uk.yml +5 -14
  113. data/config/locales/zh-CN.yml +10 -7
  114. data/config/locales/zh-TW.yml +17 -9
  115. data/db/migrate/20181030090144_destroy_deleted_users_follows.rb +1 -1
  116. data/db/migrate/20181204110723_remove_following_users_count_from_users.rb +11 -2
  117. data/db/migrate/20181214101250_add_notification_types_to_users.rb +6 -1
  118. data/db/migrate/20190412131728_fix_user_names.rb +9 -2
  119. data/db/migrate/20200211173227_add_direct_message_types_to_users.rb +6 -1
  120. data/db/migrate/20210302150803_invalidate_all_sessions_for_deleted_users.rb +10 -3
  121. data/db/migrate/20210310120640_add_followable_counter_cache_to_users.rb +13 -3
  122. data/db/migrate/20231027142329_change_default_value_for_decidim_endorsements.rb +11 -0
  123. data/db/seeds.rb +5 -3
  124. data/lib/decidim/core/test/factories.rb +2 -1
  125. data/lib/decidim/core/test/shared_examples/comments_examples.rb +24 -0
  126. data/lib/decidim/core/test/shared_examples/errors.rb +2 -0
  127. data/lib/decidim/core/test/shared_examples/map_examples.rb +4 -1
  128. data/lib/decidim/core/version.rb +1 -1
  129. data/lib/decidim/core.rb +18 -1
  130. data/lib/decidim/endorsable.rb +1 -1
  131. data/lib/decidim/exporters.rb +10 -1
  132. data/lib/decidim/form_builder.rb +7 -13
  133. data/lib/decidim/has_category.rb +2 -2
  134. data/lib/tasks/upgrade/decidim_deduplicate_endorsements.rake +53 -0
  135. data/lib/tasks/upgrade/decidim_fix_short_url_resolver.rake +22 -0
  136. data/lib/tasks/upgrade/decidim_user_moderation.rake +14 -0
  137. metadata +22 -12
@@ -171,8 +171,6 @@ uk:
171
171
  invalid_field: "Для поля %{field} значення %{value} неприпустиме."
172
172
  ok: Гаразд
173
173
  title: Недостатньо прав через відсутність підтвердження особи
174
- show:
175
- close_modal: Закрити віконце
176
174
  collapsible_list:
177
175
  see_less: "(читати менше)"
178
176
  see_more: "(читати далі)"
@@ -223,7 +221,6 @@ uk:
223
221
  already_have_an_account?: Вже маєте обліковий запис?
224
222
  newsletter: Отримувати іноді розсилання зі свіжими новинами
225
223
  newsletter_title: Дозвіл на зв'язок
226
- sign_in: Увійти
227
224
  sign_up: Зареєструватися
228
225
  sign_up_as:
229
226
  legend: Зареєструватися як
@@ -240,7 +237,6 @@ uk:
240
237
  newsletter_modal:
241
238
  buttons:
242
239
  check: Поставити галочку та продовжити
243
- close_modal: Закрити віконце
244
240
  notice: |-
245
241
  <p>Привіт, ви впевнені, що не хочете отримувати розсилання новин?<br> Будь ласка, ще раз розгляньте можливість поставити нижче галочку щодо розсилання.<br> Для нас дуже важливо, щоб ви могли іноді отримувати електронні листи з важливими оголошеннями. Ви завжди можете змінити це на сторінці налаштувань сповіщень.</p> <p>Якщо ви не поставите цю галочку, ви можете прогледіти доречні відомості щодо свіжих можливостей участі в роботі майданчика.<br> Якщо ви все ж бажаєте уникнути розсилань, ми прекрасно розуміємо таке ваше рішення.</p> <p>Дякуємо, що прочитали це!</p>
246
242
  title: Сповіщення про новини
@@ -267,8 +263,6 @@ uk:
267
263
  show:
268
264
  download_data: Завантажити дані
269
265
  request_data: Подати запит на дані
270
- endorsable:
271
- endorsements: Проявів підтримки
272
266
  errors:
273
267
  internal_server_error:
274
268
  title: При з'єднанні з нашим сервером сталася помилка
@@ -341,9 +335,9 @@ uk:
341
335
  default_image: Зображення за замовчуванням
342
336
  errors:
343
337
  error: У цьому полі є помилка.
344
- links:
345
- warning:
346
- close_modal: Закрити віконце
338
+ upload:
339
+ labels:
340
+ save: Зберегти
347
341
  log:
348
342
  base_presenter:
349
343
  create: "%{user_name} створив %{resource_name}"
@@ -383,7 +377,6 @@ uk:
383
377
  create:
384
378
  error: Бесіда не розпочата. Спробуйте ще раз пізніше
385
379
  index:
386
- close: Закрити віконце
387
380
  no_conversations: У вас ще немає бесід
388
381
  reply:
389
382
  send: Надіслати
@@ -440,7 +433,6 @@ uk:
440
433
  proposals: Пропозиції
441
434
  proposals_explanation: Вносьте нові пропозиції, підтримуйте існуючі та сприяйте змінам, які ви хочете бачити.
442
435
  footer_sub_hero:
443
- footer_sub_hero_body: Створімо більш відкрите, прозоре та співпрацююче суспільство.<br /> Долучайтесь, беріть участь та приймайте рішення.
444
436
  footer_sub_hero_headline: Ласкаво просимо до майданчику співучасті %{organization}!
445
437
  register: Зареєструватися
446
438
  hero:
@@ -458,7 +450,6 @@ uk:
458
450
  legend: Погодитися з умовами участі
459
451
  refuse:
460
452
  modal_btn_exit: Я перегляну це пізніше
461
- modal_close: Закрити віконце
462
453
  modal_title: Ви дійсно відмовляєтеся від оновлених "Умов участі"?
463
454
  required_review:
464
455
  alert: Ми оновили наші "Умови участі", будь ласка, перегляньте їх.
@@ -502,10 +493,8 @@ uk:
502
493
  term_input_placeholder: Шукати
503
494
  searches:
504
495
  filters_small_view:
505
- close_modal: Закрити віконце
506
496
  filter: Відібрати
507
497
  filter_by: 'Відібрати за ознакою:'
508
- unfold: Розгорнути
509
498
  shared:
510
499
  embed_modal:
511
500
  close_window: Закрити вікно
@@ -536,6 +525,8 @@ uk:
536
525
  statistics:
537
526
  comments_count: Коментарів
538
527
  user_conversations:
528
+ index:
529
+ close: Закрити
539
530
  update:
540
531
  error: Повідомлення не надіслано. Спробуйте ще раз пізніше
541
532
  version_author:
@@ -386,7 +386,6 @@ zh-CN:
386
386
  already_have_an_account?: 已经有一个帐户?
387
387
  newsletter: 接收附带相关信息的时事通讯
388
388
  newsletter_title: 联系人权限
389
- sign_in: 登录
390
389
  sign_up: 注册
391
390
  sign_up_as:
392
391
  legend: 注册为
@@ -432,7 +431,6 @@ zh-CN:
432
431
  download_data: 下载数据
433
432
  request_data: 请求数据
434
433
  endorsable:
435
- endorsements: 授权
436
434
  endorsements_count: 批准次数
437
435
  endorsement_buttons_cell:
438
436
  already_endorsed: 已批准
@@ -635,6 +633,10 @@ zh-CN:
635
633
  file_validation:
636
634
  allowed_file_extensions: '允许的文件扩展名: %{extensions}'
637
635
  max_file_size: '最大文件大小: %{megabytes}MB'
636
+ upload:
637
+ labels:
638
+ cancel: 取消
639
+ save: 保存
638
640
  gamification:
639
641
  all_badges_link: 查看所有可用的徽章。
640
642
  badges:
@@ -959,7 +961,6 @@ zh-CN:
959
961
  proposals: 建议
960
962
  proposals_explanation: 提出建议、支持现有建议并促进你想要看到的更改。
961
963
  footer_sub_hero:
962
- footer_sub_hero_body: 让我们建设一个更加开放、透明和协作的社会。<br /> 加入、参与和决定。
963
964
  footer_sub_hero_headline: 欢迎使用 %{organization} 参与式平台。
964
965
  register: 注册
965
966
  hero:
@@ -1334,8 +1335,6 @@ zh-CN:
1334
1335
  updated: 您的帐户已成功更新。
1335
1336
  sessions:
1336
1337
  already_signed_out: 已成功注销。
1337
- new:
1338
- sign_in: 登录
1339
1338
  signed_in: 登录成功。
1340
1339
  signed_out: 已成功注销。
1341
1340
  shared:
@@ -1344,7 +1343,6 @@ zh-CN:
1344
1343
  didn_t_receive_confirmation_instructions: 没有收到确认说明?
1345
1344
  didn_t_receive_unlock_instructions: 没有收到解锁指令?
1346
1345
  forgot_your_password: 忘记密码?
1347
- sign_in: 登录
1348
1346
  sign_in_with_provider: 使用 %{provider} 登录
1349
1347
  sign_up: 注册
1350
1348
  minimum_password_length:
@@ -1385,6 +1383,10 @@ zh-CN:
1385
1383
  timestamp_error_message: 对不起,这太快了!请重新提交。
1386
1384
  layouts:
1387
1385
  decidim:
1386
+ data_consent:
1387
+ details:
1388
+ columns:
1389
+ type: 类型
1388
1390
  edit_link:
1389
1391
  edit: 编辑
1390
1392
  footer:
@@ -1410,8 +1412,9 @@ zh-CN:
1410
1412
  facebook: "%{organization} 在 Facebook"
1411
1413
  github: "%{organization} 在 GitHub"
1412
1414
  instagram: "%{organization} 在 Instagram"
1413
- twitter: "%{organization} 在 Twitter"
1414
1415
  youtube: "%{organization} 在 YouTube"
1416
+ upload_modal:
1417
+ close_modal: 关闭模式
1415
1418
  user_menu:
1416
1419
  account: '用户帐户: %{name}'
1417
1420
  admin_dashboard: 管理员控制面板
@@ -89,6 +89,20 @@ zh-TW:
89
89
  about_x_months:
90
90
  other: "one\n大約 1 月\n\nOther\n大約 %{count} 月"
91
91
  half_a_minute: 半分鐘
92
+ less_than_x_minutes:
93
+ other: 少於 %{count} 分鐘
94
+ less_than_x_seconds:
95
+ other: "< 1秒\n< %{count} 秒"
96
+ x_days:
97
+ other: "1天\n%{count} 天"
98
+ x_hours:
99
+ other: "{count} 小時"
100
+ x_minutes:
101
+ other: "%{count} 分鐘"
102
+ x_months:
103
+ other: "%{count} 個月"
104
+ x_seconds:
105
+ other: "%{count} 秒"
92
106
  decidim:
93
107
  accessibility:
94
108
  external_link: 外部鏈接
@@ -505,7 +519,6 @@ zh-TW:
505
519
  newsletter: 偶爾收到包含相關信息的時事通訊。
506
520
  newsletter_title: 聯絡人權限
507
521
  nickname_help: 在 %{organization} 中的別名。只能包含字母、數字、'-' 和 '_'。
508
- sign_in: 登入
509
522
  sign_up: 註冊登記
510
523
  sign_up_as:
511
524
  legend: 註冊登記為
@@ -1194,7 +1207,6 @@ zh-TW:
1194
1207
  proposals: 提案
1195
1208
  proposals_explanation: 提出建議、支持現有建議並推動您希望看到的變化。
1196
1209
  footer_sub_hero:
1197
- footer_sub_hero_body: 一起建立更加開放、透明和協作的社會。<br /> 加入、參與和做出決策。
1198
1210
  footer_sub_hero_headline: 歡迎來到 %{organization} 的參與平台。
1199
1211
  register: 註冊
1200
1212
  hero:
@@ -1439,8 +1451,8 @@ zh-TW:
1439
1451
  conversations_info: 對話是私密的,沒有其他人可以看到。可以與平台上註冊的任何參與者或群組開始對話。
1440
1452
  from: 來自
1441
1453
  last_message: 最後訊息
1442
- modal_title: 新對話
1443
- new_conversation: 新對話
1454
+ modal_title: 新的對話
1455
+ new_conversation: 新的對話
1444
1456
  next: 下一個
1445
1457
  no_conversations_warning: 目前還沒有任何對話。
1446
1458
  no_results: 無結果
@@ -1624,8 +1636,6 @@ zh-TW:
1624
1636
  updated: 您的帳號已成功升級。
1625
1637
  sessions:
1626
1638
  already_signed_out: 已成功登出。
1627
- new:
1628
- sign_in: 登入
1629
1639
  signed_in: 已成功登入。
1630
1640
  signed_out: 已成功登出。
1631
1641
  shared:
@@ -1634,7 +1644,6 @@ zh-TW:
1634
1644
  didn_t_receive_confirmation_instructions: 沒有收到確認的說明嗎?
1635
1645
  didn_t_receive_unlock_instructions: 沒有收到解鎖說明?
1636
1646
  forgot_your_password: 忘記密碼了嗎?
1637
- sign_in: 登入
1638
1647
  sign_in_with_provider: 用%{provider} 登錄
1639
1648
  sign_up: 註冊登記
1640
1649
  minimum_password_length:
@@ -1686,7 +1695,7 @@ zh-TW:
1686
1695
  description: 說明
1687
1696
  name: 名稱
1688
1697
  service: 服務
1689
- type: 種類
1698
+ type: 類別
1690
1699
  items:
1691
1700
  _session_id:
1692
1701
  description: 允許網站在使用者在網頁之間移動時記住使用者。
@@ -1759,7 +1768,6 @@ zh-TW:
1759
1768
  facebook: "%{organization} 在 Facebook"
1760
1769
  github: "%{organization} 在 GitHub"
1761
1770
  instagram: "%{organization} 在 Instagram"
1762
- twitter: "%{organization} 在 Twitter"
1763
1771
  youtube: "%{organization} 在 YouTube"
1764
1772
  timeout_modal:
1765
1773
  body: 您已經閒置了 %{minutes} 分鐘。如果您繼續閒置,為了您的安全,您將被自動登出。
@@ -10,7 +10,7 @@ class DestroyDeletedUsersFollows < ActiveRecord::Migration[5.2]
10
10
  end
11
11
 
12
12
  def change
13
- deleted_users = Decidim::User.where.not(deleted_at: nil).pluck(:id)
13
+ deleted_users = User.where.not(deleted_at: nil).pluck(:id)
14
14
  Follow.where(decidim_followable_type: "Decidim::UserBaseEntity", decidim_followable_id: deleted_users).destroy_all
15
15
  Follow.where(decidim_user_id: deleted_users).destroy_all
16
16
  end
@@ -1,6 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RemoveFollowingUsersCountFromUsers < ActiveRecord::Migration[5.2]
4
+ class UserBaseEntity < ApplicationRecord
5
+ self.table_name = :decidim_users
6
+ self.inheritance_column = nil # disable the default inheritance
7
+ end
8
+
9
+ class Follow < ApplicationRecord
10
+ self.table_name = :decidim_follows
11
+ end
12
+
4
13
  def up
5
14
  remove_column :decidim_users, :following_users_count
6
15
  end
@@ -8,8 +17,8 @@ class RemoveFollowingUsersCountFromUsers < ActiveRecord::Migration[5.2]
8
17
  def down
9
18
  add_column :decidim_users, :following_users_count, :integer, null: false, default: 0
10
19
 
11
- Decidim::UserBaseEntity.find_each do |entity|
12
- following_users_count = Decidim::Follow.where(decidim_user_id: entity.id, decidim_followable_type: ["Decidim::UserBaseEntity", "Decidim::User", "Decidim::UserGroup"]).count
20
+ UserBaseEntity.find_each do |entity|
21
+ following_users_count = Follow.where(decidim_user_id: entity.id, decidim_followable_type: ["Decidim::UserBaseEntity", "Decidim::User", "Decidim::UserGroup"]).count
13
22
  entity.following_users_count = following_users_count
14
23
  entity.save
15
24
  end
@@ -1,10 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class AddNotificationTypesToUsers < ActiveRecord::Migration[5.2]
4
+ class UserBaseEntity < ApplicationRecord
5
+ self.table_name = :decidim_users
6
+ self.inheritance_column = nil # disable the default inheritance
7
+ end
8
+
4
9
  def change
5
10
  add_column :decidim_users, :notification_types, :string, default: "all"
6
11
  # rubocop:disable Rails/SkipsModelValidations
7
- Decidim::UserBaseEntity.update_all(notification_types: "all")
12
+ UserBaseEntity.update_all(notification_types: "all")
8
13
  # rubocop:enable Rails/SkipsModelValidations
9
14
 
10
15
  change_column_null :decidim_users, :notification_types, false
@@ -1,6 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FixUserNames < ActiveRecord::Migration[5.2]
4
+ class UserBaseEntity < ApplicationRecord
5
+ include Decidim::Nicknamizable
6
+
7
+ self.table_name = :decidim_users
8
+ self.inheritance_column = nil # disable the default inheritance
9
+ end
10
+
4
11
  def change
5
12
  # Comes from Decidim::User specs
6
13
  weird_characters =
@@ -8,7 +15,7 @@ class FixUserNames < ActiveRecord::Migration[5.2]
8
15
  characters_to_remove = "<>?%&^*\#@()[]=+:;\"{}\\|/"
9
16
 
10
17
  weird_characters.each do |character|
11
- Decidim::UserBaseEntity.where(deleted_at: nil).where("name like '%#{character}%' escape '\' OR nickname like '%#{character}%' escape '\'").find_each do |entity|
18
+ UserBaseEntity.where(deleted_at: nil).where("name like '%#{character}%' escape '\' OR nickname like '%#{character}%' escape '\'").find_each do |entity|
12
19
  Rails.logger.debug { "detected character: #{character}" }
13
20
  Rails.logger.debug { "UserBaseEntity ID: #{entity.id}" }
14
21
  Rails.logger.debug { "#{entity.name} => #{entity.name.delete(characters_to_remove).strip}" }
@@ -16,7 +23,7 @@ class FixUserNames < ActiveRecord::Migration[5.2]
16
23
 
17
24
  entity.name = entity.name.delete(characters_to_remove).strip
18
25
  sanitized_nickname = entity.nickname.delete(characters_to_remove).strip
19
- entity.nickname = Decidim::UserBaseEntity.nicknamize(sanitized_nickname, organization: entity.organization)
26
+ entity.nickname = UserBaseEntity.nicknamize(sanitized_nickname, organization: entity.organization)
20
27
  entity.save(validate: false)
21
28
  end
22
29
  end
@@ -1,10 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class AddDirectMessageTypesToUsers < ActiveRecord::Migration[5.2]
4
+ class UserBaseEntity < ApplicationRecord
5
+ self.table_name = :decidim_users
6
+ self.inheritance_column = nil # disable the default inheritance
7
+ end
8
+
4
9
  def change
5
10
  add_column :decidim_users, :direct_message_types, :string, default: "all"
6
11
  # rubocop:disable Rails/SkipsModelValidations
7
- Decidim::UserBaseEntity.update_all(direct_message_types: "all")
12
+ UserBaseEntity.update_all(direct_message_types: "all")
8
13
  # rubocop:enable Rails/SkipsModelValidations
9
14
 
10
15
  change_column_null :decidim_users, :direct_message_types, false
@@ -1,10 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class InvalidateAllSessionsForDeletedUsers < ActiveRecord::Migration[5.2]
4
- def up
5
- Decidim::User.reset_column_information
4
+ class User < ApplicationRecord
5
+ self.table_name = "decidim_users"
6
+ self.inheritance_column = nil # disable the default inheritance
7
+
8
+ default_scope { where(type: "Decidim::User") }
9
+ end
6
10
 
7
- Decidim::User.where.not(deleted_at: nil).find_each(&:invalidate_all_sessions!)
11
+ def up
12
+ User.where.not(deleted_at: nil).find_each do |user|
13
+ user.update!(session_token: SecureRandom.hex)
14
+ end
8
15
  end
9
16
 
10
17
  def down; end
@@ -1,14 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class AddFollowableCounterCacheToUsers < ActiveRecord::Migration[5.2]
4
+ class Follow < ApplicationRecord
5
+ self.table_name = "decidim_follows"
6
+ end
7
+
8
+ class User < ApplicationRecord
9
+ self.table_name = "decidim_users"
10
+ self.inheritance_column = nil # disable the default inheritance
11
+
12
+ default_scope { where(type: "Decidim::User") }
13
+ end
14
+
4
15
  def change
5
16
  add_column :decidim_users, :follows_count, :integer, null: false, default: 0, index: true
6
17
 
7
18
  reversible do |dir|
8
19
  dir.up do
9
- Decidim::User.reset_column_information
10
- Decidim::User.find_each do |record|
11
- record.class.reset_counters(record.id, :follows)
20
+ User.find_each do |record|
21
+ record.update!(follows_count: Follow.where(decidim_user_id: record.id).count)
12
22
  end
13
23
  end
14
24
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ChangeDefaultValueForDecidimEndorsements < ActiveRecord::Migration[6.1]
4
+ def up
5
+ change_column_default :decidim_endorsements, :decidim_user_group_id, 0
6
+ end
7
+
8
+ def down
9
+ change_column_default :decidim_endorsements, :decidim_user_group_id, nil
10
+ end
11
+ end
data/db/seeds.rb CHANGED
@@ -37,6 +37,7 @@ if !Rails.env.production? || ENV.fetch("SEED", nil)
37
37
  port: ENV.fetch("SMTP_PORT", nil) || ENV.fetch("DECIDIM_SMTP_PORT", "25")
38
38
  },
39
39
  host: ENV.fetch("DECIDIM_HOST", "localhost"),
40
+ secondary_hosts: ENV.fetch("DECIDIM_HOST", "localhost") == "localhost" ? ["0.0.0.0", "127.0.0.1"] : nil,
40
41
  external_domain_whitelist: ["decidim.org", "github.com"],
41
42
  description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
42
43
  Decidim::Faker::Localized.sentence(word_count: 15)
@@ -125,7 +126,8 @@ if !Rails.env.production? || ENV.fetch("SEED", nil)
125
126
  tos_agreement: true,
126
127
  personal_url: Faker::Internet.url,
127
128
  about: Faker::Lorem.paragraph(sentence_count: 2),
128
- accepted_tos_version: organization.tos_version,
129
+ accepted_tos_version: organization.tos_version + 1.hour,
130
+ password_updated_at: Time.current,
129
131
  admin_terms_accepted_at: Time.current
130
132
  }
131
133
  admin_hash.merge!(password: "decidim123456789", password_confirmation: "decidim123456789") if admin.encrypted_password.blank?
@@ -143,7 +145,7 @@ if !Rails.env.production? || ENV.fetch("SEED", nil)
143
145
  tos_agreement: true,
144
146
  personal_url: Faker::Internet.url,
145
147
  about: Faker::Lorem.paragraph(sentence_count: 2),
146
- accepted_tos_version: organization.tos_version
148
+ accepted_tos_version: organization.tos_version + 1.hour
147
149
  )
148
150
  end
149
151
 
@@ -162,7 +164,7 @@ if !Rails.env.production? || ENV.fetch("SEED", nil)
162
164
  tos_agreement: true,
163
165
  personal_url: Faker::Internet.url,
164
166
  about: Faker::Lorem.paragraph(sentence_count: 2),
165
- accepted_tos_version: organization.tos_version
167
+ accepted_tos_version: organization.tos_version + 1.hour
166
168
  )
167
169
 
168
170
  locked_user.lock_access!
@@ -364,7 +364,8 @@ FactoryBot.define do
364
364
  published_at { Time.current }
365
365
  settings do
366
366
  {
367
- dummy_global_translatable_text: generate_localized_title
367
+ dummy_global_translatable_text: generate_localized_title,
368
+ comments_max_length: participatory_space.organization.comments_max_length || organization.comments_max_length
368
369
  }
369
370
  end
370
371
 
@@ -838,5 +838,29 @@ shared_examples "comments" do
838
838
  expect(page).to have_link "#decidim", href: "/search?term=%23decidim"
839
839
  end
840
840
  end
841
+
842
+ describe "export_serializer" do
843
+ let(:comment) { comments.first }
844
+
845
+ it "returns the serializer for the comment" do
846
+ expect(comment.class.export_serializer).to eq(Decidim::Comments::CommentSerializer)
847
+ end
848
+
849
+ context "with instance" do
850
+ subject { comment.class.export_serializer.new(comment).serialize }
851
+
852
+ it { is_expected.to have_key(:id) }
853
+ it { is_expected.to have_key(:created_at) }
854
+ it { is_expected.to have_key(:body) }
855
+ it { is_expected.to have_key(:locale) }
856
+ it { is_expected.to have_key(:author) }
857
+ it { is_expected.to have_key(:alignment) }
858
+ it { is_expected.to have_key(:depth) }
859
+ it { is_expected.to have_key(:user_group) }
860
+ it { is_expected.to have_key(:commentable_id) }
861
+ it { is_expected.to have_key(:commentable_type) }
862
+ it { is_expected.to have_key(:root_commentable_url) }
863
+ end
864
+ end
841
865
  end
842
866
  end
@@ -18,6 +18,8 @@ shared_examples_for "a 404 page" do
18
18
  expect(page).to have_content("The page you're looking for can't be found")
19
19
 
20
20
  expect(page).to have_http_status(:not_found)
21
+
22
+ expect(page).to have_current_path(target_path)
21
23
  end
22
24
  end
23
25
  end
@@ -10,7 +10,9 @@ shared_context "with map utility" do
10
10
  end
11
11
 
12
12
  shared_context "with frontend map builder" do
13
- subject { described_class.new(template, options) }
13
+ subject { builder_class.new(template, options) }
14
+
15
+ let(:builder_class) { described_class }
14
16
 
15
17
  let(:template_class) do
16
18
  Class.new(ActionView::Base) do
@@ -102,6 +104,7 @@ shared_context "with frontend map elements" do
102
104
  # context.
103
105
  final_html = html_document
104
106
  Rails.application.routes.draw do
107
+ get "maptiles/:z/:x/:y.png", to: ->(_) { [200, {}, [final_html]] }
105
108
  get "test_dynamic_map", to: ->(_) { [200, {}, [final_html]] }
106
109
  get "offline", to: ->(_) { [200, {}, [""]] }
107
110
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-core version.
5
5
  module Core
6
6
  def self.version
7
- "0.27.3"
7
+ "0.27.5"
8
8
  end
9
9
  end
10
10
  end
data/lib/decidim/core.rb CHANGED
@@ -118,6 +118,12 @@ module Decidim
118
118
  include ActiveSupport::Configurable
119
119
  # Loads seeds from all engines.
120
120
  def self.seed!
121
+ # After running the migrations, some records may have loaded their column
122
+ # caches at different stages of the migration process, so in order to
123
+ # prevent any "undefined method" errors if these tasks are run
124
+ # consecutively, reset the column cache before the migrations.
125
+ reset_all_column_information
126
+
121
127
  # Faker needs to have the `:en` locale in order to work properly, so we
122
128
  # must enforce it during the seeds.
123
129
  original_locale = I18n.available_locales
@@ -157,6 +163,17 @@ module Decidim
157
163
  I18n.available_locales = original_locale
158
164
  end
159
165
 
166
+ # Finds all currently loaded Decidim ActiveRecord classes and resets their
167
+ # column information.
168
+ def self.reset_all_column_information
169
+ ActiveRecord::Base.descendants.each do |cls|
170
+ next if cls.name.nil? # abstract classes registered during tests
171
+ next if cls.abstract_class? || !cls.name.match?(/^Decidim::/)
172
+
173
+ cls.reset_column_information
174
+ end
175
+ end
176
+
160
177
  # Exposes a configuration option: The application name String.
161
178
  config_accessor :application_name
162
179
 
@@ -568,7 +585,7 @@ module Decidim
568
585
  #
569
586
  # Returns an Array[ComponentManifest].
570
587
  def self.component_manifests
571
- component_registry.manifests
588
+ component_registry.manifests.sort_by(&:name)
572
589
  end
573
590
 
574
591
  # Public: Finds all registered participatory space manifest's via the
@@ -21,7 +21,7 @@ module Decidim
21
21
  if user_group
22
22
  endorsements.where(user_group: user_group).any?
23
23
  else
24
- endorsements.where(author: user, user_group: nil).any?
24
+ endorsements.where(author: user, user_group: 0).any?
25
25
  end
26
26
  end
27
27
  end
@@ -9,6 +9,11 @@ module Decidim
9
9
  autoload :PDF, "decidim/exporters/pdf"
10
10
  autoload :ExportData, "decidim/exporters/export_data"
11
11
 
12
+ # Lock the export formats to one of the available exporters
13
+ EXPORT_FORMATS = [:JSON, :CSV, :Excel, :PDF, :FormPDF].freeze
14
+
15
+ class UnknownFormatError < StandardError; end
16
+
12
17
  # Necessary for the i18n normalizer to locate strings not directly invoked in views:
13
18
 
14
19
  # i18n-tasks-use t('decidim.admin.exports.formats.JSON')
@@ -19,7 +24,11 @@ module Decidim
19
24
  #
20
25
  # format - The exporter format as a string. i.e "CSV"
21
26
  def self.find_exporter(format)
22
- const_get(format)
27
+ raise UnknownFormatError unless format.respond_to?(:to_sym)
28
+ raise UnknownFormatError unless EXPORT_FORMATS.include?(format.to_sym)
29
+ raise UnknownFormatError unless const_defined?(format.to_sym)
30
+
31
+ const_get(format.to_sym)
23
32
  end
24
33
  end
25
34
  end
@@ -181,7 +181,6 @@ module Decidim
181
181
  # or 'full' (optional) (default: 'basic')
182
182
  # :lines - The Integer to indicate how many lines should editor have (optional) (default: 10)
183
183
  # :disabled - Whether the editor should be disabled
184
- # :editor_images - Allow attached images (optional) (default: false)
185
184
  #
186
185
  # Renders a container with both hidden field and editor container
187
186
  def editor(name, options = {})
@@ -199,9 +198,12 @@ module Decidim
199
198
  template += label(name, label_text + required_for_attribute(name)) if options.fetch(:label, true)
200
199
  template += hidden_field(name, hidden_options)
201
200
  template += content_tag(:div, nil, class: "editor-container #{"js-hashtags" if hashtaggable}", data: {
202
- toolbar: toolbar,
203
- disabled: options[:disabled]
204
- }.merge(editor_images_options(options)), style: "height: #{lines}rem")
201
+ toolbar: toolbar,
202
+ disabled: options[:disabled],
203
+ editor_images: true,
204
+ upload_images_path: Decidim::Core::Engine.routes.url_helpers.editor_images_path,
205
+ drag_and_drop_help_text: I18n.t("drag_and_drop_help", scope: "decidim.editor_images")
206
+ }, style: "height: #{lines}rem")
205
207
  template += error_for(name, options) if error?(name)
206
208
  template.html_safe
207
209
  end
@@ -315,6 +317,7 @@ module Decidim
315
317
  template = ""
316
318
  template += "<label>#{label_for(attribute) + required_for_attribute(attribute)}</label>" unless options[:label] == false
317
319
  template += @template.render("decidim/scopes/scopes_picker_input",
320
+ values_options: { delete_button: true, class: "label primary" },
318
321
  picker_options: picker_options,
319
322
  prompt_params: prompt_params,
320
323
  scopes: scopes,
@@ -926,15 +929,6 @@ module Decidim
926
929
  end
927
930
  end
928
931
 
929
- def editor_images_options(options)
930
- return {} unless options[:editor_images]
931
-
932
- {
933
- upload_images_path: Decidim::Core::Engine.routes.url_helpers.editor_images_path,
934
- drag_and_drop_help_text: I18n.t("drag_and_drop_help", scope: "decidim.editor_images")
935
- }
936
- end
937
-
938
932
  # Private: Determines the correct resource class for validators from the
939
933
  # object or its PassthruValidator.
940
934
  def resource_class(attribute)
@@ -26,11 +26,11 @@ module Decidim
26
26
  cat_ids = parent_ids.dup
27
27
  cat_ids.prepend(nil) if categories.include?("without")
28
28
 
29
- subquery = includes(:category).where(decidim_categories: { id: cat_ids })
29
+ subquery = left_outer_joins(:category).where(decidim_categories: { id: cat_ids })
30
30
  return subquery if parent_ids.none?
31
31
 
32
32
  subquery.or(
33
- includes(:category).where(decidim_categories: { parent_id: parent_ids })
33
+ left_outer_joins(:category).where(decidim_categories: { parent_id: parent_ids })
34
34
  )
35
35
  }
36
36