decidim-debates 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/debates/debate_activity_cell.rb +4 -0
  3. data/app/cells/decidim/debates/debate_m/data.erb +10 -8
  4. data/app/cells/decidim/debates/debate_m/footer.erb +5 -0
  5. data/app/cells/decidim/debates/debate_m_cell.rb +24 -2
  6. data/app/commands/decidim/debates/admin/close_debate.rb +54 -0
  7. data/app/commands/decidim/debates/admin/create_debate.rb +4 -2
  8. data/app/commands/decidim/debates/admin/update_debate.rb +5 -2
  9. data/app/commands/decidim/debates/close_debate.rb +58 -0
  10. data/app/commands/decidim/debates/create_debate.rb +17 -12
  11. data/app/commands/decidim/debates/update_debate.rb +56 -0
  12. data/app/controllers/decidim/debates/admin/debate_closes_controller.rb +43 -0
  13. data/app/controllers/decidim/debates/admin/debates_controller.rb +4 -2
  14. data/app/controllers/decidim/debates/debates_controller.rb +70 -9
  15. data/app/controllers/decidim/debates/orderable.rb +41 -0
  16. data/app/controllers/decidim/debates/versions_controller.rb +16 -0
  17. data/app/controllers/decidim/debates/widgets_controller.rb +19 -0
  18. data/app/events/decidim/debates/close_debate_event.rb +15 -0
  19. data/app/forms/decidim/debates/admin/close_debate_form.rb +34 -0
  20. data/app/forms/decidim/debates/admin/debate_form.rb +5 -1
  21. data/app/forms/decidim/debates/close_debate_form.rb +39 -0
  22. data/app/forms/decidim/debates/debate_form.rb +27 -1
  23. data/app/helpers/decidim/debates/admin/application_helper.rb +13 -0
  24. data/app/helpers/decidim/debates/application_helper.rb +37 -1
  25. data/app/models/decidim/debates/debate.rb +60 -8
  26. data/app/permissions/decidim/debates/admin/permissions.rb +3 -1
  27. data/app/permissions/decidim/debates/permissions.rb +28 -0
  28. data/app/presenters/decidim/debates/admin_log/debate_presenter.rb +6 -2
  29. data/app/presenters/decidim/debates/admin_log/value_types/debate_title_description_presenter.rb +20 -0
  30. data/app/presenters/decidim/debates/debate_presenter.rb +62 -7
  31. data/app/presenters/decidim/debates/log/resource_presenter.rb +18 -0
  32. data/app/presenters/decidim/debates/official_author_presenter.rb +1 -29
  33. data/app/services/decidim/debates/debate_search.rb +13 -23
  34. data/app/services/decidim/debates/diff_renderer.rb +27 -0
  35. data/app/views/decidim/debates/admin/debate_closes/edit.html.erb +17 -0
  36. data/app/views/decidim/debates/admin/debates/_form.html.erb +4 -4
  37. data/app/views/decidim/debates/admin/debates/index.html.erb +7 -1
  38. data/app/views/decidim/debates/debates/_close_debate_modal.html.erb +13 -0
  39. data/app/views/decidim/debates/debates/_debates.html.erb +7 -0
  40. data/app/views/decidim/debates/debates/_filters.html.erb +15 -13
  41. data/app/views/decidim/debates/debates/_form.html.erb +19 -0
  42. data/app/views/decidim/debates/debates/edit.html.erb +22 -0
  43. data/app/views/decidim/debates/debates/new.html.erb +1 -22
  44. data/app/views/decidim/debates/debates/show.html.erb +81 -11
  45. data/app/views/decidim/debates/versions/index.html.erb +8 -0
  46. data/app/views/decidim/debates/versions/show.html.erb +10 -0
  47. data/config/locales/am-ET.yml +1 -0
  48. data/config/locales/ar.yml +2 -1
  49. data/config/locales/bg.yml +15 -0
  50. data/config/locales/ca.yml +70 -1
  51. data/config/locales/cs.yml +70 -1
  52. data/config/locales/da.yml +1 -0
  53. data/config/locales/de.yml +48 -1
  54. data/config/locales/el.yml +2 -1
  55. data/config/locales/en.yml +70 -1
  56. data/config/locales/eo.yml +1 -0
  57. data/config/locales/es-MX.yml +70 -1
  58. data/config/locales/es-PY.yml +70 -1
  59. data/config/locales/es.yml +70 -1
  60. data/config/locales/et.yml +1 -0
  61. data/config/locales/eu.yml +2 -1
  62. data/config/locales/fi-plain.yml +70 -1
  63. data/config/locales/fi.yml +70 -1
  64. data/config/locales/fr-CA.yml +70 -1
  65. data/config/locales/fr.yml +70 -1
  66. data/config/locales/gl.yml +2 -1
  67. data/config/locales/hr.yml +1 -0
  68. data/config/locales/hu.yml +24 -1
  69. data/config/locales/id-ID.yml +2 -1
  70. data/config/locales/is-IS.yml +2 -1
  71. data/config/locales/is.yml +102 -0
  72. data/config/locales/it.yml +33 -1
  73. data/config/locales/ja-JP.yml +63 -20
  74. data/config/locales/ja.yml +221 -0
  75. data/config/locales/ko-KR.yml +1 -0
  76. data/config/locales/ko.yml +1 -0
  77. data/config/locales/lt.yml +1 -0
  78. data/config/locales/{lv-LV.yml → lv.yml} +0 -0
  79. data/config/locales/mt.yml +1 -0
  80. data/config/locales/nl.yml +46 -1
  81. data/config/locales/no.yml +42 -1
  82. data/config/locales/om-ET.yml +1 -0
  83. data/config/locales/pl.yml +58 -6
  84. data/config/locales/pt-BR.yml +2 -1
  85. data/config/locales/pt.yml +18 -1
  86. data/config/locales/ro-RO.yml +18 -1
  87. data/config/locales/ru.yml +2 -1
  88. data/config/locales/sk.yml +2 -1
  89. data/config/locales/sl.yml +13 -1
  90. data/config/locales/so-SO.yml +1 -0
  91. data/config/locales/sv.yml +51 -1
  92. data/config/locales/ti-ER.yml +1 -0
  93. data/config/locales/tr-TR.yml +2 -1
  94. data/config/locales/uk.yml +2 -1
  95. data/config/locales/vi-VN.yml +1 -0
  96. data/config/locales/vi.yml +1 -0
  97. data/config/locales/zh-CN.yml +218 -0
  98. data/config/locales/zh-TW.yml +1 -0
  99. data/db/migrate/20200703134657_close_debates.rb +9 -0
  100. data/db/migrate/20200708072042_fix_debates_i18n_fields.rb +48 -0
  101. data/db/migrate/20200716143929_add_endorsable_to_debates.rb +8 -0
  102. data/db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb +14 -0
  103. data/db/migrate/20200902133452_add_cached_comment_metadata_to_debates.rb +23 -0
  104. data/lib/decidim/debates/admin_engine.rb +3 -1
  105. data/lib/decidim/debates/component.rb +44 -1
  106. data/lib/decidim/debates/engine.rb +7 -1
  107. data/lib/decidim/debates/test/factories.rb +62 -6
  108. data/lib/decidim/debates/version.rb +1 -1
  109. metadata +57 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ddc30c91b8b1754325501a2d193748df71ddf35344a6162a56784189faf5e37b
