decidim-proposals 0.20.1 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/proposals/admin/proposals.es6 +24 -11
  3. data/app/cells/decidim/proposals/cost_report/show.erb +35 -0
  4. data/app/cells/decidim/proposals/cost_report_cell.rb +42 -0
  5. data/app/cells/decidim/proposals/proposal_m_cell.rb +9 -1
  6. data/app/cells/decidim/proposals/proposal_tags/show.erb +12 -10
  7. data/app/cells/decidim/proposals/proposal_tags_cell.rb +5 -0
  8. data/app/commands/decidim/proposals/admin/answer_proposal.rb +24 -46
  9. data/app/commands/decidim/proposals/admin/assign_proposals_to_valuator.rb +61 -0
  10. data/app/commands/decidim/proposals/admin/create_proposal.rb +5 -0
  11. data/app/commands/decidim/proposals/admin/notify_proposal_answer.rb +85 -0
  12. data/app/commands/decidim/proposals/admin/publish_answers.rb +67 -0
  13. data/app/commands/decidim/proposals/admin/unassign_proposals_from_valuator.rb +62 -0
  14. data/app/commands/decidim/proposals/admin/update_proposal_scope.rb +75 -0
  15. data/app/controllers/concerns/decidim/proposals/admin/filterable.rb +82 -0
  16. data/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +16 -6
  17. data/app/controllers/decidim/proposals/admin/proposal_notes_controller.rb +8 -9
  18. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +105 -29
  19. data/app/controllers/decidim/proposals/admin/valuation_assignments_controller.rb +58 -0
  20. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +19 -3
  21. data/app/controllers/decidim/proposals/proposals_controller.rb +42 -7
  22. data/app/controllers/decidim/proposals/versions_controller.rb +4 -1
  23. data/app/events/decidim/proposals/admin/update_proposal_scope_event.rb +11 -0
  24. data/app/forms/decidim/proposals/admin/proposal_answer_form.rb +27 -2
  25. data/app/forms/decidim/proposals/admin/valuation_assignment_form.rb +37 -0
  26. data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +8 -0
  27. data/app/helpers/decidim/proposals/admin/filterable_helper.rb +17 -0
  28. data/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb +35 -0
  29. data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +63 -0
  30. data/app/helpers/decidim/proposals/admin/proposals_helper.rb +122 -0
  31. data/app/helpers/decidim/proposals/application_helper.rb +36 -25
  32. data/app/helpers/decidim/proposals/collaborative_draft_helper.rb +9 -9
  33. data/app/helpers/decidim/proposals/proposal_cells_helper.rb +1 -1
  34. data/app/helpers/decidim/proposals/proposals_helper.rb +18 -0
  35. data/app/models/decidim/proposals/proposal.rb +163 -16
  36. data/app/models/decidim/proposals/valuation_assignment.rb +24 -0
  37. data/app/permissions/decidim/proposals/admin/permissions.rb +77 -11
  38. data/app/presenters/decidim/proposals/admin_log/proposal_presenter.rb +1 -1
  39. data/app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb +51 -0
  40. data/app/presenters/decidim/proposals/admin_log/value_types/valuator_role_user_presenter.rb +19 -0
  41. data/app/presenters/decidim/proposals/collaborative_draft_presenter.rb +2 -28
  42. data/app/presenters/decidim/proposals/log/valuation_assignment_presenter.rb +22 -0
  43. data/app/presenters/decidim/proposals/proposal_presenter.rb +26 -1
  44. data/app/services/decidim/proposals/collaborative_draft_search.rb +18 -10
  45. data/app/services/decidim/proposals/proposal_search.rb +33 -40
  46. data/app/types/decidim/proposals/proposal_input_filter.rb +29 -0
  47. data/app/types/decidim/proposals/proposal_input_sort.rb +28 -0
  48. data/app/types/decidim/proposals/proposal_type.rb +35 -4
  49. data/app/types/decidim/proposals/proposals_type.rb +14 -17
  50. data/app/views/decidim/proposals/admin/proposal_answers/_form.html.erb +35 -0
  51. data/app/views/decidim/proposals/admin/proposal_notes/_form.html.erb +1 -1
  52. data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes.html.erb +1 -1
  53. data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +8 -2
  54. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +1 -1
  55. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +25 -17
  56. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_assign_to_valuator.html.erb +15 -0
  57. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_dropdown.html.erb +21 -1
  58. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_publish_answers.html.erb +14 -0
  59. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_scope-change.html.erb +25 -0
  60. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_unassign_from_valuator.html.erb +15 -0
  61. data/app/views/decidim/proposals/admin/proposals/index.html.erb +16 -7
  62. data/app/views/decidim/proposals/admin/proposals/publish_answers.js.erb +12 -0
  63. data/app/views/decidim/proposals/admin/proposals/show.html.erb +186 -0
  64. data/app/views/decidim/proposals/admin/proposals/update_category.js.erb +3 -2
  65. data/app/views/decidim/proposals/admin/proposals/update_scope.js.erb +27 -0
  66. data/app/views/decidim/proposals/collaborative_drafts/_filters.html.erb +3 -3
  67. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +1 -1
  68. data/app/views/decidim/proposals/proposals/_filters.html.erb +12 -12
  69. data/app/views/decidim/proposals/proposals/_proposal_badge.html.erb +1 -4
  70. data/app/views/decidim/proposals/proposals/_proposal_preview.html.erb +1 -1
  71. data/app/views/decidim/proposals/proposals/_vote_button.html.erb +1 -1
  72. data/app/views/decidim/proposals/proposals/index.html.erb +1 -1
  73. data/app/views/decidim/proposals/proposals/new.html.erb +1 -1
  74. data/app/views/decidim/proposals/proposals/show.html.erb +17 -23
  75. data/config/locales/ar.yml +69 -17
  76. data/config/locales/ca.yml +113 -18
  77. data/config/locales/cs.yml +123 -31
  78. data/config/locales/de.yml +38 -18
  79. data/config/locales/el.yml +1 -0
  80. data/config/locales/en.yml +112 -17
  81. data/config/locales/es-MX.yml +112 -17
  82. data/config/locales/es-PY.yml +112 -17
  83. data/config/locales/es.yml +113 -18
  84. data/config/locales/eu.yml +38 -18
  85. data/config/locales/fi-plain.yml +113 -18
  86. data/config/locales/fi.yml +113 -18
  87. data/config/locales/fr.yml +38 -18
  88. data/config/locales/gl.yml +38 -18
  89. data/config/locales/hu.yml +112 -17
  90. data/config/locales/id-ID.yml +38 -18
  91. data/config/locales/is-IS.yml +25 -15
  92. data/config/locales/it.yml +38 -18
  93. data/config/locales/nl.yml +43 -18
  94. data/config/locales/no.yml +66 -18
  95. data/config/locales/pl.yml +38 -18
  96. data/config/locales/pt-BR.yml +39 -19
  97. data/config/locales/pt.yml +39 -19
  98. data/config/locales/ru.yml +25 -17
  99. data/config/locales/sv.yml +39 -18
  100. data/config/locales/tr-TR.yml +38 -18
  101. data/config/locales/uk.yml +25 -17
  102. data/db/migrate/20200203111239_add_proposal_valuation_assignments.rb +12 -0
  103. data/db/migrate/20200210135152_add_costs_to_proposals.rb +9 -0
  104. data/db/migrate/20200212120110_sync_proposals_state_with_amendments_state.rb +28 -0
  105. data/db/migrate/20200227175922_add_state_published_at_to_proposals.rb +7 -0
  106. data/db/migrate/20200306123652_publish_existing_proposals_state.rb +15 -0
  107. data/lib/decidim/proposals.rb +1 -0
  108. data/lib/decidim/proposals/admin_engine.rb +7 -3
  109. data/lib/decidim/proposals/component.rb +39 -19
  110. data/lib/decidim/proposals/engine.rb +1 -1
  111. data/lib/decidim/proposals/test/factories.rb +55 -0
  112. data/lib/decidim/proposals/valuatable.rb +21 -0
  113. data/lib/decidim/proposals/version.rb +1 -1
  114. metadata +53 -36
  115. data/app/views/decidim/proposals/admin/proposal_answers/edit.html.erb +0 -22
  116. data/app/views/decidim/proposals/admin/proposal_notes/index.html.erb +0 -3
  117. data/app/views/decidim/proposals/admin/shared/_info_proposal.html.erb +0 -20
  118. data/app/views/decidim/proposals/proposal_widgets/show.html.erb +0 -4
