decidim-debates 0.29.2 → 0.30.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/debates/content_blocks/highlighted_debates/content.erb +16 -0
  3. data/app/cells/decidim/debates/content_blocks/highlighted_debates_cell.rb +49 -0
  4. data/app/cells/decidim/debates/debate_card_metadata_cell.rb +2 -11
  5. data/app/cells/decidim/debates/debate_g/show.erb +12 -0
  6. data/app/cells/decidim/debates/debate_g_cell.rb +23 -0
  7. data/app/cells/decidim/debates/debate_metadata_g_cell.rb +14 -0
  8. data/app/commands/decidim/debates/admin/create_debate.rb +25 -2
  9. data/app/commands/decidim/debates/admin/update_debate.rb +34 -5
  10. data/app/commands/decidim/debates/create_debate.rb +22 -1
  11. data/app/commands/decidim/debates/update_debate.rb +26 -2
  12. data/app/controllers/decidim/debates/admin/debates_controller.rb +17 -14
  13. data/app/controllers/decidim/debates/debates_controller.rb +8 -4
  14. data/app/forms/decidim/debates/admin/debate_form.rb +34 -26
  15. data/app/forms/decidim/debates/debate_form.rb +12 -29
  16. data/app/helpers/decidim/debates/application_helper.rb +8 -8
  17. data/app/models/decidim/debates/debate.rb +23 -1
  18. data/app/permissions/decidim/debates/admin/permissions.rb +5 -5
  19. data/app/presenters/decidim/debates/admin_log/debate_presenter.rb +1 -1
  20. data/app/presenters/decidim/debates/debate_presenter.rb +1 -1
  21. data/app/queries/decidim/debates/metrics/debate_followers_metric_measure.rb +2 -2
  22. data/app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb +2 -2
  23. data/app/queries/decidim/debates/metrics/debates_metric_manage.rb +6 -6
  24. data/app/serializers/decidim/debates/download_your_data_debate_serializer.rb +6 -13
  25. data/app/views/decidim/debates/admin/debates/_actions.html.erb +27 -0
  26. data/app/views/decidim/debates/admin/debates/_debate-tr.html.erb +25 -0
  27. data/app/views/decidim/debates/admin/debates/_debates-thead.html.erb +9 -0
  28. data/app/views/decidim/debates/admin/debates/_form.html.erb +27 -6
  29. data/app/views/decidim/debates/admin/debates/index.html.erb +17 -55
  30. data/app/views/decidim/debates/admin/debates/manage_trash.html.erb +19 -0
  31. data/app/views/decidim/debates/debates/_debate_actions.html.erb +33 -0
  32. data/app/views/decidim/debates/debates/_form.html.erb +19 -6
  33. data/app/views/decidim/debates/debates/index.html.erb +10 -1
  34. data/app/views/decidim/debates/debates/show.html.erb +31 -44
  35. data/config/locales/ar.yml +9 -12
  36. data/config/locales/bg.yml +1 -15
  37. data/config/locales/ca.yml +79 -16
  38. data/config/locales/cs.yml +79 -16
  39. data/config/locales/de.yml +79 -16
  40. data/config/locales/el.yml +1 -15
  41. data/config/locales/en.yml +78 -15
  42. data/config/locales/es-MX.yml +79 -16
  43. data/config/locales/es-PY.yml +79 -16
  44. data/config/locales/es.yml +79 -16
  45. data/config/locales/eu.yml +79 -16
  46. data/config/locales/fi-plain.yml +79 -16
  47. data/config/locales/fi.yml +79 -16
  48. data/config/locales/fr-CA.yml +41 -16
  49. data/config/locales/fr.yml +41 -16
  50. data/config/locales/ga-IE.yml +0 -10
  51. data/config/locales/gl.yml +1 -13
  52. data/config/locales/hu.yml +1 -15
  53. data/config/locales/id-ID.yml +1 -13
  54. data/config/locales/is-IS.yml +0 -10
  55. data/config/locales/it.yml +1 -15
  56. data/config/locales/ja.yml +59 -16
  57. data/config/locales/lb.yml +0 -6
  58. data/config/locales/lt.yml +1 -15
  59. data/config/locales/lv.yml +1 -11
  60. data/config/locales/nl.yml +1 -14
  61. data/config/locales/no.yml +1 -15
  62. data/config/locales/pl.yml +1 -15
  63. data/config/locales/pt-BR.yml +1 -15
  64. data/config/locales/pt.yml +1 -15
  65. data/config/locales/ro-RO.yml +1 -15
  66. data/config/locales/ru.yml +0 -12
  67. data/config/locales/sk.yml +1 -13
  68. data/config/locales/sl.yml +0 -2
  69. data/config/locales/sv.yml +1 -15
  70. data/config/locales/tr-TR.yml +1 -15
  71. data/config/locales/uk.yml +0 -12
  72. data/config/locales/zh-CN.yml +1 -13
  73. data/config/locales/zh-TW.yml +1 -15
  74. data/db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb +1 -1
  75. data/db/migrate/20200902133452_add_cached_comment_metadata_to_debates.rb +1 -1
  76. data/db/migrate/20210310120652_add_followable_counter_cache_to_debates.rb +1 -1
  77. data/db/migrate/20240828103648_add_deleted_at_to_decidim_debates_debates.rb +8 -0
  78. data/db/migrate/20241017153555_add_comments_layout_to_debates.rb +7 -0
  79. data/decidim-debates.gemspec +1 -1
  80. data/lib/decidim/api/debate_type.rb +6 -8
  81. data/lib/decidim/api/debates_type.rb +4 -5
  82. data/lib/decidim/debates/admin_engine.rb +7 -0
  83. data/lib/decidim/debates/component.rb +19 -4
  84. data/lib/decidim/debates/debate_serializer.rb +83 -0
  85. data/lib/decidim/debates/seeds.rb +1 -8
  86. data/lib/decidim/debates/test/factories.rb +2 -0
  87. data/lib/decidim/debates/version.rb +1 -1
  88. data/lib/decidim/debates.rb +1 -0
  89. metadata +27 -15
  90. data/app/helpers/decidim/debates/admin/application_helper.rb +0 -13
