decidim-debates 0.21.0 → 0.23.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/decidim/gamification/badges/commented_debates.svg +1 -78
- data/app/cells/decidim/debates/debate_activity_cell.rb +4 -0
- data/app/cells/decidim/debates/debate_m/data.erb +10 -8
- data/app/cells/decidim/debates/debate_m/footer.erb +6 -1
- data/app/cells/decidim/debates/debate_m/multiple_dates.erb +1 -1
- data/app/cells/decidim/debates/debate_m_cell.rb +24 -2
- data/app/commands/decidim/debates/admin/close_debate.rb +54 -0
- data/app/commands/decidim/debates/admin/create_debate.rb +4 -2
- data/app/commands/decidim/debates/admin/update_debate.rb +5 -2
- data/app/commands/decidim/debates/close_debate.rb +58 -0
- data/app/commands/decidim/debates/create_debate.rb +17 -12
- data/app/commands/decidim/debates/update_debate.rb +56 -0
- data/app/controllers/decidim/debates/admin/debate_closes_controller.rb +43 -0
- data/app/controllers/decidim/debates/admin/debates_controller.rb +4 -2
- data/app/controllers/decidim/debates/debates_controller.rb +70 -9
- data/app/controllers/decidim/debates/orderable.rb +41 -0
- data/app/controllers/decidim/debates/versions_controller.rb +16 -0
- data/app/controllers/decidim/debates/widgets_controller.rb +19 -0
- data/app/events/decidim/debates/close_debate_event.rb +15 -0
- data/app/events/decidim/debates/create_debate_event.rb +0 -2
- data/app/forms/decidim/debates/admin/close_debate_form.rb +34 -0
- data/app/forms/decidim/debates/admin/debate_form.rb +5 -1
- data/app/forms/decidim/debates/close_debate_form.rb +39 -0
- data/app/forms/decidim/debates/debate_form.rb +27 -1
- data/app/helpers/decidim/debates/admin/application_helper.rb +13 -0
- data/app/helpers/decidim/debates/application_helper.rb +37 -1
- data/app/models/decidim/debates/debate.rb +67 -12
- data/app/permissions/decidim/debates/admin/permissions.rb +3 -1
- data/app/permissions/decidim/debates/permissions.rb +28 -0
- 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 +20 -0
- data/app/presenters/decidim/debates/debate_presenter.rb +62 -7
- data/app/presenters/decidim/debates/log/resource_presenter.rb +18 -0
- data/app/presenters/decidim/debates/official_author_presenter.rb +1 -29
- data/app/queries/decidim/debates/metrics/debates_metric_manage.rb +2 -8
- data/app/services/decidim/debates/debate_search.rb +13 -23
- data/app/services/decidim/debates/diff_renderer.rb +27 -0
- data/app/views/decidim/debates/admin/debate_closes/edit.html.erb +17 -0
- data/app/views/decidim/debates/admin/debates/_form.html.erb +5 -5
- data/app/views/decidim/debates/admin/debates/index.html.erb +7 -1
- data/app/views/decidim/debates/debates/_close_debate_modal.html.erb +13 -0
- data/app/views/decidim/debates/debates/_debates.html.erb +7 -0
- data/app/views/decidim/debates/debates/_filters.html.erb +20 -6
- data/app/views/decidim/debates/debates/_form.html.erb +19 -0
- data/app/views/decidim/debates/debates/edit.html.erb +24 -0
- data/app/views/decidim/debates/debates/index.html.erb +4 -5
- data/app/views/decidim/debates/debates/new.html.erb +7 -26
- data/app/views/decidim/debates/debates/show.html.erb +87 -9
- data/app/views/decidim/debates/versions/index.html.erb +8 -0
- data/app/views/decidim/debates/versions/show.html.erb +10 -0
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +2 -1
- data/config/locales/bg-BG.yml +7 -0
- data/config/locales/bg.yml +15 -0
- data/config/locales/ca.yml +73 -1
- data/config/locales/cs.yml +112 -40
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +95 -23
- data/config/locales/el.yml +154 -0
- data/config/locales/en.yml +73 -1
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +73 -1
- data/config/locales/es-PY.yml +73 -1
- data/config/locales/es.yml +73 -1
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +2 -1
- data/config/locales/fi-plain.yml +73 -1
- data/config/locales/fi.yml +78 -6
- data/config/locales/fr-CA.yml +223 -0
- data/config/locales/fr.yml +73 -1
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +7 -1
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +26 -1
- data/config/locales/id-ID.yml +2 -1
- data/config/locales/is-IS.yml +2 -1
- data/config/locales/is.yml +102 -0
- data/config/locales/it.yml +45 -10
- data/config/locales/ja-JP.yml +195 -0
- data/config/locales/ja.yml +221 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +135 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +50 -2
- data/config/locales/no.yml +117 -71
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +100 -45
- data/config/locales/pt-BR.yml +3 -4
- data/config/locales/pt.yml +56 -36
- data/config/locales/ro-RO.yml +173 -0
- data/config/locales/ru.yml +2 -1
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk-SK.yml +156 -0
- data/config/locales/sk.yml +157 -0
- data/config/locales/sl.yml +22 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +6 -0
- data/config/locales/sv.yml +60 -1
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +103 -31
- data/config/locales/uk.yml +2 -1
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +218 -0
- data/config/locales/zh-TW.yml +1 -0
- data/db/migrate/20200320105918_index_foreign_keys_in_decidim_debates_debates.rb +7 -0
- data/db/migrate/20200703134657_close_debates.rb +9 -0
- data/db/migrate/20200708072042_fix_debates_i18n_fields.rb +48 -0
- data/db/migrate/20200716143929_add_endorsable_to_debates.rb +8 -0
- data/db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb +14 -0
- data/db/migrate/20200902133452_add_cached_comment_metadata_to_debates.rb +23 -0
- data/lib/decidim/debates/admin_engine.rb +3 -1
- data/lib/decidim/debates/component.rb +44 -1
- data/lib/decidim/debates/engine.rb +7 -1
- data/lib/decidim/debates/test/factories.rb +62 -6
- data/lib/decidim/debates/version.rb +1 -1
- metadata +85 -17
@@ -8,6 +8,9 @@ module Decidim
|
|
8
8
|
include PaginateHelper
|
9
9
|
include Decidim::Comments::CommentsHelper
|
10
10
|
include Decidim::RichTextEditorHelper
|
11
|
+
include Decidim::EndorsableHelper
|
12
|
+
include Decidim::FollowableHelper
|
13
|
+
include Decidim::CheckBoxesTreeHelper
|
11
14
|
|
12
15
|
# If the debate is official or the rich text editor is enabled on the
|
13
16
|
# frontend, the debate description is considered as safe content.
|
@@ -17,7 +20,7 @@ module Decidim
|
|
17
20
|
|
18
21
|
# If the content is safe, HTML tags are sanitized, otherwise, they are stripped.
|
19
22
|
def render_debate_description(debate)
|
20
|
-
description = present(debate).description(strip_tags: !safe_content
|
23
|
+
description = present(debate).description(strip_tags: !safe_content?, links: true)
|
21
24
|
|
22
25
|
safe_content? ? decidim_sanitize(description) : simple_format(description)
|
23
26
|
end
|
@@ -26,6 +29,39 @@ module Decidim
|
|
26
29
|
def text_editor_for_debate_description(form)
|
27
30
|
text_editor_for(form, :description)
|
28
31
|
end
|
32
|
+
|
33
|
+
# Returns a TreeNode to be used in the list filters to filter debates by
|
34
|
+
# its origin.
|
35
|
+
def filter_origin_values
|
36
|
+
origin_values = []
|
37
|
+
origin_values << TreePoint.new("official", t("decidim.debates.debates.filters.official"))
|
38
|
+
origin_values << TreePoint.new("citizens", t("decidim.debates.debates.filters.citizens"))
|
39
|
+
origin_values << TreePoint.new("user_group", t("decidim.debates.debates.filters.user_groups")) if current_organization.user_groups_enabled?
|
40
|
+
|
41
|
+
TreeNode.new(TreePoint.new("", t("decidim.debates.debates.filters.all")), origin_values)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Options to filter Debates by activity.
|
45
|
+
def activity_filter_values
|
46
|
+
base = [
|
47
|
+
["all", t("decidim.debates.debates.filters.all")],
|
48
|
+
["my_debates", t("decidim.debates.debates.filters.my_debates")]
|
49
|
+
]
|
50
|
+
base += [["commented", t("decidim.debates.debates.filters.commented")]]
|
51
|
+
base
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns a TreeNode to be used in the list filters to filter debates by
|
55
|
+
# its state.
|
56
|
+
def filter_debates_state_values
|
57
|
+
Decidim::CheckBoxesTreeHelper::TreeNode.new(
|
58
|
+
Decidim::CheckBoxesTreeHelper::TreePoint.new("", t("decidim.debates.debates.filters.all")),
|
59
|
+
[
|
60
|
+
Decidim::CheckBoxesTreeHelper::TreePoint.new("open", t("decidim.debates.debates.filters.state_values.open")),
|
61
|
+
Decidim::CheckBoxesTreeHelper::TreePoint.new("closed", t("decidim.debates.debates.filters.state_values.closed"))
|
62
|
+
]
|
63
|
+
)
|
64
|
+
end
|
29
65
|
end
|
30
66
|
end
|
31
67
|
end
|
@@ -11,7 +11,7 @@ module Decidim
|
|
11
11
|
include Decidim::Resourceable
|
12
12
|
include Decidim::Followable
|
13
13
|
include Decidim::Comments::Commentable
|
14
|
-
include Decidim::
|
14
|
+
include Decidim::ScopableResource
|
15
15
|
include Decidim::Authorable
|
16
16
|
include Decidim::Reportable
|
17
17
|
include Decidim::HasReference
|
@@ -20,11 +20,17 @@ module Decidim
|
|
20
20
|
include Decidim::DataPortability
|
21
21
|
include Decidim::NewsletterParticipant
|
22
22
|
include Decidim::Searchable
|
23
|
+
include Decidim::TranslatableResource
|
24
|
+
include Decidim::TranslatableAttributes
|
25
|
+
include Decidim::Endorsable
|
26
|
+
include Decidim::Randomable
|
23
27
|
|
28
|
+
belongs_to :last_comment_by, polymorphic: true, foreign_key: "last_comment_by_id", foreign_type: "last_comment_by_type", optional: true
|
24
29
|
component_manifest_name "debates"
|
25
30
|
|
26
31
|
validates :title, presence: true
|
27
32
|
|
33
|
+
translatable_fields :title, :description, :instructions, :information_updates
|
28
34
|
searchable_fields({
|
29
35
|
participatory_space: { component: :participatory_space },
|
30
36
|
A: :title,
|
@@ -34,17 +40,23 @@ module Decidim
|
|
34
40
|
index_on_create: ->(debate) { debate.visible? },
|
35
41
|
index_on_update: ->(debate) { debate.visible? })
|
36
42
|
|
43
|
+
scope :open, -> { where(closed_at: nil) }
|
44
|
+
scope :closed, -> { where.not(closed_at: nil) }
|
45
|
+
scope :authored_by, ->(author) { where(author: author) }
|
46
|
+
scope :commented_by, lambda { |author|
|
47
|
+
joins(:comments).where(
|
48
|
+
decidim_comments_comments:
|
49
|
+
{
|
50
|
+
decidim_author_id: author.id,
|
51
|
+
decidim_author_type: author.class.base_class.name
|
52
|
+
}
|
53
|
+
)
|
54
|
+
}
|
55
|
+
|
37
56
|
def self.log_presenter_class_for(_log)
|
38
57
|
Decidim::Debates::AdminLog::DebatePresenter
|
39
58
|
end
|
40
59
|
|
41
|
-
# Public: Checks whether the debate is official or not.
|
42
|
-
#
|
43
|
-
# Returns a boolean.
|
44
|
-
def official?
|
45
|
-
author.is_a?(Decidim::Organization)
|
46
|
-
end
|
47
|
-
|
48
60
|
# Public: Overrides the `reported_content_url` Reportable concern method.
|
49
61
|
def reported_content_url
|
50
62
|
ResourceLocatorPresenter.new(self).url
|
@@ -82,6 +94,7 @@ module Decidim
|
|
82
94
|
# Public: Overrides the `accepts_new_comments?` Commentable concern method.
|
83
95
|
def accepts_new_comments?
|
84
96
|
return false unless open?
|
97
|
+
return false if closed?
|
85
98
|
|
86
99
|
commentable? && !comments_blocked?
|
87
100
|
end
|
@@ -118,12 +131,54 @@ module Decidim
|
|
118
131
|
end
|
119
132
|
|
120
133
|
def self.newsletter_participant_ids(component)
|
121
|
-
Decidim::Debates::Debate.where(component: component)
|
122
|
-
|
123
|
-
|
124
|
-
|
134
|
+
authors_ids = Decidim::Debates::Debate.where(component: component)
|
135
|
+
.where(decidim_author_type: Decidim::UserBaseEntity.name)
|
136
|
+
.where.not(author: nil)
|
137
|
+
.group(:decidim_author_id)
|
138
|
+
.pluck(:decidim_author_id).flatten.compact
|
139
|
+
commentators_ids = Decidim::Comments::Comment.user_commentators_ids_in(Decidim::Debates::Debate.where(component: component))
|
140
|
+
(authors_ids + commentators_ids).flatten.compact.uniq
|
141
|
+
end
|
142
|
+
|
143
|
+
# Checks whether the user can edit the debate.
|
144
|
+
#
|
145
|
+
# user - the user to check for authorship
|
146
|
+
def editable_by?(user)
|
147
|
+
!closed? && authored_by?(user)
|
125
148
|
end
|
126
149
|
|
150
|
+
# Checks whether the debate is closed or not.
|
151
|
+
#
|
152
|
+
def closed?
|
153
|
+
closed_at.present? && conclusions.present?
|
154
|
+
end
|
155
|
+
|
156
|
+
# Checks whether the user can edit the debate.
|
157
|
+
#
|
158
|
+
# user - the user to check for authorship
|
159
|
+
def closeable_by?(user)
|
160
|
+
authored_by?(user)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Public: Updates the comments counter cache. We have to do it these
|
164
|
+
# way in order to properly calculate the counter with hidden
|
165
|
+
# comments.
|
166
|
+
#
|
167
|
+
# rubocop:disable Rails/SkipsModelValidations
|
168
|
+
def update_comments_count
|
169
|
+
comments_count = comments.not_hidden.count
|
170
|
+
last_comment = comments.not_hidden.order("created_at DESC").first
|
171
|
+
|
172
|
+
update_columns(
|
173
|
+
last_comment_at: last_comment&.created_at,
|
174
|
+
last_comment_by_id: last_comment&.decidim_author_id,
|
175
|
+
last_comment_by_type: last_comment&.decidim_author_type,
|
176
|
+
comments_count: comments_count,
|
177
|
+
updated_at: Time.current
|
178
|
+
)
|
179
|
+
end
|
180
|
+
# rubocop:enable Rails/SkipsModelValidations
|
181
|
+
|
127
182
|
private
|
128
183
|
|
129
184
|
def comments_blocked?
|
@@ -12,7 +12,9 @@ module Decidim
|
|
12
12
|
case permission_action.action
|
13
13
|
when :create, :read
|
14
14
|
allow!
|
15
|
-
when :update
|
15
|
+
when :update
|
16
|
+
toggle_allow(debate && !debate.closed? && debate.official?)
|
17
|
+
when :delete, :close
|
16
18
|
toggle_allow(debate && debate.official?)
|
17
19
|
end
|
18
20
|
|
@@ -15,6 +15,12 @@ module Decidim
|
|
15
15
|
toggle_allow(can_create_debate?)
|
16
16
|
when :report
|
17
17
|
allow!
|
18
|
+
when :edit
|
19
|
+
can_edit_debate?
|
20
|
+
when :endorse
|
21
|
+
can_endorse_debate?
|
22
|
+
when :close
|
23
|
+
can_close_debate?
|
18
24
|
end
|
19
25
|
|
20
26
|
permission_action
|
@@ -26,6 +32,28 @@ module Decidim
|
|
26
32
|
authorized?(:create) &&
|
27
33
|
current_settings&.creation_enabled? && component.participatory_space.can_participate?(user)
|
28
34
|
end
|
35
|
+
|
36
|
+
def can_edit_debate?
|
37
|
+
return allow! if debate&.editable_by?(user)
|
38
|
+
|
39
|
+
disallow!
|
40
|
+
end
|
41
|
+
|
42
|
+
def can_close_debate?
|
43
|
+
return allow! if debate&.closeable_by?(user)
|
44
|
+
|
45
|
+
disallow!
|
46
|
+
end
|
47
|
+
|
48
|
+
def can_endorse_debate?
|
49
|
+
return disallow! if debate.closed?
|
50
|
+
|
51
|
+
allow!
|
52
|
+
end
|
53
|
+
|
54
|
+
def debate
|
55
|
+
@debate ||= context.fetch(:debate, nil) || context.fetch(:resource, nil)
|
56
|
+
end
|
29
57
|
end
|
30
58
|
end
|
31
59
|
end
|
@@ -15,14 +15,18 @@ module Decidim
|
|
15
15
|
class DebatePresenter < Decidim::Log::BasePresenter
|
16
16
|
private
|
17
17
|
|
18
|
+
def resource_presenter
|
19
|
+
@resource_presenter ||= Decidim::Debates::Log::ResourcePresenter.new(action_log.resource, h, action_log.extra["resource"])
|
20
|
+
end
|
21
|
+
|
18
22
|
def diff_fields_mapping
|
19
23
|
{
|
20
|
-
description:
|
24
|
+
description: "Decidim::Debates::AdminLog::ValueTypes::DebateTitleDescriptionPresenter",
|
21
25
|
end_date: :date,
|
22
26
|
information_updates: :i18n,
|
23
27
|
instructions: :i18n,
|
24
28
|
start_date: :date,
|
25
|
-
title:
|
29
|
+
title: "Decidim::Debates::AdminLog::ValueTypes::DebateTitleDescriptionPresenter"
|
26
30
|
}
|
27
31
|
end
|
28
32
|
|
data/app/presenters/decidim/debates/admin_log/value_types/debate_title_description_presenter.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Debates
|
5
|
+
module AdminLog
|
6
|
+
module ValueTypes
|
7
|
+
# This class presents the given value as a Decidim::Debates::DebateTitleBody. Check
|
8
|
+
# the `DefaultPresenter` for more info on how value presenters work.
|
9
|
+
class DebateTitleDescriptionPresenter < Decidim::Log::ValueTypes::DefaultPresenter
|
10
|
+
def present
|
11
|
+
return unless value
|
12
|
+
|
13
|
+
renderer = Decidim::ContentRenderers::HashtagRenderer.new(h.translated_attribute(value))
|
14
|
+
renderer.render(links: false).html_safe
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,8 +6,11 @@ module Decidim
|
|
6
6
|
# Decorator for debates
|
7
7
|
#
|
8
8
|
class DebatePresenter < SimpleDelegator
|
9
|
+
include Decidim::TranslationsHelper
|
10
|
+
include Decidim::ResourceHelper
|
9
11
|
include Decidim::SanitizeHelper
|
10
12
|
include Decidim::TranslatableAttributes
|
13
|
+
include ActionView::Helpers::DateHelper
|
11
14
|
|
12
15
|
def debate
|
13
16
|
__getobj__
|
@@ -23,15 +26,67 @@ module Decidim
|
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
26
|
-
def title
|
27
|
-
|
28
|
-
|
29
|
+
def title(links: false, all_locales: false)
|
30
|
+
return unless debate
|
31
|
+
|
32
|
+
handle_locales(debate.title, all_locales) do |content|
|
33
|
+
renderer = Decidim::ContentRenderers::HashtagRenderer.new(decidim_html_escape(content))
|
34
|
+
renderer.render(links: links).html_safe
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def description(strip_tags: false, links: false, all_locales: false)
|
39
|
+
return unless debate
|
40
|
+
|
41
|
+
handle_locales(debate.description, all_locales) do |content|
|
42
|
+
content = strip_tags(content) if strip_tags
|
43
|
+
renderer = Decidim::ContentRenderers::HashtagRenderer.new(content)
|
44
|
+
content = renderer.render(links: links).html_safe
|
45
|
+
content = Decidim::ContentRenderers::LinkRenderer.new(content).render if links
|
46
|
+
content
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def handle_locales(content, all_locales, &block)
|
51
|
+
if all_locales
|
52
|
+
content.each_with_object({}) do |(key, value), parsed_content|
|
53
|
+
parsed_content[key] = if key == "machine_translations"
|
54
|
+
handle_locales(value, all_locales, &block)
|
55
|
+
else
|
56
|
+
block.call(value)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
else
|
60
|
+
yield(translated_attribute(content))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def last_comment_at
|
65
|
+
return unless debate.last_comment_at
|
66
|
+
|
67
|
+
time_ago_in_words(debate.last_comment_at)
|
68
|
+
end
|
69
|
+
|
70
|
+
def last_comment_by
|
71
|
+
debate.last_comment_by&.presenter
|
72
|
+
end
|
73
|
+
|
74
|
+
def participants_count
|
75
|
+
comments_authors.count do |author|
|
76
|
+
author.is_a?(Decidim::User)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def groups_count
|
81
|
+
comments_authors.count do |author|
|
82
|
+
author.is_a?(Decidim::UserGroup)
|
83
|
+
end
|
29
84
|
end
|
30
85
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
86
|
+
private
|
87
|
+
|
88
|
+
def comments_authors
|
89
|
+
@comments_authors ||= debate.comments.includes(:author, :user_group).map(&:normalized_author).uniq
|
35
90
|
end
|
36
91
|
end
|
37
92
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Debates
|
5
|
+
module Log
|
6
|
+
class ResourcePresenter < Decidim::Log::ResourcePresenter
|
7
|
+
private
|
8
|
+
|
9
|
+
# Private: Presents resource name.
|
10
|
+
#
|
11
|
+
# Returns an HTML-safe String.
|
12
|
+
def present_resource_name
|
13
|
+
Decidim::Debates::DebatePresenter.new(resource).title
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -5,38 +5,10 @@ module Decidim
|
|
5
5
|
#
|
6
6
|
# A dummy presenter to abstract out the author of an official debate.
|
7
7
|
#
|
8
|
-
class OfficialAuthorPresenter
|
8
|
+
class OfficialAuthorPresenter < Decidim::OfficialAuthorPresenter
|
9
9
|
def name
|
10
10
|
I18n.t("decidim.debates.models.debate.fields.official_debate")
|
11
11
|
end
|
12
|
-
|
13
|
-
def nickname
|
14
|
-
""
|
15
|
-
end
|
16
|
-
|
17
|
-
def badge
|
18
|
-
""
|
19
|
-
end
|
20
|
-
|
21
|
-
def profile_path
|
22
|
-
""
|
23
|
-
end
|
24
|
-
|
25
|
-
def avatar_url
|
26
|
-
ActionController::Base.helpers.asset_path("decidim/default-avatar.svg")
|
27
|
-
end
|
28
|
-
|
29
|
-
def deleted?
|
30
|
-
false
|
31
|
-
end
|
32
|
-
|
33
|
-
def can_be_contacted?
|
34
|
-
false
|
35
|
-
end
|
36
|
-
|
37
|
-
def has_tooltip?
|
38
|
-
false
|
39
|
-
end
|
40
12
|
end
|
41
13
|
end
|
42
14
|
end
|
@@ -9,9 +9,6 @@ module Decidim
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def save
|
12
|
-
return @registry if @registry
|
13
|
-
|
14
|
-
@registry = []
|
15
12
|
cumulative.each do |key, cumulative_value|
|
16
13
|
next if cumulative_value.zero?
|
17
14
|
|
@@ -21,10 +18,8 @@ module Decidim
|
|
21
18
|
organization: @organization, decidim_category_id: category_id,
|
22
19
|
participatory_space_type: space_type, participatory_space_id: space_id)
|
23
20
|
record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
|
24
|
-
|
21
|
+
record.save!
|
25
22
|
end
|
26
|
-
@registry.each(&:save!)
|
27
|
-
@registry
|
28
23
|
end
|
29
24
|
|
30
25
|
private
|
@@ -32,8 +27,7 @@ module Decidim
|
|
32
27
|
def query
|
33
28
|
return @query if @query
|
34
29
|
|
35
|
-
|
36
|
-
@query = Decidim::Debates::Debate.where(component: components).joins(:component)
|
30
|
+
@query = Decidim::Debates::Debate.where(component: visible_component_ids_from_spaces(retrieve_participatory_spaces)).joins(:component)
|
37
31
|
.left_outer_joins(:category)
|
38
32
|
@query = @query.where("decidim_debates_debates.start_time <= ?", end_time)
|
39
33
|
@query = @query.group("decidim_categorizations.decidim_category_id",
|