Class: Decidim::Proposals::ProposalPresenter

Inherits:
SimpleDelegator
  • Object
show all
Includes:
ActionView::Helpers::UrlHelper
Defined in:
app/presenters/decidim/proposals/proposal_presenter.rb

Overview

Decorator for proposals

Instance Method Summary collapse

Instance Method Details

#authorObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 12

def author
  @author ||= if official?
                Decidim::Proposals::OfficialAuthorPresenter.new
              else
                coauthorship = coauthorships.first
                if coauthorship.user_group
                  Decidim::UserGroupPresenter.new(coauthorship.user_group)
                else
                  Decidim::UserPresenter.new(coauthorship.author)
                end
              end
end

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



48
49
50
51
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 48

def body(links: false, extras: true, strip_tags: false)
  renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.body)
  renderer.render(links: links, extras: extras, strip_tags: strip_tags).html_safe
end

#display_mentionObject



33
34
35
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 33

def display_mention
  link_to title, proposal_path
end

#proposalObject



25
26
27
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 25

def proposal
  __getobj__
end

#proposal_pathObject



29
30
31
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 29

def proposal_path
  Decidim::ResourceLocatorPresenter.new(proposal).path
end

#title(links: false, extras: true, html_escape: false) ⇒ Object

Render the proposal title

links - should render hashtags as links? extras - should include extra hashtags?

Returns a String.



43
44
45
46
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 43

def title(links: false, extras: true, html_escape: false)
  renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.title)
  renderer.render(links: links, extras: extras, html_escape: html_escape).html_safe
end