@@ -3,8 +3,6 @@ sk:
3
3
  activemodel:
4
4
  attributes:
5
5
  debate:
6
- category_id: Kategória
7
- decidim_category_id: Kategória
8
6
  description: Popis
9
7
  end_time: Končí
10
8
  information_updates: Aktualizácia Informácií
@@ -25,8 +23,6 @@ sk:
25
23
  decidim:
26
24
  components:
27
25
  debates:
28
- actions:
29
- create: Vytvoriť
30
26
  name: Debaty
31
27
  settings:
32
28
  global:
@@ -37,8 +33,6 @@ sk:
37
33
  comments_blocked: Komentáre blokované
38
34
  debates:
39
35
  actions:
40
- confirm_destroy: Ste si istí?
41
- destroy: Odstrániť
42
36
  edit: Upraviť
43
37
  title: Akcie
44
38
  admin:
@@ -46,8 +40,6 @@ sk:
46
40
  create:
47
41
  invalid: Pri vytváraní debaty sa vyskytol problém.
48
42
  success: Debata úspešne vytvorená.
49
- destroy:
50
- success: Debata úspešne zmazaná.
51
43
  edit:
52
44
  title: Upraviť debatu
53
45
  update: Aktualizovať debatu
@@ -80,16 +72,12 @@ sk:
80
72
  official: Oficiálni
81
73
  origin: Pôvod
82
74
  search: Vyhľadávanie
83
- form:
84
- select_a_category: Vyberte kategóriu
85
75
  index:
86
76
  new_debate: Nová debata
87
77
  new:
88
78
  back: Späť
89
79
  create: Vytvoriť
90
80
  title: Nová debata
91
- show:
92
- edit_debate: Upraviť debatu
93
81
  models:
94
82
  debate:
95
83
  fields:
@@ -120,7 +108,7 @@ sk:
120
108
  badges:
121
109
  commented_debates:
122
110
  conditions:
123
- - Vyberte si otvorenú debatu a zúčastnite sa
111
+ - Vyberte si otvorenú debatu a zúčastnite sa
124
112
  description: Tento odznak ste dostali za aktívnu participáciu komentovaním v rôznych debatách.
125
113
  description_another: Tento účastník sa zúčastnil na %{score} debatách.