@@ -73,6 +73,21 @@ tr:
73
73
  one: Oy
74
74
  other: oy
75
75
  decidim:
76
+ admin:
77
+ filters:
78
+ is_emendation_true:
79
+ label: tip
80
+ values:
81
+ 'false': Teklif
82
+ 'true': Değişiklikler
83
+ state_eq:
84
+ values:
85
+ evaluating: değerlendirilmesi
86
+ withdrawn: çekilmiş
87
+ state_null:
88
+ label: Belirtmek, bildirmek
89
+ values:
90
+ 'true': Cevaplanmadı
76
91
  components:
77
92
  proposals:
78
93
  actions:
@@ -193,7 +208,6 @@ tr:
193
208
  email_subject: Takip ettiğiniz bir teklif değerlendiriliyor
194
209
  notification_title: <a href="%{resource_path}">%{resource_title}</a> teklifi değerlendiriliyor.
195
210
  proposal_mentioned:
196
- email_intro: Öneriniz "%{mentioned_proposal_title}" söz edilmiştir <a href="%{resource_path}">bu alanda</a> yorumlardaki.
197
211
  email_outro: Bu bildirimi, "%{resource_title}" ın bir yazarı olduğunuz için aldınız.
198
212
  email_subject: Teklifinizin "%{mentioned_proposal_title}" olduğu belirtildi