4
- data.tar.gz: 1baf08c4025770f4d6bfce209a279ea90312d05118857b8b96d61c6eb8c0416f
3
+ metadata.gz: edefc8e041f33c9f126ccaaacb50e5d835a6ecba57e0599cc328eae2f291d26f
4
+ data.tar.gz: 59623d46c9aa336fd27d39cd7dc1855595e3e011fc1acfef6863e1a00ae86554
5
5
  SHA512:
6
- metadata.gz: 56c4b2858559a7a96eb0fbfd727b9c352ec109083255f403f4433752372d71a60843f558e98fa3bc47fed4427aa27c70fcb986bdcdcd11ffebf07238ae54c613
7
- data.tar.gz: e2dc00d6efd0687e86a44119c35d28e1e14c08eca9a1062762d0681e5e238bc4b6af8944f1e66a2c0dc93ade4aa007207f1623199930567ec986e9b2d8eca1d0
6
+ metadata.gz: 6bccf40ec83ec976d942ee707cf73b163888f4e2f0d7832c4c59e5698bf111c3f82f9e04255a5a01240d4f8170ee745f091804cb6c649d8eaed82e3dcf2664a5
7
+ data.tar.gz: a8c5efc3714e613dfe142caaa076949efb3fc5ea74bf9cca7bfb6b824054943c2046e197e92c50887c2fcb3d20dd329ee87bd0a08adaffc26e711415343b971d
@@ -10,6 +10,10 @@ module Decidim
10
10
  link: participatory_space_link