126
114
  description_own: Zúčastnili ste sa na %{score} debatách.
@@ -13,7 +13,5 @@ sl:
13
13
  edit:
14
14
  close: Zapri
15
15
  debates:
16
- form:
17
- select_a_category: Prosim izberi kategorijo
18
16
  show:
19
17
  debate_closed: Zaprto
@@ -3,15 +3,12 @@ sv:
3
3
  activemodel:
4
4
  attributes:
5
5
  debate:
6
- category_id: Kategori
7
6
  closed_at: Avslutades
8
7
  conclusions: Slutsatser
9
- decidim_category_id: Kategori
10
8
  description: Beskrivning
11
9
  end_time: Slutar vid
12
10
  information_updates: Uppdatering av uppgifter
13
11
  instructions: Instruktioner för att delta
14
- scope_id: Indelning
15
12
  start_time: Startdatum
16
13
  title: Titel
17
14
  user_group_id: Skapa debatt som
@@ -30,7 +27,6 @@ sv:
30
27
  debates:
31
28
  actions:
32
29
  comment: Kommentera
33
- create: Skapa
34
30
  endorse: Gilla
35
31
  name: Debatter
36
32
  settings:
@@ -38,8 +34,6 @@ sv:
38
34
  announcement: Meddelande
39
35
  comments_enabled: Aktivera kommentarer
40
36
  comments_max_length: Maximal kommentarslängd (ange 0 för att använda standardvärdet)
41
- scope_id: Indelning
42
- scopes_enabled: Aktivera indelningar
43
37
  step:
44
38
  announcement: Meddelande
45
39
  comments_blocked: Stäng av kommentarer
@@ -49,8 +43,6 @@ sv:
49
43
  debates:
50
44
  actions:
51
45
  close: Stäng
52
- confirm_destroy: Är du säker?
53
- destroy: Radera
54
46
  edit: Redigera
55
47
  new: Ny debatt
56
48
  title: Åtgärder
@@ -63,8 +55,6 @@ sv:
63
55
  create:
64
56
  invalid: Det gick inte att skapa debatten.
65
57
  success: Debatten har skapats.
66
- destroy:
67
- success: Debatten har raderats.
68
58
  edit:
69
59
  title: Redigera debatt
70
60
  update: Uppdatera debatt
@@ -125,8 +115,6 @@ sv:
125
115
  closed: Avslutade
126
116
  open: Öppna
127
117
  user_group: Grupper
128
- form:
129
- select_a_category: Välj en kategori
130
118
  index:
131
119
  new_debate: Ny debatt
132
120
  new:
@@ -140,11 +128,9 @@ sv:
140
128
  recent: Senaste
141
129
  updated: Senast uppdaterade
142
130
  show:
143
- close_debate: Avsluta debatt
144
131
  debate_closed: Avslutade
145
132
  debate_conclusions_are: 'Debatten avslutades %{date} med följande slutsatser:'
146
133
  edit_conclusions: Redigera slutsatser
147
- edit_debate: Redigera debatt
148
134
  groups_count: Grupper
149
135
  open: Öppen debatt
150
136
  participants_count: Deltagare
@@ -205,7 +191,7 @@ sv:
205
191
  badges:
206
192
  commented_debates:
207
193
  conditions:
208
- - Välj en öppen debatt att delta i
194
+ - Välj en öppen debatt att delta i
209
195
  description: Detta märke beviljas när du aktivt deltar i de olika debatterna genom att lämna dina kommentarer.
210
196
  description_another: Deltagaren har deltagit i %{score} debatter.
211
197
  description_own: Du har deltagit i %{score} debatter.
@@ -3,15 +3,12 @@ tr:
3
3
  activemodel:
4
4
  attributes:
5
5
  debate:
6
- category_id: Kategori
7
6
  closed_at: Kapandı
8
7
  conclusions: Sonuçlar
9
- decidim_category_id: Kategori
10
8
  description: Açıklama
11
9
  end_time: Biter
12
10
  information_updates: Bilgi güncellemeleri
13
11
  instructions: Katılma talimatları
14
- scope_id: Kapsam
15
12
  start_time: Den başlar
16
13
  title: Başlık
17
14
  user_group_id: Olarak tartışma oluştur