199
213
  notification_title: Öneriniz "%{mentioned_proposal_title}" söz edilmiştir <a href="%{resource_path}">bu alanda</a> yorumlardaki.
@@ -223,6 +237,8 @@ tr:
223
237
  email_outro: Bu bildirimi aldınız çünkü teklifin yazarı sizsiniz.
224
238
  email_subject: '%{resource_title} teklif kategorisi güncellendi'
225
239
  notification_title: <a href="%{resource_path}">%{resource_title}</a> teklif kategorisi bir yönetici tarafından güncellendi.
240
+ proposal_update_scope:
241
+ email_outro: Bu bildirimi aldınız çünkü teklifin yazarı sizsiniz.
226
242
  voting_enabled:
227
243
  email_intro: 'Teklifleri %{participatory_space_title}oylayabilirsiniz! Bu sayfaya katılmaya başlayın:'
228
244
  email_outro: Bu bildirimi, %{participatory_space_title}izlediğiniz için aldınız. Önceki bağlantıyı takip ederek bildirimleri almayı durdurabilirsiniz.
@@ -289,12 +305,10 @@ tr:
289
305
  see_all: Tümünü gör (%{count})
290
306
  proposals:
291
307
  actions:
292
- answer: Cevap
293
308
  edit_proposal: Teklifi düzenle
294
309
  import: Başka bir bileşenden içe aktar
295
310
  new: Yeni teklif
296
311
  participatory_texts: Katılımcı metinler
297
- private_notes: Özel notlar
298
312
  title: Eylemler
299
313
  admin:
300
314
  actions:
@@ -338,7 +352,7 @@ tr:
338
352
  update:
339
353
  success: Katılımcı metin başarıyla güncellendi.
340
354
  proposal_answers:
341
- edit:
355
+ form:
342
356
  accepted: Kabul edilmiş
343
357
  answer_proposal: Cevap
344
358
  evaluating: değerlendirilmesi
@@ -374,6 +388,7 @@ tr:
374
388
  change_category: Kategoriyi değiştir
375
389
  merge: Yeni biriyle birleştir
376
390
  merge_button: birleşmek
391
+ publish: Yayınla
377
392
  select_component: Bir bileşen seç
378
393
  selected: seçilmiş
379
394
  split: Bölünmüş teklifler
@@ -383,11 +398,19 @@ tr:
383
398
  new:
384
399
  create: yaratmak
385
400
  title: Teklif oluştur
401
+ publish_answers:
402
+ select_a_proposal: Lütfen bir teklif seçin
403
+ show:
404
+ authors: Yazarlar
405
+ body: Vücut
406
+ created_at: Oluşturulma tarihi
407
+ proposals: Teklif
408
+ votes_count: Oy sayısı
386
409
  update_category:
