Class: Decidim::Debates::DebatePresenter

Inherits:
ResourcePresenter
  • Object
show all
Includes:
ActionView::Helpers::DateHelper, ResourceHelper, TranslationsHelper
Defined in:
app/presenters/decidim/debates/debate_presenter.rb

Overview

Decorator for debates

Instance Method Summary collapse

Instance Method Details

#authorObject



17
18
19
20
21
22
23
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 17

def author
  @author ||= if official?
                Decidim::Debates::OfficialAuthorPresenter.new
              else
                Decidim::UserPresenter.new(super)
              end
end

#debateObject



13
14
15
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 13

def debate
  __getobj__
end

#description(links: false, strip_tags: false, all_locales: false) ⇒ Object



31
32
33
34
35
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 31

def description(links: false, strip_tags: false, all_locales: false)
  return unless debate

  content_handle_locale(debate.description, all_locales, links, strip_tags)
end

#last_comment_atObject



37
38
39
40
41
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 37

def last_comment_at
  return unless debate.last_comment_at

  time_ago_in_words(debate.last_comment_at)
end

#last_comment_byObject



43
44
45
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 43

def last_comment_by
  debate.last_comment_by&.presenter
end

#participants_countObject



47
48
49
50
51
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 47

def participants_count
  comments_authors.count do |author|
    author.is_a?(Decidim::User) && !author.group?
  end
end

#title(html_escape: false, all_locales: false) ⇒ Object



25
26
27
28
29
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 25

def title(html_escape: false, all_locales: false)
  return unless debate

  super(debate.title, html_escape, all_locales)
end