@@ -28,7 +25,6 @@ tr:
28
25
  components:
29
26
  debates:
30
27
  actions:
31
- create: Oluştur
32
28
  endorse: Onayla
33
29
  name: Tartışmalar
34
30
  settings:
@@ -36,8 +32,6 @@ tr:
36
32
  announcement: duyuru
37
33
  comments_enabled: Yorumlar etkin
38
34
  comments_max_length: Maksimum yorum uzunluğu (Varsayılan değer için 0 bırakın)
39
- scope_id: Kapsam
40
- scopes_enabled: Kapsamlar etkinleştirildi
41
35
  step:
42
36
  announcement: duyuru
43
37
  comments_blocked: Yorumlar engellendi
@@ -46,8 +40,6 @@ tr:
46
40
  debates:
47
41
  actions:
48
42
  close: Kapat
49
- confirm_destroy: Emin misiniz?
50
- destroy: Sil
51
43
  edit: Düzenle
52
44
  new: Yeni Tartışma
53
45
  title: Eylemler
@@ -60,8 +52,6 @@ tr:
60
52
  create:
61
53
  invalid: Tartışmayı oluştururken bir sorun oluştu.
62
54
  success: Tartışma başarıyla oluşturuldu.
63
- destroy:
64
- success: Tartışma başarıyla silindi.
65
55
  edit:
66
56
  title: Tartışmayı düzenle
67
57
  update: Tartışmayı güncelle
@@ -119,8 +109,6 @@ tr:
119
109
  state_values:
120
110
  closed: Kapalı
121
111
  open: Açık
122
- form:
123
- select_a_category: Lütfen bir kategori seçin
124
112
  index:
125
113
  new_debate: Yeni tartışma
126
114
  new:
@@ -134,11 +122,9 @@ tr:
134
122
  recent: En yeni
135
123
  updated: Yeni güncellenmiş
136
124
  show:
137
- close_debate: Tartışmayı kapat
138
125
  debate_closed: Kapalı
139
126
  debate_conclusions_are: 'Tartışma bu sonuçlarla %{date} tarihinde kapatıldı:'
140
127
  edit_conclusions: Sonuçları düzenleyin
141
- edit_debate: Tartışmayı düzenle
142
128
  groups_count: Gruplar
143
129
  open: Açık tartışma
144
130
  participants_count: Katılımcılar
@@ -193,7 +179,7 @@ tr:
193
179
  badges:
194
180
  commented_debates:
195
181
  conditions:
196
- - Katılmak için açık bir tartışma seçin
182
+ - Katılmak için açık bir tartışma seçin
197
183
  description: Bu rozet, yorumlarınızı bırakarak farklı tartışmalara aktif olarak katıldığınızda verilir.
198
184
  description_another: Bu katılımcı %{score} kez tartışmada yer aldı.
199
185
  description_own: '%{score} kez tartışmaya katıldınız.'
@@ -3,8 +3,6 @@ uk:
3
3
  activemodel:
4
4
  attributes:
5
5
  debate:
6
- category_id: Категорія
7
- decidim_category_id: Категорія
8
6
  description: Опис
9
7
  end_time: 'Закінчується:'
10
8
  information_updates: Оновлення відомостей
@@ -25,8 +23,6 @@ uk:
25
23
  decidim:
26
24
  components:
27
25
  debates:
28
- actions:
29
- create: Започаткувати
30
26
  name: Обговорення
31
27
  settings:
32
28
  global:
@@ -37,8 +33,6 @@ uk:
37
33
  comments_blocked: Коментарі вимкнено
38
34
  debates:
39
35
  actions:
40
- confirm_destroy: Ви впевнені?
41
- destroy: Видалити
42
36
  edit: Редагувати
43
37
  title: Дії
44
38
  admin:
@@ -46,8 +40,6 @@ uk:
46
40
  create:
47
41
  invalid: При спробі започаткувати обговорення сталася помилка.
48
42
  success: Обговорення успішно започатковано.
49
- destroy:
50
- success: Обговорення успішно видалено.
51
43
  edit:
52
44
  title: Редагувати обговорення
53
45
  update: Оновити обговорення
@@ -80,16 +72,12 @@ uk:
80
72
  official: Службове
81
73
  origin: Джерело
82
74
  search: Шукати