387
- invalid: 'Bu teklifler zaten %{category} kategorisine sahipti: %{proposals}.'
388
410
  select_a_category: Lütfen bir kategori seçin
389
411
  select_a_proposal: Lütfen bir teklif seçin
390
- success: 'Teklifler başarıyla %{category} kategorisine güncellendi: %{proposals}.'
412
+ update_scope:
413
+ select_a_proposal: Lütfen bir teklif seçin
391
414
  proposals_imports:
392
415
  create:
393
416
  invalid: Teklifleri içe aktarırken bir sorun oluştu
@@ -405,12 +428,6 @@ tr:
405
428
  create:
406
429
  invalid: Seçilen teklifleri bölen bir hata oluştu.
407
430
  success: Teklifleri başarılı bir şekilde yenilere ayırdı.
408
- shared:
409
- info_proposal:
410
- body: Vücut
411
- created_at: Oluşturulma tarihi
412
- proposal_votes_count: Oy sayısı
413
- proposals: Teklif
414
431
  admin_log:
415
432
  proposal:
416
433
  answer: "%{user_name} , %{space_name} uzayda %{resource_name} teklifi yanıtladı"
@@ -425,17 +442,21 @@ tr:
425
442
  rejected: Reddedilen
426
443
  withdrawn: çekilmiş
427
444
  application_helper:
445
+ filter_category_values:
446
+ all: Herşey
428
447
  filter_origin_values:
429
448
  all: Herşey
430
449
  citizens: Vatandaşlar
431
450
  meetings: Toplantılar
432
451
  official: Resmi
433
452
  user_groups: Kullanıcı Grupları
453
+ filter_scope_values:
454
+ all: Herşey
434
455
  filter_state_values:
435
456
  accepted: Kabul edilmiş
436
457
  all: Herşey
437
458
  evaluating: değerlendirilmesi
438
- except_rejected: Reddedilenlerin tümü hariç
459
+ not_answered: Cevaplanmadı
439
460
  rejected: Reddedilen
440
461
  filter_type_values:
441
462
  all: Herşey
@@ -484,10 +505,10 @@ tr:
484
505
  all: Herşey
485
506
  amendment: Değişiklikler
486
507
  category: Kategori
487
- category_prompt: Kategori İstemi
488
508
  open: Açık
489
509
  published: Yayınlanan
490
510
  related_to: İle ilgili
511
+ scope: kapsam
491
512
  search: Arama
492
513
  state: Belirtmek, bildirmek
493
514
  withdrawn: çekilmiş
@@ -636,11 +657,12 @@ tr:
636
657
  filters:
637
658
  amendment_type: tip
638
659
  category: Kategori
639
- category_prompt: bir kategori seç
640
660
  origin: Menşei
641
661
  related_to: İle ilgili
662
+ scope: kapsam
642
663
  search: Arama
643
664
  state: Belirtmek, bildirmek
665
+ type: tip
644
666
  voted: oy
645
667
  filters_small_view:
646
668
  close_modal: Yakın kalıcı
@@ -680,6 +702,7 @@ tr:
680
702
  creation_date: 'Oluşturma: %{date}'
681
703
  view_proposal: Teklifi görüntüle
682
704
  show:
705
+ answer: Cevap
683
706
  back_to: Geri
684
707
  edit_proposal: Teklifi düzenle
685
708
  endorsements_list: Onay Listesi
@@ -696,9 +719,6 @@ tr:
696
719
  withdraw_btn_hint: Herhangi bir destek almadığınız sürece fikrinizi değiştirirseniz teklifinizi geri çekebilirsiniz. Teklif silinmemiş, iptal edilen teklifler listesinde görünecektir.
697
720
  withdraw_confirmation: Bu teklifi geri çektiğinizden emin misiniz?
698
721
  withdraw_proposal: Teklifi geri çek
699
- tags:
700
- changed_from: "(bir yönetici tarafından <u>%{previous_category}</u> değiştirildi)"
701
- filed_as: Olarak dosyalandı
702
722
  vote_button:
703
723
  already_voted: Çoktan oy verildi
704
724
  already_voted_hover: Unvote
@@ -55,6 +55,18 @@ uk:
55
55
  many: Голосів
56
56
  other: Голосів
57
57
  decidim:
58
+ admin:
59
+ filters:
60
+ is_emendation_true:
61
+ values:
62
+ 'false': Пропозиції
63
+ state_eq:
64
+ values:
65
+ evaluating: Розглядається
66
+ withdrawn: Відкликана
67
+ state_null:
68
+ values:
69
+ 'true': Без відповідей
58
70
  components:
59
71
  proposals:
60
72
  actions:
@@ -122,7 +134,6 @@ uk:
122
134
  email_subject: Пропозиція, за якою ви стежите, зараз розглядається
123
135
  notification_title: Пропозиція <a href="%{resource_path}">%{resource_title}</a> розглядається.
124
136
  proposal_mentioned:
125
- email_intro: Вашу пропозицію "%{mentioned_proposal_title}" було згадано в коментарях <a href="%{resource_path}">в цьому просторі</a>.
126
137
  email_subject: Вашу пропозицію "%{mentioned_proposal_title}" було згадано
127
138
  notification_title: Вашу пропозицію "%{mentioned_proposal_title}" було згадано в коментарях <a href="%{resource_path}">в цьому просторі</a>.
128
139
  proposal_published:
@@ -143,6 +154,8 @@ uk:
143
154
  email_outro: Ви отримали це сповіщення, оскільки ви є автором цієї пропозиції.
144
155
  email_subject: Категорію пропозиції %{resource_title} було оновлено
145
156
  notification_title: Адміністратор оновив категорію пропозиції <a href="%{resource_path}">%{resource_title}</a>.
157
+ proposal_update_scope:
158
+ email_outro: Ви отримали це сповіщення, оскільки ви є автором цієї пропозиції.
146
159
  voting_enabled:
147
160
  email_intro: 'Ви можете голосувати щодо пропозицій у %{participatory_space_title}! Почніть брати участь зі сторінки:'
148
161
  email_outro: Ви отримали це сповіщення, тому що ви стежите за %{participatory_space_title}. Ви можете відписатися від цих сповіщень, перейшовши за наведеним вище посиланням.
@@ -154,10 +167,8 @@ uk:
154
167
  proposals: Пропозиції
155
168
  proposals:
156
169
  actions:
157
- answer: Відповісти
158
170
  import: Запозичити з іншої складової
159
171
  new: Додати нову пропозицію
160
- private_notes: Приватні примітки
161
172
  title: Дії
162
173
  admin:
163
174
  actions:
@@ -169,7 +180,7 @@ uk:
169
180
  proposal:
170
181
  name: Пропозиція
171
182
  proposal_answers:
172
- edit:
183
+ form:
173
184
  accepted: Прийнято
174
185
  answer_proposal: Відповісти
175
186
  evaluating: Розглядається
@@ -204,11 +215,17 @@ uk:
204
215
  new:
205
216
  create: Внести
206
217
  title: Створити пропозицію
218
+ publish_answers:
219
+ select_a_proposal: Будь ласка, оберіть пропозицію
220
+ show:
221
+ created_at: Дата створення
222
+ proposals: Пропозиції
223
+ votes_count: Кількість голосів
207
224
  update_category:
208
- invalid: 'Ці пропозиції вже відносились до категорії %{category}: %{proposals}.'
209
225
  select_a_category: Будь ласка, виберіть категорію
210
226
  select_a_proposal: Будь ласка, оберіть пропозицію
211
- success: 'Пропозиції успішно перенесені до категорії %{category}: %{proposals}.'
227
+ update_scope:
228
+ select_a_proposal: Будь ласка, оберіть пропозицію
212
229
  proposals_imports:
213
230
  create:
214
231
  invalid: При запозиченні цих пропозицій сталася помилка
@@ -218,12 +235,6 @@ uk:
218
235
  no_components: У цьому просторі співучасті немає інших складових пропозицій, звідки можна було б запозичити пропозиції.
219
236
  select_component: Будь ласка, оберіть складову
220
237
  select_states: Перевірте стани пропозицій, які бажаєте запозичити
221
- shared:
222
- info_proposal:
223
- body: Основний текст
224
- created_at: Дата створення
225
- proposal_votes_count: Кількість голосів
226
- proposals: Пропозиції
227
238
  admin_log:
228
239
  proposal:
229
240
  answer: "%{user_name} відповів на пропозицію %{resource_name} у просторі %{space_name}"
