Class: Decidim::Plans::PlanPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::Plans::PlanPresenter
show all
- Includes:
- ActionView::Helpers::UrlHelper, RichPresenter, TranslatableAttributes
- Defined in:
- app/presenters/decidim/plans/plan_presenter.rb
Overview
Instance Method Summary
collapse
#plain_content, #rich_content
Instance Method Details
#author ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'app/presenters/decidim/plans/plan_presenter.rb', line 14
def author
coauthorship = coauthorships.first
@author ||= if coauthorship.user_group
Decidim::UserGroupPresenter.new(coauthorship.user_group)
else
Decidim::UserPresenter.new(coauthorship.author)
end
end
|
#body ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/presenters/decidim/plans/plan_presenter.rb', line 35
def body
fields = plan.sections.map do |section|
content = plan.contents.find_by(section: section)
next if content.nil?
section_title = plain_content(translated_attribute(content.title))
section_body = plain_content(translated_attribute(content.body))
"<dt>#{section_title}</dt> <dd>#{section_body}</dd>"
end
"<dl>#{fields.join("\n")}</dl>".html_safe
end
|
#display_mention ⇒ Object
48
49
50
|
# File 'app/presenters/decidim/plans/plan_presenter.rb', line 48
def display_mention
link_to title, plan_path
end
|
#plan ⇒ Object
23
24
25
|
# File 'app/presenters/decidim/plans/plan_presenter.rb', line 23
def plan
__getobj__
end
|
#plan_path ⇒ Object
27
28
29
|
# File 'app/presenters/decidim/plans/plan_presenter.rb', line 27
def plan_path
Decidim::ResourceLocatorPresenter.new(plan).path
end
|
#title ⇒ Object
31
32
33
|
# File 'app/presenters/decidim/plans/plan_presenter.rb', line 31
def title
plain_content(translated_attribute(plan.title))
end
|