83
- form:
84
- select_a_category: Будь ласка, виберіть категорію
85
75
  index:
86
76
  new_debate: Додати обговорення
87
77
  new:
88
78
  back: Повернутись
89
79
  create: Започаткувати
90
80
  title: Додати обговорення
91
- show:
92
- edit_debate: Редагувати обговорення
93
81
  models:
94
82
  debate:
95
83
  fields:
@@ -3,15 +3,12 @@ zh-CN:
3
3
  activemodel:
4
4
  attributes:
5
5
  debate:
6
- category_id: 类别
7
6
  closed_at: 关闭于
8
7
  conclusions: 四. 结论
9
- decidim_category_id: 类别
10
8
  description: 描述
11
9
  end_time: 结束于
12
10
  information_updates: 信息更新
13
11
  instructions: 参与说明
14
- scope_id: 范围
15
12
  start_time: 开始于
16
13
  title: 标题
17
14
  user_group_id: 创建辩论为
@@ -27,7 +24,6 @@ zh-CN:
27
24
  components:
28
25
  debates:
29
26
  actions:
30
- create: 创建
31
27
  endorse: 批准
32
28
  name: 辩论
33
29
  settings:
@@ -35,8 +31,6 @@ zh-CN:
35
31
  announcement: 通 知
36
32
  comments_enabled: 评论已启用
37
33
  comments_max_length: 评论最大长度 (默认值留0)
38
- scope_id: 范围
39
- scopes_enabled: 范围已启用
40
34
  step:
41
35
  announcement: 通 知
42
36
  comments_blocked: 评论已阻止
@@ -45,8 +39,6 @@ zh-CN:
45
39
  debates:
46
40
  actions:
47
41
  close: 关闭
48
- confirm_destroy: 您确定吗?
49
- destroy: 删除
50
42
  edit: 编辑
51
43
  title: 行动
52
44
  admin:
@@ -58,8 +50,6 @@ zh-CN:
58
50
  create:
59
51
  invalid: 有一个问题是如何建立辩论。
60
52
  success: 辩论成功创建。
61
- destroy:
62
- success: 辩论已成功删除。
63
53
  edit:
64
54
  title: 编辑辩论
65
55
  update: 更新辩论
@@ -122,11 +112,9 @@ zh-CN:
122
112
  recent: 最新的
123
113
  updated: 最近更新
124
114
  show:
125
- close_debate: 结束辩论
126
115
  debate_closed: 已关闭
127
116
  debate_conclusions_are: '辩论在 %{date} 结束后得出以下结论:'
128
117
  edit_conclusions: 编辑结论
129
- edit_debate: 编辑辩论
130
118
  groups_count: 群組
131
119
  participants_count: 参加者
132
120
  update:
@@ -173,7 +161,7 @@ zh-CN:
173
161
  badges:
174
162
  commented_debates:
175
163
  conditions:
176
- - 选择要参与的公开辩论
164
+ - 选择要参与的公开辩论
177
165
  description: 当你通过留下评论积极参与不同的辩论时,这个徽章将被授予。
178
166
  description_another: 此参与者已经参加了 %{score} 场辩论。
179
167
  description_own: 您已经参加了 %{score} 次辩论。
@@ -3,15 +3,12 @@ zh-TW:
3
3
  activemodel:
4
4
  attributes:
5
5
  debate:
6
- category_id: 類別
7
6
  closed_at: 關閉於
8
7
  conclusions: 結論
9
- decidim_category_id: 類別
10
8
  description: 說明
11
9
  end_time: 結束於
12
10
  information_updates: 資訊更新
13
11
  instructions: 參加指南
14
- scope_id: 範圍
15
12
  start_time: 開始於
16
13
  title: 標題
17
14
  user_group_id: 建立辯論為
@@ -29,7 +26,6 @@ zh-TW:
29
26
  debates:
30
27
  actions:
31
28
  comment: 留言
32
- create: 建立
33
29
  endorse: 連署
34
30
  name: 辯論
35
31
  settings:
@@ -37,8 +33,6 @@ zh-TW:
37
33
  announcement: 公告
38
34
  comments_enabled: 啟用評論功能
39
35
  comments_max_length: 評論字數最大長度(若要使用預設值請輸入0)