11
11
  )
12
12
  end
13
+
14
+ def resource_link_text
15
+ Decidim::Debates::DebatePresenter.new(resource).title
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -1,8 +1,10 @@
1
- <div class="card__icondata">
2
- <ul class="card-data">
3
- <li class="card-data__item">
4
- <%= icon "datetime", class: "icon--big", role: "img", aria_label: t("decidim.debates.debates.show.date") %>
5
- </li>
6
- <%= debate_date %>
7
- </ul>
8
- </div>
1
+ <% if debate_date.present? %>
2
+ <div class="card__icondata">
3
+ <ul class="card-data">
4
+ <li class="card-data__item">
5
+ <%= icon "datetime", class: "icon--big", role: "img", aria_label: t("decidim.debates.debates.show.date") %>
6
+ </li>
7
+ <%= debate_date %>
8
+ </ul>
9
+ </div>
10
+ <% end %>
@@ -1,5 +1,10 @@
1
1
  <div class="card__footer">
2
2
  <div class="card__support">
3
+ <% if presenter.last_comment_by %>
4
+ <% author = presenter.last_comment_by %>
5
+ <%= cell "decidim/author", author, from: model, author_name_text: t(".commented_time_ago", time: presenter.last_comment_at), context: { extra_classes: ["author-data--small"] } %>
6
+ <% end %>
7
+
3
8
  <%= link_to t("participate", scope: "decidim.debates.debates.debate"), resource_path, class: "card__button button button--sc small" %>
4
9
  </div>
5
10
  </div>
@@ -11,14 +11,36 @@ module Decidim
11
11
  render
12
12
  end
13
13
 
14
+ def has_state?
15
+ model.closed?
16
+ end
17
+
18
+ def badge_name
19
+ I18n.t("decidim.debates.debates.closed") if model.closed?
20
+ end
21
+
22
+ def state_classes
23
+ return ["muted"] if model.closed?
24
+
25
+ super
26
+ end
27
+
28
+ def presenter
29
+ present(model)
30
+ end
31
+
14
32
  private
15
33
 
16
34
  def title
17
- present(model).title
35
+ presenter.title
36
+ end
37
+
38
+ def body
39
+ decidim_sanitize(present(model).description)
18
40
  end
19
41
 
20
42
  def description
21
- present(model).description(strip_tags: true)
43
+ strip_tags(body).truncate(200, separator: /\s/)
22
44
  end
23
45
 
24
46
  def resource_icon
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Debates
5
+ module Admin
6
+ # A command with all the business logic when an admin closes a debate.
7
+ class CloseDebate < Rectify::Command
8
+ # Public: Initializes the command.
9
+ #
10
+ # form - A form object with the params.
11
+ def initialize(form)
12
+ @form = form
13
+ end
14
+
15
+ # Executes the command. Broadcasts these events:
16
+ #
17
+ # - :ok when everything is valid, together with the debate.
18
+ # - :invalid if the form wasn't valid and we couldn't proceed.
19
+ #
20
+ # Returns nothing.
21
+ def call
22
+ return broadcast(:invalid) if form.invalid?
23
+
24
+ close_debate
25
+ broadcast(:ok, debate)
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :form
31
+
32
+ def close_debate
33
+ @debate = Decidim.traceability.perform_action!(
34
+ :close,
35
+ form.debate,
36
+ form.current_user
37
+ ) do
38
+ form.debate.update!(
39
+ conclusions: form.conclusions,
40
+ closed_at: form.closed_at
41
+ )
42
+ end
43
+
44
+ Decidim::EventsManager.publish(
45
+ event: "decidim.events.debates.debate_closed",
46
+ event_class: Decidim::Debates::CloseDebateEvent,
47
+ resource: debate,
48
+ followers: debate.followers
49
+ )
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -28,10 +28,12 @@ module Decidim
28
28
  attr_reader :debate, :form
