decidim-debates 0.27.9 → 0.28.0.rc4
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/debate_activity_cell.rb +1 -12
- data/app/cells/decidim/debates/debate_card_metadata_cell.rb +43 -0
- data/app/cells/decidim/debates/debate_cell.rb +6 -1
- data/app/cells/decidim/debates/debate_l_cell.rb +49 -0
- data/app/cells/decidim/debates/debate_s_cell.rb +21 -0
- data/app/commands/decidim/debates/admin/close_debate.rb +1 -1
- data/app/commands/decidim/debates/close_debate.rb +1 -1
- data/app/commands/decidim/debates/create_debate.rb +13 -4
- data/app/commands/decidim/debates/update_debate.rb +15 -2
- data/app/controllers/decidim/debates/admin/debate_closes_controller.rb +2 -2
- data/app/controllers/decidim/debates/admin/debates_controller.rb +5 -5
- data/app/controllers/decidim/debates/debates_controller.rb +7 -9
- data/app/events/decidim/debates/close_debate_event.rb +1 -1
- data/app/events/decidim/debates/create_debate_event.rb +15 -1
- data/app/forms/decidim/debates/admin/close_debate_form.rb +1 -1
- data/app/forms/decidim/debates/close_debate_form.rb +2 -2
- data/app/forms/decidim/debates/debate_form.rb +2 -2
- data/app/helpers/decidim/debates/application_helper.rb +42 -17
- data/app/jobs/decidim/debates/hide_all_created_by_author_job.rb +13 -0
- data/app/jobs/decidim/debates/settings_change_job.rb +2 -2
- data/app/models/decidim/debates/debate.rb +4 -10
- data/app/packs/entrypoints/decidim_debates.js +2 -0
- data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_commented_debates.svg +42 -1
- data/app/permissions/decidim/debates/permissions.rb +0 -6
- data/app/presenters/decidim/debates/admin_log/debate_presenter.rb +6 -2
- data/app/presenters/decidim/debates/admin_log/value_types/debate_title_description_presenter.rb +1 -1
- data/app/presenters/decidim/debates/log/resource_presenter.rb +18 -0
- data/app/views/decidim/debates/admin/debate_closes/edit.html.erb +26 -14
- data/app/views/decidim/debates/admin/debates/_form.html.erb +40 -39
- data/app/views/decidim/debates/admin/debates/edit.html.erb +16 -6
- data/app/views/decidim/debates/admin/debates/index.html.erb +60 -58
- data/app/views/decidim/debates/admin/debates/new.html.erb +16 -6
- data/app/views/decidim/debates/debates/_close_debate_modal.html.erb +22 -11
- data/app/views/decidim/debates/debates/_debates.html.erb +5 -6
- data/app/views/decidim/debates/debates/_form.html.erb +10 -19
- data/app/views/decidim/debates/debates/edit.html.erb +16 -20
- data/app/views/decidim/debates/debates/index.html.erb +19 -23
- data/app/views/decidim/debates/debates/index.js.erb +3 -4
- data/app/views/decidim/debates/debates/new.html.erb +16 -20
- data/app/views/decidim/debates/debates/show.html.erb +106 -109
- data/app/views/decidim/debates/versions/show.html.erb +15 -6
- data/config/locales/ar.yml +7 -17
- data/config/locales/bg.yml +0 -231
- data/config/locales/ca.yml +14 -35
- data/config/locales/cs.yml +13 -34
- data/config/locales/de.yml +14 -35
- data/config/locales/el.yml +10 -28
- data/config/locales/en.yml +13 -34
- data/config/locales/es-MX.yml +12 -33
- data/config/locales/es-PY.yml +13 -34
- data/config/locales/es.yml +15 -36
- data/config/locales/eu.yml +16 -37
- data/config/locales/fi-plain.yml +12 -33
- data/config/locales/fi.yml +14 -35
- data/config/locales/fr-CA.yml +14 -35
- data/config/locales/fr.yml +14 -35
- data/config/locales/ga-IE.yml +0 -15
- data/config/locales/gl.yml +7 -16
- data/config/locales/hu.yml +13 -32
- data/config/locales/id-ID.yml +7 -15
- data/config/locales/is-IS.yml +3 -9
- data/config/locales/it.yml +7 -31
- data/config/locales/ja.yml +13 -37
- data/config/locales/lb.yml +7 -25
- data/config/locales/lt.yml +14 -29
- data/config/locales/lv.yml +6 -17
- data/config/locales/nl.yml +7 -28
- data/config/locales/no.yml +7 -31
- data/config/locales/pl.yml +12 -38
- data/config/locales/pt-BR.yml +7 -39
- data/config/locales/pt.yml +7 -31
- data/config/locales/ro-RO.yml +10 -29
- data/config/locales/ru.yml +3 -12
- data/config/locales/sk.yml +6 -17
- data/config/locales/sl.yml +0 -3
- data/config/locales/sr-CS.yml +0 -6
- data/config/locales/sv.yml +34 -54
- data/config/locales/tr-TR.yml +6 -38
- data/config/locales/uk.yml +3 -12
- data/config/locales/zh-CN.yml +7 -29
- data/config/locales/zh-TW.yml +9 -28
- data/lib/decidim/debates/component.rb +4 -88
- data/lib/decidim/debates/engine.rb +29 -7
- data/lib/decidim/debates/seeds.rb +104 -0
- data/lib/decidim/debates/test/factories.rb +19 -14
- data/lib/decidim/debates/version.rb +1 -1
- metadata +29 -30
- data/app/cells/decidim/debates/debate_m/data.erb +0 -10
- data/app/cells/decidim/debates/debate_m/footer.erb +0 -10
- data/app/cells/decidim/debates/debate_m/multiple_dates.erb +0 -17
- data/app/cells/decidim/debates/debate_m/open_date.erb +0 -7
- data/app/cells/decidim/debates/debate_m/single_date.erb +0 -9
- data/app/cells/decidim/debates/debate_m/tags.erb +0 -1
- data/app/cells/decidim/debates/debate_m_cell.rb +0 -86
- data/app/controllers/decidim/debates/widgets_controller.rb +0 -29
- data/app/views/decidim/debates/debates/_count.html.erb +0 -1
- data/app/views/decidim/debates/debates/_filters.html.erb +0 -34
- data/app/views/decidim/debates/debates/_filters_small_view.html.erb +0 -18
- data/config/locales/he-IL.yml +0 -1
- data/decidim-debates.gemspec +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbbd97fad2e27ad5112a8fc5c9e87e8a43917e56345f0f0dfa08a78458c23ac9
|
4
|
+
data.tar.gz: e7f57d48e3331d15831289deae2655bb21abee8e069cc5fdfb0f3db9100b147a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af588e7c7dfa666a243493f50a6594f87c7d14225ae142c20d520c05747968dfc9aceecb241b458ca78f75afb2033d3556b67df44dcd00977c76881880d06af7
|
7
|
+
data.tar.gz: a0281466ecd1c7c00484840c4ba0ae6a97ed0827e7333359a131cda5b19bacc41dcd0ff77ab17b25c4b28060bfe71f86f206719ea15adc0492f73ae3084cbdfb
|
@@ -5,18 +5,7 @@ module Decidim
|
|
5
5
|
# A cell to display when actions happen on a debate.
|
6
6
|
class DebateActivityCell < ActivityCell
|
7
7
|
def title
|
8
|
-
|
9
|
-
when "update"
|
10
|
-
I18n.t(
|
11
|
-
"decidim.debates.last_activity.debate_updated_at_html",
|
12
|
-
link: participatory_space_link
|
13
|
-
)
|
14
|
-
else
|
15
|
-
I18n.t(
|
16
|
-
"decidim.debates.last_activity.new_debate_at_html",
|
17
|
-
link: participatory_space_link
|
18
|
-
)
|
19
|
-
end
|
8
|
+
action == "update" ? I18n.t("decidim.debates.last_activity.debate_updated") : I18n.t("decidim.debates.last_activity.new_debate")
|
20
9
|
end
|
21
10
|
|
22
11
|
def resource_link_text
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Debates
|
5
|
+
# This cell renders metadata for an instance of a Meeting
|
6
|
+
class DebateCardMetadataCell < Decidim::CardMetadataCell
|
7
|
+
include Decidim::LayoutHelper
|
8
|
+
include ActionView::Helpers::DateHelper
|
9
|
+
|
10
|
+
alias debate model
|
11
|
+
|
12
|
+
delegate :type_of_meeting, :start_time, :end_time, :category, :withdrawn?, to: :debate
|
13
|
+
|
14
|
+
def initialize(*)
|
15
|
+
super
|
16
|
+
|
17
|
+
@items.prepend(*debate_items)
|
18
|
+
end
|
19
|
+
|
20
|
+
def category_item
|
21
|
+
return if category.blank?
|
22
|
+
|
23
|
+
{
|
24
|
+
text: category.translated_name,
|
25
|
+
icon: resource_type_icon_key("Decidim::Category")
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def debate_items
|
30
|
+
[duration, comments_count_item, endorsements_count_item, category_item, coauthors_item]
|
31
|
+
end
|
32
|
+
|
33
|
+
def duration
|
34
|
+
text = format_date_range(debate.start_time, debate.end_time) || t("open", scope: "decidim.debates.debates.show")
|
35
|
+
|
36
|
+
{
|
37
|
+
text:,
|
38
|
+
icon: "time-line"
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cell/partial"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Debates
|
7
|
+
# This cell renders the List (:l) debate card
|
8
|
+
# for a given instance of a Debate
|
9
|
+
class DebateLCell < Decidim::CardLCell
|
10
|
+
include Decidim::SanitizeHelper
|
11
|
+
delegate :component_settings, to: :controller
|
12
|
+
|
13
|
+
alias debate model
|
14
|
+
|
15
|
+
def has_description?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def author_presenter
|
20
|
+
if model.official?
|
21
|
+
Decidim::Core::OfficialAuthorPresenter.new
|
22
|
+
else
|
23
|
+
model.normalized_author.presenter
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def title
|
28
|
+
presenter.title(html_escape: true)
|
29
|
+
end
|
30
|
+
|
31
|
+
def description
|
32
|
+
attribute = model.try(:short_description) || model.try(:body) || model.description
|
33
|
+
text = translated_attribute(attribute)
|
34
|
+
|
35
|
+
decidim_sanitize(html_truncate(text, length: 240))
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def presenter
|
41
|
+
present(model)
|
42
|
+
end
|
43
|
+
|
44
|
+
def metadata_cell
|
45
|
+
"decidim/debates/debate_card_metadata"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cell/partial"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Debates
|
7
|
+
# This cell renders the Search (:s) debate card
|
8
|
+
# for a given instance of a Debate
|
9
|
+
class DebateSCell < Decidim::CardSCell
|
10
|
+
private
|
11
|
+
|
12
|
+
def title
|
13
|
+
present(model).title(html_escape: true)
|
14
|
+
end
|
15
|
+
|
16
|
+
def metadata_cell
|
17
|
+
"decidim/debates/debate_card_metadata"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -15,7 +15,7 @@ module Decidim
|
|
15
15
|
# Executes the command. Broadcasts these events:
|
16
16
|
#
|
17
17
|
# - :ok when everything is valid, together with the debate.
|
18
|
-
# - :invalid if the form
|
18
|
+
# - :invalid if the form was not valid and we could not proceed.
|
19
19
|
#
|
20
20
|
# Returns nothing.
|
21
21
|
def call
|
@@ -14,7 +14,7 @@ module Decidim
|
|
14
14
|
# Executes the command. Broadcasts these events:
|
15
15
|
#
|
16
16
|
# - :ok when everything is valid, together with the debate.
|
17
|
-
# - :invalid if the form
|
17
|
+
# - :invalid if the form was not valid and we could not proceed.
|
18
18
|
#
|
19
19
|
# Returns nothing.
|
20
20
|
def call
|
@@ -15,12 +15,11 @@ module Decidim
|
|
15
15
|
def call
|
16
16
|
return broadcast(:invalid) if form.invalid?
|
17
17
|
|
18
|
-
|
18
|
+
with_events(with_transaction: true) do
|
19
19
|
create_debate
|
20
|
-
send_notification_to_author_followers
|
21
|
-
send_notification_to_space_followers
|
22
20
|
end
|
23
|
-
|
21
|
+
send_notification_to_author_followers
|
22
|
+
send_notification_to_space_followers
|
24
23
|
follow_debate
|
25
24
|
broadcast(:ok, debate)
|
26
25
|
end
|
@@ -29,6 +28,16 @@ module Decidim
|
|
29
28
|
|
30
29
|
attr_reader :debate, :form
|
31
30
|
|
31
|
+
def event_arguments
|
32
|
+
{
|
33
|
+
resource: debate,
|
34
|
+
extra: {
|
35
|
+
event_author: form.current_user,
|
36
|
+
locale:
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
32
41
|
def create_debate
|
33
42
|
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
|
34
43
|
parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite
|
@@ -14,14 +14,17 @@ module Decidim
|
|
14
14
|
# Executes the command. Broadcasts these events:
|
15
15
|
#
|
16
16
|
# - :ok when everything is valid, together with the debate.
|
17
|
-
# - :invalid if the form
|
17
|
+
# - :invalid if the form was not valid and we could not proceed.
|
18
18
|
#
|
19
19
|
# Returns nothing.
|
20
20
|
def call
|
21
21
|
return broadcast(:invalid) if form.invalid?
|
22
22
|
return broadcast(:invalid) unless form.debate.editable_by?(form.current_user)
|
23
23
|
|
24
|
-
|
24
|
+
with_events(with_transaction: true) do
|
25
|
+
update_debate
|
26
|
+
end
|
27
|
+
|
25
28
|
broadcast(:ok, @debate)
|
26
29
|
end
|
27
30
|
|
@@ -29,6 +32,16 @@ module Decidim
|
|
29
32
|
|
30
33
|
attr_reader :form
|
31
34
|
|
35
|
+
def event_arguments
|
36
|
+
{
|
37
|
+
resource: @debate,
|
38
|
+
extra: {
|
39
|
+
event_author: form.current_user,
|
40
|
+
locale:
|
41
|
+
}
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
32
45
|
def update_debate
|
33
46
|
@debate = Decidim.traceability.update!(
|
34
47
|
@form.debate,
|
@@ -8,13 +8,13 @@ module Decidim
|
|
8
8
|
helper_method :debate
|
9
9
|
|
10
10
|
def edit
|
11
|
-
enforce_permission_to
|
11
|
+
enforce_permission_to(:close, :debate, debate:)
|
12
12
|
|
13
13
|
@form = form(Admin::CloseDebateForm).from_model(debate)
|
14
14
|
end
|
15
15
|
|
16
16
|
def update
|
17
|
-
enforce_permission_to
|
17
|
+
enforce_permission_to(:close, :debate, debate:)
|
18
18
|
|
19
19
|
@form = form(Admin::CloseDebateForm).from_params(params)
|
20
20
|
|
@@ -22,7 +22,7 @@ module Decidim
|
|
22
22
|
def create
|
23
23
|
enforce_permission_to :create, :debate
|
24
24
|
|
25
|
-
@form = form(Decidim::Debates::Admin::DebateForm).from_params(params, current_component:
|
25
|
+
@form = form(Decidim::Debates::Admin::DebateForm).from_params(params, current_component:)
|
26
26
|
|
27
27
|
CreateDebate.call(@form) do
|
28
28
|
on(:ok) do
|
@@ -38,15 +38,15 @@ module Decidim
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def edit
|
41
|
-
enforce_permission_to
|
41
|
+
enforce_permission_to(:update, :debate, debate:)
|
42
42
|
|
43
43
|
@form = form(Decidim::Debates::Admin::DebateForm).from_model(debate)
|
44
44
|
end
|
45
45
|
|
46
46
|
def update
|
47
|
-
enforce_permission_to
|
47
|
+
enforce_permission_to(:update, :debate, debate:)
|
48
48
|
|
49
|
-
@form = form(Decidim::Debates::Admin::DebateForm).from_params(params, current_component:
|
49
|
+
@form = form(Decidim::Debates::Admin::DebateForm).from_params(params, current_component:)
|
50
50
|
|
51
51
|
UpdateDebate.call(@form, debate) do
|
52
52
|
on(:ok) do
|
@@ -62,7 +62,7 @@ module Decidim
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def destroy
|
65
|
-
enforce_permission_to
|
65
|
+
enforce_permission_to(:delete, :debate, debate:)
|
66
66
|
|
67
67
|
debate.destroy!
|
68
68
|
|
@@ -6,7 +6,6 @@ module Decidim
|
|
6
6
|
class DebatesController < Decidim::Debates::ApplicationController
|
7
7
|
helper Decidim::ApplicationHelper
|
8
8
|
helper Decidim::Messaging::ConversationHelper
|
9
|
-
helper Decidim::WidgetUrlsHelper
|
10
9
|
include FormFactory
|
11
10
|
include FilterResource
|
12
11
|
include Paginable
|
@@ -14,7 +13,6 @@ module Decidim
|
|
14
13
|
include Decidim::Debates::Orderable
|
15
14
|
|
16
15
|
helper_method :debates, :debate, :form_presenter, :paginated_debates, :close_debate_form
|
17
|
-
before_action :authenticate_user!, only: [:new, :create]
|
18
16
|
|
19
17
|
def new
|
20
18
|
enforce_permission_to :create, :debate
|
@@ -45,13 +43,13 @@ module Decidim
|
|
45
43
|
end
|
46
44
|
|
47
45
|
def edit
|
48
|
-
enforce_permission_to
|
46
|
+
enforce_permission_to(:edit, :debate, debate:)
|
49
47
|
|
50
48
|
@form = form(DebateForm).from_model(debate)
|
51
49
|
end
|
52
50
|
|
53
51
|
def update
|
54
|
-
enforce_permission_to
|
52
|
+
enforce_permission_to(:edit, :debate, debate:)
|
55
53
|
|
56
54
|
@form = form(DebateForm).from_params(params)
|
57
55
|
|
@@ -69,7 +67,7 @@ module Decidim
|
|
69
67
|
end
|
70
68
|
|
71
69
|
def close
|
72
|
-
enforce_permission_to
|
70
|
+
enforce_permission_to(:close, :debate, debate:)
|
73
71
|
|
74
72
|
@form = form(CloseDebateForm).from_params(params)
|
75
73
|
|
@@ -115,10 +113,10 @@ module Decidim
|
|
115
113
|
def default_filter_params
|
116
114
|
{
|
117
115
|
search_text_cont: "",
|
118
|
-
with_any_origin:
|
119
|
-
activity:
|
120
|
-
with_any_category:
|
121
|
-
with_any_scope:
|
116
|
+
with_any_origin: nil,
|
117
|
+
activity: %w(all),
|
118
|
+
with_any_category: nil,
|
119
|
+
with_any_scope: nil,
|
122
120
|
with_any_state: %w(open closed)
|
123
121
|
}
|
124
122
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Debates
|
@@ -12,12 +12,26 @@ module Decidim
|
|
12
12
|
class CreateDebateEvent < Decidim::Events::SimpleEvent
|
13
13
|
include Decidim::Events::AuthorEvent
|
14
14
|
|
15
|
+
i18n_attributes :space_title, :space_path
|
16
|
+
|
15
17
|
def resource_text
|
16
18
|
translated_attribute(resource.description)
|
17
19
|
end
|
18
20
|
|
19
21
|
private
|
20
22
|
|
23
|
+
def space
|
24
|
+
@space ||= resource.participatory_space
|
25
|
+
end
|
26
|
+
|
27
|
+
def space_path
|
28
|
+
Decidim::ResourceLocatorPresenter.new(space).path
|
29
|
+
end
|
30
|
+
|
31
|
+
def space_title
|
32
|
+
space.title.is_a?(Hash) ? space.title[I18n.locale.to_s] : space.title
|
33
|
+
end
|
34
|
+
|
21
35
|
def i18n_scope
|
22
36
|
@i18n_scope ||= if extra[:type].to_s == "user"
|
23
37
|
"decidim.events.debates.create_debate_event.user_followers"
|
@@ -20,13 +20,13 @@ module Decidim
|
|
20
20
|
super
|
21
21
|
|
22
22
|
# Debates can be translated in different languages from the admin but
|
23
|
-
# the public form
|
23
|
+
# the public form does not allow it. When a user closes a debate the
|
24
24
|
# user locale is taken as the text locale.
|
25
25
|
self.conclusions = debate.conclusions&.values&.first
|
26
26
|
end
|
27
27
|
|
28
28
|
def debate
|
29
|
-
@debate ||= Debate.find_by(id:
|
29
|
+
@debate ||= Debate.find_by(id:)
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
@@ -22,7 +22,7 @@ module Decidim
|
|
22
22
|
def map_model(debate)
|
23
23
|
super
|
24
24
|
# Debates can be translated in different languages from the admin but
|
25
|
-
# the public form
|
25
|
+
# the public form does not allow it. When a user creates a debate the
|
26
26
|
# user locale is taken as the text locale.
|
27
27
|
self.title = debate.title.values.first
|
28
28
|
self.description = debate.description.values.first
|
@@ -53,7 +53,7 @@ module Decidim
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def debate
|
56
|
-
@debate ||= Debate.find_by(id:
|
56
|
+
@debate ||= Debate.find_by(id:)
|
57
57
|
end
|
58
58
|
|
59
59
|
private
|
@@ -11,6 +11,7 @@ module Decidim
|
|
11
11
|
include Decidim::EndorsableHelper
|
12
12
|
include Decidim::FollowableHelper
|
13
13
|
include Decidim::CheckBoxesTreeHelper
|
14
|
+
include Decidim::DateRangeHelper
|
14
15
|
|
15
16
|
# If the debate is official or the rich text editor is enabled on the
|
16
17
|
# frontend, the debate description is considered as safe content.
|
@@ -42,35 +43,59 @@ module Decidim
|
|
42
43
|
# Returns a TreeNode to be used in the list filters to filter debates by
|
43
44
|
# its origin.
|
44
45
|
def filter_origin_values
|
45
|
-
|
46
|
-
|
47
|
-
origin_values << TreePoint.new("participants", t("decidim.debates.debates.filters.participants"))
|
48
|
-
origin_values << TreePoint.new("user_group", t("decidim.debates.debates.filters.user_groups")) if current_organization.user_groups_enabled?
|
46
|
+
origin_keys = %w(official participants)
|
47
|
+
origin_keys << "user_group" if current_organization.user_groups_enabled?
|
49
48
|
|
50
|
-
|
49
|
+
origin_values = origin_keys.map { |key| [key, t(key, scope: "decidim.debates.debates.filters")] }
|
50
|
+
origin_values.prepend(["", all_filter_text])
|
51
|
+
|
52
|
+
filter_tree_from_array(origin_values)
|
51
53
|
end
|
52
54
|
|
53
55
|
# Options to filter Debates by activity.
|
54
56
|
def activity_filter_values
|
55
|
-
|
56
|
-
["all", t("decidim.debates.debates.filters.all")],
|
57
|
-
["my_debates", t("decidim.debates.debates.filters.my_debates")]
|
58
|
-
]
|
59
|
-
base += [["commented", t("decidim.debates.debates.filters.commented")]]
|
60
|
-
base
|
57
|
+
%w(all my_debates commented).map { |k| [k, t(k, scope: "decidim.debates.debates.filters")] }
|
61
58
|
end
|
62
59
|
|
63
60
|
# Returns a TreeNode to be used in the list filters to filter debates by
|
64
61
|
# its state.
|
65
62
|
def filter_debates_state_values
|
66
|
-
|
67
|
-
|
68
|
-
[
|
69
|
-
Decidim::CheckBoxesTreeHelper::TreePoint.new("open", t("decidim.debates.debates.filters.state_values.open")),
|
70
|
-
Decidim::CheckBoxesTreeHelper::TreePoint.new("closed", t("decidim.debates.debates.filters.state_values.closed"))
|
71
|
-
]
|
63
|
+
%w(open closed).map { |k| [k, t(k, scope: "decidim.debates.debates.filters.state_values")] }.prepend(
|
64
|
+
["all", all_filter_text]
|
72
65
|
)
|
73
66
|
end
|
67
|
+
|
68
|
+
def all_filter_text
|
69
|
+
t("all", scope: "decidim.debates.debates.filters")
|
70
|
+
end
|
71
|
+
|
72
|
+
def filter_sections
|
73
|
+
@filter_sections ||= begin
|
74
|
+
items = [{
|
75
|
+
method: :with_any_state,
|
76
|
+
collection: filter_debates_state_values,
|
77
|
+
label_scope: "decidim.meetings.meetings.filters",
|
78
|
+
id: "date",
|
79
|
+
type: :radio_buttons
|
80
|
+
}]
|
81
|
+
if current_component.has_subscopes?
|
82
|
+
items.append(method: :with_any_scope, collection: filter_scopes_values, label_scope: "decidim.shared.participatory_space_filters.filters", id: "scope")
|
83
|
+
end
|
84
|
+
if current_participatory_space.categories.any?
|
85
|
+
items.append(method: :with_any_category, collection: filter_categories_values, label_scope: "decidim.debates.debates.filters", id: "category")
|
86
|
+
end
|
87
|
+
items.append(method: :with_any_origin, collection: filter_origin_values, label_scope: "decidim.debates.debates.filters", id: "origin")
|
88
|
+
items.append(method: :activity, collection: activity_filter_values, label_scope: "decidim.debates.debates.filters", id: "activity") if current_user
|
89
|
+
|
90
|
+
items.reject { |item| item[:collection].blank? }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def search_variable = :search_text_cont
|
95
|
+
|
96
|
+
def component_name
|
97
|
+
(defined?(current_component) && translated_attribute(current_component&.name).presence) || t("decidim.components.debates.name")
|
98
|
+
end
|
74
99
|
end
|
75
100
|
end
|
76
101
|
end
|
@@ -44,7 +44,7 @@ module Decidim
|
|
44
44
|
|
45
45
|
scope :open, -> { where(closed_at: nil) }
|
46
46
|
scope :closed, -> { where.not(closed_at: nil) }
|
47
|
-
scope :authored_by, ->(author) { where(author:
|
47
|
+
scope :authored_by, ->(author) { where(author:) }
|
48
48
|
scope :commented_by, lambda { |author|
|
49
49
|
joins(:comments).where(
|
50
50
|
decidim_comments_comments:
|
@@ -56,12 +56,6 @@ module Decidim
|
|
56
56
|
}
|
57
57
|
scope_search_multi :with_any_state, [:open, :closed]
|
58
58
|
|
59
|
-
# Returns the presenter for this debate, to be used in the views.
|
60
|
-
# Required by ResourceRenderer.
|
61
|
-
def presenter
|
62
|
-
Decidim::Debates::DebatePresenter.new(self)
|
63
|
-
end
|
64
|
-
|
65
59
|
def self.log_presenter_class_for(_log)
|
66
60
|
Decidim::Debates::AdminLog::DebatePresenter
|
67
61
|
end
|
@@ -153,12 +147,12 @@ module Decidim
|
|
153
147
|
end
|
154
148
|
|
155
149
|
def self.newsletter_participant_ids(component)
|
156
|
-
authors_ids = Decidim::Debates::Debate.where(component:
|
150
|
+
authors_ids = Decidim::Debates::Debate.where(component:)
|
157
151
|
.where(decidim_author_type: Decidim::UserBaseEntity.name)
|
158
152
|
.where.not(author: nil)
|
159
153
|
.group(:decidim_author_id)
|
160
154
|
.pluck(:decidim_author_id).flatten.compact
|
161
|
-
commentators_ids = Decidim::Comments::Comment.user_commentators_ids_in(Decidim::Debates::Debate.where(component:
|
155
|
+
commentators_ids = Decidim::Comments::Comment.user_commentators_ids_in(Decidim::Debates::Debate.where(component:))
|
162
156
|
(authors_ids + commentators_ids).flatten.compact.uniq
|
163
157
|
end
|
164
158
|
|
@@ -195,7 +189,7 @@ module Decidim
|
|
195
189
|
last_comment_at: last_comment&.created_at,
|
196
190
|
last_comment_by_id: last_comment&.decidim_user_group_id || last_comment&.decidim_author_id,
|
197
191
|
last_comment_by_type: last_comment&.decidim_author_type,
|
198
|
-
comments_count
|
192
|
+
comments_count:,
|
199
193
|
updated_at: Time.current
|
200
194
|
)
|
201
195
|
end
|