40
- scope_id: 範圍
41
- scopes_enabled: 啟用範圍
42
36
  step:
43
37
  announcement: 公告
44
38
  comments_blocked: 留言已封鎖
@@ -48,8 +42,6 @@ zh-TW:
48
42
  debates:
49
43
  actions:
50
44
  close: 關閉
51
- confirm_destroy: 您確定嗎?
52
- destroy: 刪除
53
45
  edit: 編輯
54
46
  title: 操作
55
47
  admin:
@@ -61,8 +53,6 @@ zh-TW:
61
53
  create:
62
54
  invalid: 建立辯論時出現問題。
63
55
  success: 辯論建立成功。
64
- destroy:
65
- success: 辯論已成功刪除。
66
56
  edit:
67
57
  title: 編輯辯論
68
58
  update: 更新辯論
@@ -117,8 +107,6 @@ zh-TW:
117
107
  state_values:
118
108
  closed: 關閉
119
109
  open: 開啟
120
- form:
121
- select_a_category: 請選擇一個類別
122
110
  index:
123
111
  new_debate: 新辯論
124
112
  new:
@@ -132,11 +120,9 @@ zh-TW:
132
120
  recent: 最近
133
121
  updated: 最近更新
134
122
  show:
135
- close_debate: 關閉辯論
136
123
  debate_closed: 關閉
137
124
  debate_conclusions_are: '此辯論已於 %{date} 結束,以下是總結結論:'
138
125
  edit_conclusions: 修改結論
139
- edit_debate: 編輯辯論
140
126
  groups_count: 群組
141
127
  open: 開放性辯論
142
128
  participants_count: 參與者
@@ -188,7 +174,7 @@ zh-TW:
188
174
  badges:
189
175
  commented_debates:
190
176
  conditions:
191
- - 選擇一個開放辯論加入
177
+ - 選擇一個開放辯論加入
192
178
  description: 當你在不同辯論中發表評論時,會被授予此徽章。
193
179
  description_another: 此參與者已參與了 %{score} 個辯論。
194
180
  description_own: 您已經參與了 %{score} 場辯論
@@ -6,7 +6,7 @@ class AddCommentableCounterCacheToDebates < ActiveRecord::Migration[5.2]
6
6
  Decidim::Debates::Debate.reset_column_information
7
7
 
8
8
  # rubocop:disable Rails/SkipsModelValidations
9
- Decidim::Debates::Debate.includes(:comments).find_each do |debate|
9
+ Decidim::Debates::Debate.unscoped.includes(:comments).find_each do |debate|
10
10
  debate.update_columns(comments_count: debate.comments.not_hidden.count)
11
11
  end
12
12
  # rubocop:enable Rails/SkipsModelValidations
@@ -8,7 +8,7 @@ class AddCachedCommentMetadataToDebates < ActiveRecord::Migration[5.2]
8
8
 
9
9
  # rubocop:disable Rails/SkipsModelValidations
10
10
  Decidim::Debates::Debate.reset_column_information
11
- Decidim::Debates::Debate.includes(comments: [:author, :user_group]).find_each do |debate|
11
+ Decidim::Debates::Debate.unscoped.includes(comments: [:author, :user_group]).find_each do |debate|
12
12
  last_comment = debate.comments.order("created_at DESC").first
13
13
  next unless last_comment
14
14
 
@@ -7,7 +7,7 @@ class AddFollowableCounterCacheToDebates < ActiveRecord::Migration[5.2]
7
7
  reversible do |dir|
8
8
  dir.up do
9
9
  Decidim::Debates::Debate.reset_column_information
10
- Decidim::Debates::Debate.find_each do |record|
10
+ Decidim::Debates::Debate.unscoped.find_each do |record|
11
11
  record.class.reset_counters(record.id, :follows)
12
12
  end
13
13
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddDeletedAtToDecidimDebatesDebates < ActiveRecord::Migration[7.0]
4
+ def change
5
+ add_column :decidim_debates_debates, :deleted_at, :datetime
6
+ add_index :decidim_debates_debates, :deleted_at
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddCommentsLayoutToDebates < ActiveRecord::Migration[7.0]
4
+ def change
5
+ add_column :decidim_debates_debates, :comments_layout, :string
6
+ end
7
+ end
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  "homepage_uri" => "https://decidim.org",
19
19
  "source_code_uri" => "https://github.com/decidim/decidim"