@@ -241,7 +252,7 @@ uk:
241
252
  citizens: Громадяни
242
253
  official: Службове
243
254
  filter_state_values:
244
- except_rejected: Усі, окрім відхилених
255
+ not_answered: Без відповідей
245
256
  create:
246
257
  error: При спробі збереження цієї пропозиції сталися помилки.
247
258
  success: Пропозицію успішно створено. Збережено як чернетку.
@@ -303,7 +314,6 @@ uk:
303
314
  comments: Коментарі
304
315
  filters:
305
316
  category: Категорія
306
- category_prompt: Оберіть категорію
307
317
  origin: Джерело
308
318
  related_to: Пов'язане з
309
319
  search: Шукати
@@ -345,6 +355,7 @@ uk:
345
355
  creation_date: 'Внесено: %{date}'
346
356
  view_proposal: Переглянути пропозицію
347
357
  show:
358
+ answer: Відповісти
348
359
  edit_proposal: Редагувати пропозицію
349
360
  endorsements_list: Перелік тих, хто підтримав
350
361
  proposal_accepted_reason: 'Ця пропозиція була прийнята, тому що:'
@@ -354,9 +365,6 @@ uk:
354
365
  withdraw_btn_hint: Ви можете зняти свою пропозицію, якщо ви передумали, доки ви не отримали жодної підтримки. Пропозиція не видаляється, вона з'явиться у списку відкликаних пропозицій.
355
366
  withdraw_confirmation: Ви впевнені, що бажаєте зняти цю пропозицію?
356
367
  withdraw_proposal: Зняти пропозицію
357
- tags:
358
- changed_from: "(перенесено з <u>%{previous_category}</u> адміністратором)"
359
- filed_as: Відмічено як
360
368
  vote_button:
361
369
  already_voted: Вже проголосували
362
370
  already_voted_hover: Скасувати голос
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddProposalValuationAssignments < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :decidim_proposals_valuation_assignments do |t|
6
+ t.references :decidim_proposal, null: false, index: { name: "decidim_proposals_valuation_assignment_proposal" }
7
+ t.references :valuator_role, polymorphic: true, null: false, index: { name: "decidim_proposals_valuation_assignment_valuator_role" }
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddCostsToProposals < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :decidim_proposals_proposals, :cost, :decimal
6
+ add_column :decidim_proposals_proposals, :cost_report, :jsonb
7
+ add_column :decidim_proposals_proposals, :execution_period, :jsonb
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SyncProposalsStateWithAmendmentsState < ActiveRecord::Migration[5.2]
4
+ def up
5
+ execute <<-SQL.squish
6
+ UPDATE decidim_proposals_proposals AS proposals
7
+ SET state = amendments.state
8
+ FROM decidim_amendments AS amendments
9
+ WHERE
10
+ proposals.state IS NULL AND
11
+ amendments.decidim_emendation_type = 'Decidim::Proposals::Proposal' AND
12
+ amendments.decidim_emendation_id = proposals.id AND
13
+ amendments.state IS NOT NULL
14
+ SQL
15
+ end
16
+
17
+ def down
18
+ execute <<-SQL.squish
19
+ UPDATE decidim_proposals_proposals AS proposals
20
+ SET state = NULL
21
+ FROM decidim_amendments AS amendments
22
+ WHERE
23
+ amendments.decidim_emendation_type = 'Decidim::Proposals::Proposal' AND
24
+ amendments.decidim_emendation_id = proposals.id AND
25
+ amendments.state IS NOT NULL
26
+ SQL
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddStatePublishedAtToProposals < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :decidim_proposals_proposals, :state_published_at, :datetime
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PublishExistingProposalsState < ActiveRecord::Migration[5.2]
4
+ def up
5
+ execute <<-SQL.squish
6
+ UPDATE decidim_proposals_proposals SET state_published_at = COALESCE(answered_at, published_at) WHERE state IS NOT NULL
7
+ SQL
8
+ end
9
+
10
+ def down
11
+ execute <<-SQL.squish
12
+ UPDATE decidim_proposals_proposals SET state_published_at = NULL
13
+ SQL
14
+ end
15
+ end
@@ -17,6 +17,7 @@ module Decidim
17
17
  autoload :ParticipatoryTextSection, "decidim/proposals/participatory_text_section"
