decidim-debates 0.29.1 → 0.30.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/debates/content_blocks/highlighted_debates/content.erb +16 -0
- data/app/cells/decidim/debates/content_blocks/highlighted_debates_cell.rb +49 -0
- data/app/cells/decidim/debates/debate_card_metadata_cell.rb +2 -11
- data/app/cells/decidim/debates/debate_g/show.erb +12 -0
- data/app/cells/decidim/debates/debate_g_cell.rb +23 -0
- data/app/cells/decidim/debates/debate_metadata_g_cell.rb +14 -0
- data/app/commands/decidim/debates/admin/create_debate.rb +25 -2
- data/app/commands/decidim/debates/admin/update_debate.rb +34 -5
- data/app/commands/decidim/debates/create_debate.rb +22 -1
- data/app/commands/decidim/debates/update_debate.rb +26 -2
- data/app/controllers/decidim/debates/admin/debates_controller.rb +17 -14
- data/app/controllers/decidim/debates/debates_controller.rb +8 -4
- data/app/forms/decidim/debates/admin/close_debate_form.rb +1 -1
- data/app/forms/decidim/debates/admin/debate_form.rb +37 -29
- data/app/forms/decidim/debates/debate_form.rb +12 -29
- data/app/helpers/decidim/debates/application_helper.rb +8 -8
- data/app/models/decidim/debates/debate.rb +23 -1
- data/app/permissions/decidim/debates/admin/permissions.rb +5 -5
- data/app/permissions/decidim/debates/permissions.rb +2 -0
- data/app/presenters/decidim/debates/admin_log/debate_presenter.rb +1 -1
- data/app/presenters/decidim/debates/debate_presenter.rb +1 -1
- data/app/queries/decidim/debates/metrics/debate_followers_metric_measure.rb +2 -2
- data/app/queries/decidim/debates/metrics/debate_participants_metric_measure.rb +2 -2
- data/app/queries/decidim/debates/metrics/debates_metric_manage.rb +6 -6
- data/app/serializers/decidim/debates/download_your_data_debate_serializer.rb +6 -13
- data/app/views/decidim/debates/admin/debates/_actions.html.erb +27 -0
- data/app/views/decidim/debates/admin/debates/_debate-tr.html.erb +25 -0
- data/app/views/decidim/debates/admin/debates/_debates-thead.html.erb +9 -0
- data/app/views/decidim/debates/admin/debates/_form.html.erb +27 -6
- data/app/views/decidim/debates/admin/debates/index.html.erb +17 -55
- data/app/views/decidim/debates/admin/debates/manage_trash.html.erb +19 -0
- data/app/views/decidim/debates/debates/_debate_actions.html.erb +33 -0
- data/app/views/decidim/debates/debates/_form.html.erb +19 -6
- data/app/views/decidim/debates/debates/index.html.erb +10 -1
- data/app/views/decidim/debates/debates/show.html.erb +31 -44
- data/config/locales/ar.yml +9 -11
- data/config/locales/bg.yml +1 -17
- data/config/locales/bn-BD.yml +1 -0
- data/config/locales/bs-BA.yml +1 -0
- data/config/locales/ca.yml +79 -16
- data/config/locales/cs.yml +85 -22
- data/config/locales/de.yml +79 -16
- data/config/locales/el.yml +1 -17
- data/config/locales/en.yml +78 -15
- data/config/locales/es-MX.yml +79 -16
- data/config/locales/es-PY.yml +79 -16
- data/config/locales/es.yml +79 -16
- data/config/locales/eu.yml +93 -30
- data/config/locales/fi-plain.yml +79 -16
- data/config/locales/fi.yml +80 -17
- data/config/locales/fr-CA.yml +41 -16
- data/config/locales/fr.yml +41 -16
- data/config/locales/ga-IE.yml +0 -11
- data/config/locales/gl.yml +1 -11
- data/config/locales/hu.yml +1 -17
- data/config/locales/id-ID.yml +1 -11
- data/config/locales/is-IS.yml +0 -8
- data/config/locales/it.yml +1 -16
- data/config/locales/ja.yml +59 -16
- data/config/locales/lb.yml +0 -9
- data/config/locales/lt.yml +1 -17
- data/config/locales/lv.yml +1 -9
- data/config/locales/nl.yml +1 -15
- data/config/locales/no.yml +1 -16
- data/config/locales/pl.yml +1 -17
- data/config/locales/pt-BR.yml +1 -17
- data/config/locales/pt.yml +1 -16
- data/config/locales/ro-RO.yml +1 -17
- data/config/locales/ru.yml +0 -10
- data/config/locales/sk.yml +1 -11
- data/config/locales/sl.yml +0 -3
- data/config/locales/sv.yml +1 -17
- data/config/locales/tr-TR.yml +1 -16
- data/config/locales/uk.yml +0 -10
- data/config/locales/zh-CN.yml +1 -12
- data/config/locales/zh-TW.yml +1 -17
- data/db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb +1 -1
- data/db/migrate/20200902133452_add_cached_comment_metadata_to_debates.rb +1 -1
- data/db/migrate/20210310120652_add_followable_counter_cache_to_debates.rb +1 -1
- data/db/migrate/20240828103648_add_deleted_at_to_decidim_debates_debates.rb +8 -0
- data/db/migrate/20241017153555_add_comments_layout_to_debates.rb +7 -0
- data/decidim-debates.gemspec +3 -2
- data/lib/decidim/api/debate_type.rb +12 -8
- data/lib/decidim/api/debates_type.rb +5 -8
- data/lib/decidim/debates/admin_engine.rb +7 -0
- data/lib/decidim/debates/component.rb +19 -4
- data/lib/decidim/debates/debate_serializer.rb +83 -0
- data/lib/decidim/debates/seeds.rb +1 -8
- data/lib/decidim/debates/test/factories.rb +8 -0
- data/lib/decidim/debates/version.rb +1 -1
- data/lib/decidim/debates.rb +1 -0
- metadata +42 -14
- data/app/helpers/decidim/debates/admin/application_helper.rb +0 -13
data/config/locales/tr-TR.yml
CHANGED
@@ -3,10 +3,8 @@ 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
|
@@ -27,7 +25,6 @@ tr:
|
|
27
25
|
components:
|
28
26
|
debates:
|
29
27
|
actions:
|
30
|
-
create: yaratmak
|
31
28
|
endorse: Onayla
|
32
29
|
name: Tartışmalar
|
33
30
|
settings:
|
@@ -35,8 +32,6 @@ tr:
|
|
35
32
|
announcement: duyuru
|
36
33
|
comments_enabled: Yorumlar etkin
|
37
34
|
comments_max_length: Maksimum yorum uzunluğu (Varsayılan değer için 0 bırakın)
|
38
|
-
scope_id: Kapsam
|
39
|
-
scopes_enabled: Kapsamlar etkinleştirildi
|
40
35
|
step:
|
41
36
|
announcement: duyuru
|
42
37
|
comments_blocked: Yorumlar engellendi
|
@@ -45,8 +40,6 @@ tr:
|
|
45
40
|
debates:
|
46
41
|
actions:
|
47
42
|
close: Kapat
|
48
|
-
confirm_destroy: Emin misiniz?
|
49
|
-
destroy: Sil
|
50
43
|
edit: Düzenle
|
51
44
|
new: Yeni Tartışma
|
52
45
|
title: Eylemler
|
@@ -59,8 +52,6 @@ tr:
|
|
59
52
|
create:
|
60
53
|
invalid: Tartışmayı oluştururken bir sorun oluştu.
|
61
54
|
success: Tartışma başarıyla oluşturuldu.
|
62
|
-
destroy:
|
63
|
-
success: Tartışma başarıyla silindi.
|
64
55
|
edit:
|
65
56
|
title: Tartışmayı düzenle
|
66
57
|
update: Tartışmayı güncelle
|
@@ -76,8 +67,6 @@ tr:
|
|
76
67
|
update:
|
77
68
|
invalid: Bu tartışmayı güncellerken bir sorun oluştu.
|
78
69
|
success: Tartışma başarıyla güncellendi.
|
79
|
-
exports:
|
80
|
-
comments: Yorumlar
|
81
70
|
admin_log:
|
82
71
|
debate:
|
83
72
|
close: "%{user_name}, %{space_name} alanındaki %{resource_name} tartışmasını kapattı"
|
@@ -120,8 +109,6 @@ tr:
|
|
120
109
|
state_values:
|
121
110
|
closed: Kapalı
|
122
111
|
open: Açık
|
123
|
-
form:
|
124
|
-
select_a_category: Lütfen bir kategori seçin
|
125
112
|
index:
|
126
113
|
new_debate: Yeni tartışma
|
127
114
|
new:
|
@@ -135,11 +122,9 @@ tr:
|
|
135
122
|
recent: En yeni
|
136
123
|
updated: Yeni güncellenmiş
|
137
124
|
show:
|
138
|
-
close_debate: Tartışmayı kapat
|
139
125
|
debate_closed: Kapalı
|
140
126
|
debate_conclusions_are: 'Tartışma bu sonuçlarla %{date} tarihinde kapatıldı:'
|
141
127
|
edit_conclusions: Sonuçları düzenleyin
|
142
|
-
edit_debate: Tartışmayı düzenle
|
143
128
|
groups_count: Gruplar
|
144
129
|
open: Açık tartışma
|
145
130
|
participants_count: Katılımcılar
|
@@ -194,7 +179,7 @@ tr:
|
|
194
179
|
badges:
|
195
180
|
commented_debates:
|
196
181
|
conditions:
|
197
|
-
|
182
|
+
- Katılmak için açık bir tartışma seçin
|
198
183
|
description: Bu rozet, yorumlarınızı bırakarak farklı tartışmalara aktif olarak katıldığınızda verilir.
|
199
184
|
description_another: Bu katılımcı %{score} kez tartışmada yer aldı.
|
200
185
|
description_own: '%{score} kez tartışmaya katıldınız.'
|
data/config/locales/uk.yml
CHANGED
@@ -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,8 +72,6 @@ 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:
|
data/config/locales/zh-CN.yml
CHANGED
@@ -3,10 +3,8 @@ 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: 信息更新
|
@@ -26,7 +24,6 @@ zh-CN:
|
|
26
24
|
components:
|
27
25
|
debates:
|
28
26
|
actions:
|
29
|
-
create: 创建
|
30
27
|
endorse: 批准
|
31
28
|
name: 辩论
|
32
29
|
settings:
|
@@ -34,8 +31,6 @@ zh-CN:
|
|
34
31
|
announcement: 通 知
|
35
32
|
comments_enabled: 评论已启用
|
36
33
|
comments_max_length: 评论最大长度 (默认值留0)
|
37
|
-
scope_id: 范围
|
38
|
-
scopes_enabled: 范围已启用
|
39
34
|
step:
|
40
35
|
announcement: 通 知
|
41
36
|
comments_blocked: 评论已阻止
|
@@ -44,8 +39,6 @@ zh-CN:
|
|
44
39
|
debates:
|
45
40
|
actions:
|
46
41
|
close: 关闭
|
47
|
-
confirm_destroy: 您确定吗?
|
48
|
-
destroy: 删除
|
49
42
|
edit: 编辑
|
50
43
|
title: 行动
|
51
44
|
admin:
|
@@ -57,8 +50,6 @@ zh-CN:
|
|
57
50
|
create:
|
58
51
|
invalid: 有一个问题是如何建立辩论。
|
59
52
|
success: 辩论成功创建。
|
60
|
-
destroy:
|
61
|
-
success: 辩论已成功删除。
|
62
53
|
edit:
|
63
54
|
title: 编辑辩论
|
64
55
|
update: 更新辩论
|
@@ -121,11 +112,9 @@ zh-CN:
|
|
121
112
|
recent: 最新的
|
122
113
|
updated: 最近更新
|
123
114
|
show:
|
124
|
-
close_debate: 结束辩论
|
125
115
|
debate_closed: 已关闭
|
126
116
|
debate_conclusions_are: '辩论在 %{date} 结束后得出以下结论:'
|
127
117
|
edit_conclusions: 编辑结论
|
128
|
-
edit_debate: 编辑辩论
|
129
118
|
groups_count: 群組
|
130
119
|
participants_count: 参加者
|
131
120
|
update:
|
@@ -172,7 +161,7 @@ zh-CN:
|
|
172
161
|
badges:
|
173
162
|
commented_debates:
|
174
163
|
conditions:
|
175
|
-
|
164
|
+
- 选择要参与的公开辩论
|
176
165
|
description: 当你通过留下评论积极参与不同的辩论时,这个徽章将被授予。
|
177
166
|
description_another: 此参与者已经参加了 %{score} 场辩论。
|
178
167
|
description_own: 您已经参加了 %{score} 次辩论。
|
data/config/locales/zh-TW.yml
CHANGED
@@ -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: 更新辯論
|
@@ -78,8 +68,6 @@ zh-TW:
|
|
78
68
|
update:
|
79
69
|
invalid: 更新此辯論時發生問題。
|
80
70
|
success: 辯論已成功更新
|
81
|
-
exports:
|
82
|
-
comments: 評論
|
83
71
|
admin_log:
|
84
72
|
debate:
|
85
73
|
close: "%{user_name} 在 %{space_name} 空間關閉了 %{resource_name} 辯論。"
|
@@ -119,8 +107,6 @@ zh-TW:
|
|
119
107
|
state_values:
|
120
108
|
closed: 關閉
|
121
109
|
open: 開啟
|
122
|
-
form:
|
123
|
-
select_a_category: 請選擇一個類別
|
124
110
|
index:
|
125
111
|
new_debate: 新辯論
|
126
112
|
new:
|
@@ -134,11 +120,9 @@ zh-TW:
|
|
134
120
|
recent: 最近
|
135
121
|
updated: 最近更新
|
136
122
|
show:
|
137
|
-
close_debate: 關閉辯論
|
138
123
|
debate_closed: 關閉
|
139
124
|
debate_conclusions_are: '此辯論已於 %{date} 結束,以下是總結結論:'
|
140
125
|
edit_conclusions: 修改結論
|
141
|
-
edit_debate: 編輯辯論
|
142
126
|
groups_count: 群組
|
143
127
|
open: 開放性辯論
|
144
128
|
participants_count: 參與者
|
@@ -190,7 +174,7 @@ zh-TW:
|
|
190
174
|
badges:
|
191
175
|
commented_debates:
|
192
176
|
conditions:
|
193
|
-
|
177
|
+
- 選擇一個開放辯論加入
|
194
178
|
description: 當你在不同辯論中發表評論時,會被授予此徽章。
|
195
179
|
description_another: 此參與者已參與了 %{score} 個辯論。
|
196
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
|
data/decidim-debates.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.version = Decidim::Debates.version
|
10
10
|
s.authors = ["Josep Jaume Rey Peroy", "Marc Riera Casals", "Oriol Gual Oliva", "Genis Matutes Pujol"]
|
11
11
|
s.email = ["josepjaume@gmail.com", "mrc2407@gmail.com", "oriolgual@gmail.com", "genis.matutes@gmail.com"]
|
12
|
-
s.license = "AGPL-3.0"
|
12
|
+
s.license = "AGPL-3.0-or-later"
|
13
13
|
s.homepage = "https://decidim.org"
|
14
14
|
s.metadata = {
|
15
15
|
"bug_tracker_uri" => "https://github.com/decidim/decidim/issues",
|
@@ -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.
|
21
|
+
s.required_ruby_version = "~> 3.3.0"
|
22
22
|
|
23
23
|
s.name = "decidim-debates"
|
24
24
|
s.summary = "Decidim debates module"
|
@@ -35,5 +35,6 @@ Gem::Specification.new do |s|
|
|
35
35
|
s.add_dependency "decidim-core", Decidim::Debates.version
|
36
36
|
|
37
37
|
s.add_development_dependency "decidim-admin", Decidim::Debates.version
|
38
|
+
s.add_development_dependency "decidim-assemblies", Decidim::Debates.version
|
38
39
|
s.add_development_dependency "decidim-dev", Decidim::Debates.version
|
39
40
|
end
|
@@ -3,24 +3,28 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Debates
|
5
5
|
class DebateType < Decidim::Api::Types::BaseObject
|
6
|
-
implements Decidim::Core::
|
6
|
+
implements Decidim::Core::TaxonomizableInterface
|
7
7
|
implements Decidim::Comments::CommentableInterface
|
8
8
|
implements Decidim::Core::AuthorableInterface
|
9
|
-
implements Decidim::Core::
|
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
|
22
|
+
|
23
|
+
def self.authorized?(object, context)
|
24
|
+
context[:debate] = object
|
25
|
+
|
26
|
+
super && allowed_to?(:read, :debate, object, context)
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -2,22 +2,19 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Debates
|
5
|
-
class DebatesType < Decidim::
|
6
|
-
implements Decidim::Core::ComponentInterface
|
7
|
-
|
5
|
+
class DebatesType < Decidim::Core::ComponentType
|
8
6
|
graphql_name "Debates"
|
9
7
|
description "A debates component of a participatory space."
|
10
8
|
|
11
|
-
field :
|
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
|
12
13
|
|
13
14
|
def debates
|
14
15
|
Debate.where(component: object).includes(:component)
|
15
16
|
end
|
16
17
|
|
17
|
-
field :debate, Decidim::Debates::DebateType, null: true do
|
18
|
-
argument :id, GraphQL::Types::ID, required: true
|
19
|
-
end
|
20
|
-
|
21
18
|
def debate(**args)
|
22
19
|
Debate.where(component: object).find_by(id: args[:id])
|
23
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 :
|
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 :
|
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
|
@@ -4,7 +4,7 @@ require "decidim/components/namer"
|
|
4
4
|
|
5
5
|
module Decidim
|
6
6
|
module Debates
|
7
|
-
class Seeds
|
7
|
+
class Seeds < Decidim::Seeds
|
8
8
|
attr_reader :participatory_space
|
9
9
|
|
10
10
|
def initialize(participatory_space:)
|
@@ -12,11 +12,6 @@ module Decidim
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call
|
15
|
-
admin_user = Decidim::User.find_by(
|
16
|
-
organization: participatory_space.organization,
|
17
|
-
email: "admin@example.org"
|
18
|
-
)
|
19
|
-
|
20
15
|
user = Decidim::User.find_by(
|
21
16
|
organization: participatory_space.organization,
|
22
17
|
email: "user@example.org"
|
@@ -49,7 +44,6 @@ module Decidim
|
|
49
44
|
end
|
50
45
|
params = {
|
51
46
|
component:,
|
52
|
-
category: participatory_space.categories.sample,
|
53
47
|
title: Decidim::Faker::Localized.sentence(word_count: 2),
|
54
48
|
description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
55
49
|
Decidim::Faker::Localized.paragraph(sentence_count: 3)
|
@@ -81,7 +75,6 @@ module Decidim
|
|
81
75
|
|
82
76
|
params = {
|
83
77
|
component:,
|
84
|
-
category: participatory_space.categories.sample,
|
85
78
|
title: Decidim::Faker::Localized.sentence(word_count: 2),
|
86
79
|
description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
87
80
|
Decidim::Faker::Localized.paragraph(sentence_count: 3)
|
@@ -18,6 +18,8 @@ FactoryBot.define do
|
|
18
18
|
instructions { generate_localized_description(:debate_instructions, skip_injection:) }
|
19
19
|
component { build(:debates_component, skip_injection:) }
|
20
20
|
author { component.try(:organization) }
|
21
|
+
comments_layout { "single_column" }
|
22
|
+
deleted_at { nil }
|
21
23
|
|
22
24
|
trait :open_ama do
|
23
25
|
start_time { 1.day.ago }
|
@@ -46,6 +48,12 @@ FactoryBot.define do
|
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
51
|
+
trait :hidden do
|
52
|
+
after :create do |debate, evaluator|
|
53
|
+
create(:moderation, hidden_at: Time.current, reportable: debate, skip_injection: evaluator.skip_injection)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
49
57
|
trait :closed do
|
50
58
|
closed_at { Time.current }
|
51
59
|
conclusions { generate_localized_description(:debate_conclusions, skip_injection:) }
|