20
20
  }
21
- s.required_ruby_version = "~> 3.2.0"
21
+ s.required_ruby_version = "~> 3.3.0"
22
22
 
23
23
  s.name = "decidim-debates"
24
24
  s.summary = "Decidim debates module"
@@ -3,24 +3,22 @@
3
3
  module Decidim
4
4
  module Debates
5
5
  class DebateType < Decidim::Api::Types::BaseObject
6
- implements Decidim::Core::CategorizableInterface
6
+ implements Decidim::Core::TaxonomizableInterface
7
7
  implements Decidim::Comments::CommentableInterface
8
8
  implements Decidim::Core::AuthorableInterface
9
- implements Decidim::Core::ScopableInterface
9
+ implements Decidim::Core::TimestampsInterface
10
10
 
11
11
  description "A debate"
12
12
 
13
- field :id, GraphQL::Types::ID, "The internal ID for this debate", null: false
14
- field :title, Decidim::Core::TranslatedFieldType, "The title for this debate", null: true
15
13
  field :description, Decidim::Core::TranslatedFieldType, "The description for this debate", null: true
16
- field :instructions, Decidim::Core::TranslatedFieldType, "The instructions for this debate", null: true
17
- field :start_time, Decidim::Core::DateTimeType, "The start time for this debate", null: true
18
14
  field :end_time, Decidim::Core::DateTimeType, "The end time for this debate", null: true
15
+ field :id, GraphQL::Types::ID, "The internal ID for this debate", null: false
19
16
  field :image, GraphQL::Types::String, "The image of this debate", null: true
20
- field :created_at, Decidim::Core::DateTimeType, "When this debate was created", null: true
21
- field :updated_at, Decidim::Core::DateTimeType, "When this debate was updated", null: true
22
17
  field :information_updates, Decidim::Core::TranslatedFieldType, "The information updates for this debate", null: true
18
+ field :instructions, Decidim::Core::TranslatedFieldType, "The instructions for this debate", null: true
23
19
  field :reference, GraphQL::Types::String, "The reference for this debate", null: true
20
+ field :start_time, Decidim::Core::DateTimeType, "The start time for this debate", null: true
21
+ field :title, Decidim::Core::TranslatedFieldType, "The title for this debate", null: true
24
22
 
25
23
  def self.authorized?(object, context)
26
24
  context[:debate] = object
@@ -6,16 +6,15 @@ module Decidim
6
6
  graphql_name "Debates"
7
7
  description "A debates component of a participatory space."
8
8
 
9
- field :debates, Decidim::Debates::DebateType.connection_type, null: true, connection: true
9
+ field :debate, Decidim::Debates::DebateType, "A single Debate object", null: true do
10
+ argument :id, GraphQL::Types::ID, "The id of the Debate requested", required: true
11
+ end
12
+ field :debates, Decidim::Debates::DebateType.connection_type, "A collection of Debates", null: true, connection: true
10
13
 
11
14
  def debates
12
15
  Debate.where(component: object).includes(:component)
13
16
  end
14
17
 
15
- field :debate, Decidim::Debates::DebateType, null: true do
16
- argument :id, GraphQL::Types::ID, required: true
17
- end
18
-
19
18
  def debate(**args)
20
19
  Debate.where(component: object).find_by(id: args[:id])
21
20
  end
@@ -14,6 +14,13 @@ module Decidim
14
14
  routes do
15
15
  resources :debates do
16
16
  resources :debate_closes, only: [:edit, :update]
17
+
18
+ member do
19
+ patch :soft_delete
20
+ patch :restore
21
+ end
22
+
23
+ get :manage_trash, on: :collection
17
24
  end
18
25
  root to: "debates#index"
19
26
  end
@@ -17,11 +17,11 @@ Decidim.register_component(:debates) do |component|
17
17
  end
18
18
 
19
19
  component.settings(:global) do |settings|
20
- settings.attribute :scopes_enabled, type: :boolean, default: false
21
- settings.attribute :scope_id, type: :scope
20
+ settings.attribute :taxonomy_filters, type: :taxonomy_filters
22
21
  settings.attribute :comments_enabled, type: :boolean, default: true
