Sha256: a1621796c74c910b289f463b172bf09ea9c915f0908b563d514c33a2fe0d757e
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module Decidim module Plans # # Decorator for plans # class PlanPresenter < SimpleDelegator include Rails.application.routes.mounted_helpers include ActionView::Helpers::UrlHelper include TranslatableAttributes include Plans::RichPresenter def author coauthorship = coauthorships.first @author ||= if coauthorship.user_group Decidim::UserGroupPresenter.new(coauthorship.user_group) else Decidim::UserPresenter.new(coauthorship.author) end end def plan __getobj__ end def plan_path Decidim::ResourceLocatorPresenter.new(plan).path end def title sanitize(translated_attribute(plan.title)) end def body fields = plan.sections.map do |section| content = plan.contents.find_by(section: section) next if content.nil? section_title = sanitize(translated_attribute(content.title)) section_body = sanitize(translated_attribute(content.body)) "<dt>#{section_title}</dt> <dd>#{section_body}</dd>" end "<dl>#{fields.join("\n")}</dl>".html_safe end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
decidim-plans-0.16.5 | app/presenters/decidim/plans/plan_presenter.rb |