18
18
  autoload :DocToMarkdown, "decidim/proposals/doc_to_markdown"
19
19
  autoload :OdtToMarkdown, "decidim/proposals/odt_to_markdown"
20
+ autoload :Valuatable, "decidim/proposals/valuatable"
20
21
 
21
22
  include ActiveSupport::Configurable
22
23
 
@@ -10,15 +10,19 @@ module Decidim
10
10
  paths["lib/tasks"] = nil
11
11
 
12
12
  routes do
13
- resources :proposals, only: [:index, :new, :create, :edit, :update] do
14
- post :update_category, on: :collection
13
+ resources :proposals, only: [:show, :index, :new, :create, :edit, :update] do
14
+ resources :valuation_assignments, only: [:destroy]
15
15
  collection do
16
+ post :update_category
17
+ post :publish_answers
18
+ post :update_scope
16
19
  resource :proposals_import, only: [:new, :create]
17
20
  resource :proposals_merge, only: [:create]
18
21
  resource :proposals_split, only: [:create]
22
+ resource :valuation_assignment, only: [:create, :destroy]
19
23
  end
20
24
  resources :proposal_answers, only: [:edit, :update]
21
- resources :proposal_notes, only: [:index, :create]
25
+ resources :proposal_notes, only: [:create]
22
26
  end
23
27
 
24
28
  resources :participatory_texts, only: [:index] do
@@ -34,12 +34,14 @@ Decidim.register_component(:proposals) do |component|
34
34
  settings.attribute :comments_enabled, type: :boolean, default: true
35
35
  settings.attribute :geocoding_enabled, type: :boolean, default: false
36
36
  settings.attribute :attachments_allowed, type: :boolean, default: false
37
+ settings.attribute :allow_card_image, type: :boolean, default: false
37
38
  settings.attribute :resources_permissions_enabled, type: :boolean, default: true
38
39
  settings.attribute :collaborative_drafts_enabled, type: :boolean, default: false
39
40
  settings.attribute :participatory_texts_enabled, type: :boolean, default: false
40
41
  settings.attribute :amendments_enabled, type: :boolean, default: false
41
42
  settings.attribute :amendments_wizard_help_text, type: :text, translated: true, editor: true, required: false
42
43
  settings.attribute :announcement, type: :text, translated: true, editor: true
44
+ settings.attribute :new_proposal_body_template, type: :text, translated: true, editor: false, required: false
43
45
  settings.attribute :new_proposal_help_text, type: :text, translated: true, editor: true
44
46
  settings.attribute :proposal_wizard_step_1_help_text, type: :text, translated: true, editor: true
45
47
  settings.attribute :proposal_wizard_step_2_help_text, type: :text, translated: true, editor: true
@@ -56,6 +58,8 @@ Decidim.register_component(:proposals) do |component|
56
58
  settings.attribute :comments_blocked, type: :boolean, default: false
57
59
  settings.attribute :creation_enabled, type: :boolean
58
60
  settings.attribute :proposal_answering_enabled, type: :boolean, default: true
61
+ settings.attribute :publish_answers_immediately, type: :boolean, default: true
62
+ settings.attribute :answers_with_costs, type: :boolean, default: false
59
63
  settings.attribute :amendment_creation_enabled, type: :boolean, default: true
60
64
  settings.attribute :amendment_reaction_enabled, type: :boolean, default: true
61
65
  settings.attribute :amendment_promotion_enabled, type: :boolean, default: true
@@ -86,7 +90,7 @@ Decidim.register_component(:proposals) do |component|
86
90
  Decidim::Proposals::FilteredProposals.for(components, start_at, end_at).accepted.not_hidden.count
87
91
  end
88
92
 
89
- component.register_stat :votes_count, priority: Decidim::StatsRegistry::HIGH_PRIORITY do |components, start_at, end_at|
93
+ component.register_stat :supports_count, priority: Decidim::StatsRegistry::HIGH_PRIORITY do |components, start_at, end_at|
90
94
  proposals = Decidim::Proposals::FilteredProposals.for(components, start_at, end_at).published.not_hidden
91
95
  Decidim::Proposals::ProposalVote.where(proposal: proposals).count
92
96
  end
@@ -101,12 +105,25 @@ Decidim.register_component(:proposals) do |component|
101
105
  Decidim::Comments::Comment.where(root_commentable: proposals).count
