Sha256: 231d44916ef19f4869c5dd0296e1c5c4e70057427ab949a7589172a4543af928

Contents?: true

Size: 1.55 KB

Versions: 7

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    #
    # Decorator for proposals
    #
    class ProposalPresenter < SimpleDelegator
      include Rails.application.routes.mounted_helpers
      include ActionView::Helpers::UrlHelper

      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

      def proposal
        __getobj__
      end

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

      def display_mention
        link_to title, proposal_path
      end

      def title
        renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.title)
        renderer.render_without_link.html_safe
      end

      def html_title
        renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.title)
        renderer.render.html_safe
      end

      def body
        renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.body)
        renderer.render_without_link.html_safe
      end

      def html_body
        renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.body)
        renderer.render.html_safe
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-proposals-0.15.2 app/presenters/decidim/proposals/proposal_presenter.rb
decidim-proposals-0.15.1 app/presenters/decidim/proposals/proposal_presenter.rb
decidim-proposals-0.15.0 app/presenters/decidim/proposals/proposal_presenter.rb
decidim-proposals-0.14.4 app/presenters/decidim/proposals/proposal_presenter.rb
decidim-proposals-0.14.3 app/presenters/decidim/proposals/proposal_presenter.rb
decidim-proposals-0.14.2 app/presenters/decidim/proposals/proposal_presenter.rb
decidim-proposals-0.14.1 app/presenters/decidim/proposals/proposal_presenter.rb