Class: Decidim::Debates::DebatePresenter

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

Overview

Decorator for debates

Instance Method Summary collapse

Instance Method Details

#authorObject



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

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

#debateObject



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

def debate
  __getobj__
end

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



34
35
36
37
38
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 34

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

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

#groups_countObject



56
57
58
59
60
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 56

def groups_count
  comments_authors.count do |author|
    author.is_a?(Decidim::UserGroup)
  end
end

#last_comment_atObject



40
41
42
43
44
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 40

def last_comment_at
  return unless debate.last_comment_at

  time_ago_in_words(debate.last_comment_at)
end

#last_comment_byObject



46
47
48
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 46

def last_comment_by
  debate.last_comment_by&.presenter
end

#participants_countObject



50
51
52
53
54
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 50

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

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



28
29
30
31
32
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 28

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

  super debate.title, links, html_escape, all_locales
end