102
106
  end
103
107
 
108
+ component.register_stat :followers_count, tag: :followers, priority: Decidim::StatsRegistry::LOW_PRIORITY do |components, start_at, end_at|
109
+ proposals_ids = Decidim::Proposals::FilteredProposals.for(components, start_at, end_at).published.not_hidden.pluck(:id)
110
+ Decidim::Follow.where(decidim_followable_type: "Decidim::Proposals::Proposal", decidim_followable_id: proposals_ids).count
111
+ end
112
+
104
113
  component.exports :proposals do |exports|
105
- exports.collection do |component_instance|
106
- Decidim::Proposals::Proposal
107
- .published
108
- .where(component: component_instance)
109
- .includes(:category, component: { participatory_space: :organization })
114
+ exports.collection do |component_instance, user|
115
+ space = component_instance.participatory_space
116
+
117
+ collection = Decidim::Proposals::Proposal
118
+ .published
119
+ .where(component: component_instance)
120
+ .includes(:category, :component)
121
+
122
+ if space.user_roles(:valuator).where(user: user).any?
123
+ collection.with_valuation_assigned_to(user, space)
124
+ else
125
+ collection
126
+ end
110
127
  end
111
128
 
112
129
  exports.include_in_open_data = true
@@ -166,15 +183,17 @@ Decidim.register_component(:proposals) do |component|
166
183
  end
167
184
 
168
185
  5.times do |n|
169
- state, answer = if n > 3
170
- ["accepted", Decidim::Faker::Localized.sentence(10)]
171
- elsif n > 2
172
- ["rejected", nil]
173
- elsif n > 1
174
- ["evaluating", nil]
175
- else
176
- [nil, nil]
177
- end
186
+ state, answer, state_published_at = if n > 3
187
+ ["accepted", Decidim::Faker::Localized.sentence(10), Time.current]
188
+ elsif n > 2
189
+ ["rejected", nil, Time.current]
190
+ elsif n > 1
191
+ ["evaluating", nil, Time.current]
192
+ elsif n.positive?
193
+ ["accepted", Decidim::Faker::Localized.sentence(10), nil]
194
+ else
195
+ [nil, nil, nil]
196
+ end
178
197
 
179
198
  params = {
180
199
  component: component,
@@ -184,7 +203,8 @@ Decidim.register_component(:proposals) do |component|
184
203
  body: Faker::Lorem.paragraphs(2).join("\n"),
185
204
  state: state,
186
205
  answer: answer,
187
- answered_at: Time.current,
206
+ answered_at: state.present? ? Time.current : nil,
207
+ state_published_at: state_published_at,
188
208
  published_at: Time.current
189
209
  }
190
210
 
@@ -247,7 +267,7 @@ Decidim.register_component(:proposals) do |component|
247
267
  scope: Faker::Boolean.boolean(0.5) ? global : scopes.sample,
248
268
  title: "#{proposal.title} #{Faker::Lorem.sentence(1)}",
249
269
  body: "#{proposal.body} #{Faker::Lorem.sentence(3)}",
250
- state: nil,
270
+ state: "evaluating",
251
271
  answer: nil,
252
272
  answered_at: Time.current,
253
273
  published_at: Time.current
@@ -290,11 +310,11 @@ Decidim.register_component(:proposals) do |component|
290
310
  about: Faker::Lorem.paragraph(2)
291
311
  )
292
312
 
293
- Decidim::Proposals::ProposalVote.create!(proposal: proposal, author: author) unless proposal.answered? && proposal.rejected?
313
+ Decidim::Proposals::ProposalVote.create!(proposal: proposal, author: author) unless proposal.published_state? && proposal.rejected?
294
314
  Decidim::Proposals::ProposalVote.create!(proposal: emendation, author: author) if emendation
295
315
  end
296
316
 
297
- unless proposal.answered? && proposal.rejected?
317
+ unless proposal.published_state? && proposal.rejected?
298
318
  (n * 2).times do |index|
299
319
  email = "endorsement-author-#{participatory_space.underscored_name}-#{participatory_space.id}-#{n}-endr#{index}@example.org"
300
320
  name = "#{Faker::Name.name} #{participatory_space.id} #{n} endr#{index}"