29
29
 
30
30
  def create_debate
31
+ parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
32
+ parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite
31
33
  params = {
32
34
  category: form.category,
33
- title: form.title,
34
- description: form.description,
35
+ title: parsed_title,
36
+ description: parsed_description,
35
37
  information_updates: form.information_updates,
36
38
  instructions: form.instructions,
37
39
  end_time: form.end_time,
@@ -30,12 +30,15 @@ module Decidim
30
30
  attr_reader :debate, :form
31
31
 
32
32
  def update_debate
33
+ parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
34
+ parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite
35
+
33
36
  Decidim.traceability.update!(
34
37
  debate,
35
38
  form.current_user,
36
39
  category: form.category,
37
- title: form.title,
38
- description: form.description,
40
+ title: parsed_title,
41
+ description: parsed_description,
39
42
  information_updates: form.information_updates,
40
43
  instructions: form.instructions,
41
44
  end_time: form.end_time,
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Debates
5
+ # A command with all the business logic when a user updates a debate.
6
+ class CloseDebate < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # form - A form object with the params.
10
+ def initialize(form)
11
+ @form = form
12
+ end
13
+
14
+ # Executes the command. Broadcasts these events:
15
+ #
16
+ # - :ok when everything is valid, together with the debate.
17
+ # - :invalid if the form wasn't valid and we couldn't proceed.
18
+ #
19
+ # Returns nothing.
20
+ def call
21
+ return broadcast(:invalid) if form.invalid?
22
+
23
+ close_debate
24
+ broadcast(:ok, debate)
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :form
30
+
31
+ def close_debate
32
+ @debate = Decidim.traceability.perform_action!(
33
+ :close,
34
+ form.debate,
35
+ form.current_user
36
+ ) do
37
+ form.debate.update!(attributes)
38
+ end
39
+
40
+ Decidim::EventsManager.publish(
41
+ event: "decidim.events.debates.debate_closed",
42
+ event_class: Decidim::Debates::CloseDebateEvent,
43
+ resource: debate,
44
+ followers: debate.followers
45
+ )
46
+ end
47
+
48
+ def attributes
49
+ {
50
+ conclusions: {
51
+ I18n.locale => form.conclusions
52
+ },
53
+ closed_at: form.closed_at
54
+ }
55
+ end
56
+ end
57
+ end
58
+ end
@@ -20,6 +20,8 @@ module Decidim
20
20
  send_notification_to_author_followers
21
21
  send_notification_to_space_followers
22
22
  end
23
+
24
+ follow_debate
23
25
  broadcast(:ok, debate)
24
26
  end
25
27
 
@@ -27,23 +29,19 @@ module Decidim
27
29
 
28
30
  attr_reader :debate, :form
29
31
 
30
- def organization
31
- @organization = form.current_component.organization
32
- end
33
-
34
- def i18n_field(field)
35
- organization.available_locales.inject({}) do |i18n, locale|
36
- i18n.update(locale => field)
37
- end
38
- end
39
-
40
32
  def create_debate
33
+ parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
34
+ parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite
41
35
  params = {
42
36
  author: form.current_user,
43
37
  decidim_user_group_id: form.user_group_id,
44
38
  category: form.category,
45
- title: i18n_field(form.title),
46
- description: i18n_field(form.description),
39
+ title: {
40
+ I18n.locale => parsed_title
41
+ },
42
+ description: {
43
+ I18n.locale => parsed_description
44
+ },
47
45
  component: form.current_component
48
46
  }
49
47
 
@@ -78,6 +76,13 @@ module Decidim
78
76
  }
79
77
  )
80
78
  end