23
22
  settings.attribute :comments_max_length, type: :integer, required: true
24
23
  settings.attribute :announcement, type: :text, translated: true, editor: true
24
+ settings.attribute :attachments_allowed, type: :boolean, default: false
25
25
  end
26
26
 
27
27
  component.settings(:step) do |settings|
@@ -56,13 +56,28 @@ Decidim.register_component(:debates) do |component|
56
56
 
57
57
  component.actions = %w(create endorse comment)
58
58
 
59
- component.exports :comments do |exports|
59
+ component.exports :debates do |exports|
60
+ exports.collection do |component_instance|
61
+ Decidim::Debates::Debate
62
+ .not_hidden
63
+ .where(component: component_instance)
64
+ .includes(:taxonomies, component: { participatory_space: :organization })
65
+ end
66
+
67
+ exports.include_in_open_data = true
68
+
69
+ exports.serializer Decidim::Debates::DebateSerializer
70
+ end
71
+
72
+ component.exports :debate_comments do |exports|
60
73
  exports.collection do |component_instance|
61
74
  Decidim::Comments::Export.comments_for_resource(
62
75
  Decidim::Debates::Debate, component_instance
63
- )
76
+ ).includes(:author, :user_group, root_commentable: { component: { participatory_space: :organization } })
64
77
  end
65
78
 
79
+ exports.include_in_open_data = true
80
+
66
81
  exports.serializer Decidim::Comments::CommentSerializer
67
82
  end
68
83
 
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Debates
5
+ # This class serializes a Debate so can be exported to CSV, JSON or other
6
+ # formats.
7
+ class DebateSerializer < Decidim::Exporters::Serializer
8
+ include Decidim::ApplicationHelper
9
+ include Decidim::ResourceHelper
10
+
11
+ # Public: Exports a hash with the serialized data for this resource.
12
+ def serialize
13
+ {
14
+ id: resource.id,
15
+ author: {
16
+ **author_fields
17
+ },
18
+ title: resource.title,
19
+ description: resource.description,
20
+ instructions: resource.instructions,
21
+ start_time: resource.start_time,
22
+ end_time: resource.end_time,
23
+ information_updates: resource.information_updates,
24
+ taxonomies:,
25
+ participatory_space: {
26
+ id: resource.participatory_space.id,
27
+ url: Decidim::ResourceLocatorPresenter.new(resource.participatory_space).url
28
+ },
29
+ component: { id: component.id },
30
+ reference: resource.reference,
31
+ comments: resource.comments_count,
32
+ follows_count: resource.follows_count,
33
+ url: Decidim::ResourceLocatorPresenter.new(resource).url,
34
+ last_comment_at: resource.last_comment_at,
35
+ last_comment_by: {
36
+ **last_comment_by_fields
37
+ },
38
+ comments_enabled: resource.comments_enabled,
39
+ conclusions: resource.conclusions,
40
+ closed_at: resource.closed_at,
41
+ created_at: resource.created_at,
42
+ updated_at: resource.updated_at,
43
+ endorsements_count: resource.endorsements_count
44
+ }
45
+ end
46
+
47
+ private
48
+
49
+ def last_comment_by_fields
50
+ return {} unless resource.last_comment_by
51
+ return {} if resource.last_comment_by.respond_to?(:deleted?) && resource.last_comment_by.deleted?
52
+
53
+ {
54
+ id: resource.last_comment_by.id,
55
+ name: user_name(resource.last_comment_by),
56
+ url: user_url(resource.last_comment_by)
57
+ }
58
+ end
59
+
60
+ def author_fields
61
+ return {} if resource.author.respond_to?(:deleted?) && resource.author.deleted?
62
+
63
+ {
64
+ id: resource.author.id,
65
+ name: user_name(resource.author),
66
+ url: user_url(resource.author)
67
+ }
68
+ end
69
+
70
+ def user_name(author)
71
+ translated_attribute(author.name)
72
+ end
73
+
74
+ def user_url(author)
75
+ if author.respond_to?(:nickname)
76
+ profile_url(author) # is a Decidim::User or Decidim::UserGroup
77
+ else
78
+ root_url # is a Decidim::Organization
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end