79
+
80
+ def follow_debate
81
+ follow_form = Decidim::FollowForm
82
+ .from_params(followable_gid: debate.to_signed_global_id.to_s)
83
+ .with_context(current_user: debate.author)
84
+ Decidim::CreateFollow.call(follow_form, debate.author)
85
+ end
81
86
  end
82
87
  end
83
88
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Debates
5
+ # A command with all the business logic when a user updates a debate.
6
+ class UpdateDebate < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # form - A form object with the params.
10
+ def initialize(form)
11
+ @form = form
12
+ end
13
+
14
+ # Executes the command. Broadcasts these events:
15
+ #
16
+ # - :ok when everything is valid, together with the debate.
17
+ # - :invalid if the form wasn't valid and we couldn't proceed.
18
+ #
19
+ # Returns nothing.
20
+ def call
21
+ return broadcast(:invalid) if form.invalid?
22
+ return broadcast(:invalid) unless form.debate.editable_by?(form.current_user)
23
+
24
+ update_debate
25
+ broadcast(:ok, @debate)
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :form
31
+
32
+ def update_debate
33
+ @debate = Decidim.traceability.update!(
34
+ @form.debate,
35
+ @form.current_user,
36
+ attributes,
37
+ visibility: "public-only"
38
+ )
39
+ end
40
+
41
+ def attributes
42
+ parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
43
+ parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite
44
+ {
45
+ category: form.category,
46
+ title: {
47
+ I18n.locale => parsed_title
48
+ },
49
+ description: {
50
+ I18n.locale => parsed_description
51
+ }
52
+ }
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Debates
5
+ module Admin
6
+ # This controller allows an admin to close debates
7
+ class DebateClosesController < Admin::ApplicationController
8
+ helper_method :debate
9
+
10
+ def edit
11
+ enforce_permission_to :close, :debate, debate: debate
12
+
13
+ @form = form(Admin::CloseDebateForm).from_model(debate)
14
+ end
15
+
16
+ def update
17
+ enforce_permission_to :close, :debate, debate: debate
18
+
19
+ @form = form(Admin::CloseDebateForm).from_params(params)
20
+ @form.debate = debate
21
+
22
+ CloseDebate.call(@form) do
23
+ on(:ok) do |_debate|
24
+ flash[:notice] = I18n.t("debates.close.success", scope: "decidim.debates")
25
+ redirect_to debates_path
26
+ end
27
+
28
+ on(:invalid) do
29
+ flash.now[:alert] = I18n.t("debates.close.invalid", scope: "decidim.debates")
30
+ render action: "edit"
31
+ end
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def debate
38
+ @debate ||= Debate.where(component: current_component).find(params[:id])
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -5,6 +5,8 @@ module Decidim
5
5
  module Admin
6
6
  # This controller allows an admin to manage debates from a Participatory Space
7
7
  class DebatesController < Decidim::Debates::Admin::ApplicationController
8
+ helper Decidim::ApplicationHelper
9
+
8
10
  helper_method :debates
9
11
 
10
12
  def index
@@ -38,13 +40,13 @@ module Decidim
38
40
  def edit
39
41
  enforce_permission_to :update, :debate, debate: debate
40
42
 
41
- @form = form(DebateForm).from_model(debate)
43
+ @form = form(Decidim::Debates::Admin::DebateForm).from_model(debate)
42
44
  end
43
45
 
44
46
  def update
45
47
  enforce_permission_to :update, :debate, debate: debate
46
48
 
47
- @form = form(DebateForm).from_params(params, current_component: current_component)
49
+ @form = form(Decidim::Debates::Admin::DebateForm).from_params(params, current_component: current_component)
48
50
 
49
51
  UpdateDebate.call(@form, debate) do
50
52
  on(:ok) do
@@ -6,11 +6,14 @@ module Decidim
6
6
  class DebatesController < Decidim::Debates::ApplicationController
7
7
  helper Decidim::ApplicationHelper
8
8
  helper Decidim::Messaging::ConversationHelper
9
+ helper Decidim::WidgetUrlsHelper
9
10
  include FormFactory
10
11
  include FilterResource
11
12
  include Paginable
13
+ include Flaggable
14
+ include Decidim::Debates::Orderable
12
15
 
13
- helper_method :debates, :debate, :paginated_debates, :report_form
16
+ helper_method :debates, :debate, :form_presenter, :paginated_debates, :report_form, :close_debate_form
14
17
 
15
18
  def new
16
19
  enforce_permission_to :create, :debate
@@ -21,7 +24,7 @@ module Decidim
21
24
  def create
22
25
  enforce_permission_to :create, :debate
23
26
 
24
- @form = form(DebateForm).from_params(params, current_component: current_component)
27
+ @form = form(DebateForm).from_params(params)
25
28
 
26
29
  CreateDebate.call(@form) do
27
30
  on(:ok) do |debate|
@@ -36,25 +39,80 @@ module Decidim
36
39
  end
37
40
  end
38
41
 
42
+ def show
43
+ raise ActionController::RoutingError, "Not Found" if debate.blank?
44
+ end
45
+
46
+ def edit
47
+ enforce_permission_to :edit, :debate, debate: debate
48
+
49
+ @form = form(DebateForm).from_model(debate)
50
+ end
51
+
52
+ def update
53
+ enforce_permission_to :edit, :debate, debate: debate
54
+
55
+ @form = form(DebateForm).from_params(params)
56
+ @form.debate = debate
57
+
58
+ UpdateDebate.call(@form) do
59
+ on(:ok) do |debate|
60
+ flash[:notice] = I18n.t("debates.update.success", scope: "decidim.debates")
61
+ redirect_to Decidim::ResourceLocatorPresenter.new(debate).path
62
+ end
63
+
64
+ on(:invalid) do
65
+ flash.now[:alert] = I18n.t("debates.update.invalid", scope: "decidim.debates")
66
+ render :edit
67
+ end
68
+ end
69
+ end
70
+
71
+ def close
72
+ enforce_permission_to :close, :debate, debate: debate
73
+
74
+ @form = form(CloseDebateForm).from_params(params)
75
+ @form.debate = debate
76
+
77
+ CloseDebate.call(@form) do
78
+ on(:ok) do |debate|
79
+ flash[:notice] = I18n.t("debates.close.success", scope: "decidim.debates")
80
+ redirect_back fallback_location: Decidim::ResourceLocatorPresenter.new(debate).path
81
+ end
82
+
83
+ on(:invalid) do
84
+ flash[:alert] = I18n.t("debates.close.invalid", scope: "decidim.debates")
85
+ redirect_back fallback_location: Decidim::ResourceLocatorPresenter.new(debate).path
86
+ end
87
+ end
88
+ end
89
+
39
90
  private
40
91
 
92
+ def form_presenter
93
+ @form_presenter ||= present(@form, presenter_class: Decidim::Debates::DebatePresenter)
94
+ end
95
+
41
96
  def paginated_debates
42
- @paginated_debates ||= paginate(debates)
43
- .includes(:category)
97
+ @paginated_debates ||= paginate(debates).includes(:category)
44
98
  end
45
99
 
46
100
  def debates
47
- @debates ||= search.results
101
+ @debates ||= reorder(search.results)
48
102
  end
49
103
 
50
104
  def debate
51
- @debate ||= debates.find(params[:id])
105
+ @debate ||= debates.find_by(id: params[:id])
52
106
  end
53
107
 
54
108
  def report_form
55
109
  @report_form ||= form(Decidim::ReportForm).from_params(reason: "spam")
56
110
  end
57
111
 
112
+ def close_debate_form
113
+ @close_debate_form ||= form(CloseDebateForm).from_model(debate)
114
+ end
115
+
58
116
  def search_klass
59
117
  DebateSearch
60
118
  end
@@ -69,9 +127,12 @@ module Decidim
69
127
  def default_filter_params
70
128
  {
71
129
  search_text: "",
72
- order_start_time: "asc",
73
- origin: "all",
74
- category_id: ""
130
+ origin: %w(official citizens user_group),
131
+ activity: "all",
132
+ category_id: default_filter_category_params,
133
+ scope_id: default_filter_scope_params,
134
+ status: "all",
135
+ state: %w(open closed)
75
136
  }
76
137
  end
77
138
  end