Sha256: bff58b7726a86b5cf24c4280b8591e1de0b596c9ae8f5159e65ff0c1bc1692c7

Contents?: true

Size: 963 Bytes

Versions: 3

Compression:

Stored size: 963 Bytes

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_path
        proposal = __getobj__
        Decidim::ResourceLocatorPresenter.new(proposal).path
      end

      def display_mention
        link_to title, proposal_path
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-proposals-0.13.1 app/presenters/decidim/proposals/proposal_presenter.rb
decidim-proposals-0.13.0 app/presenters/decidim/proposals/proposal_presenter.rb
decidim-proposals-0.13.0.pre1 app/presenters/decidim/proposals/proposal_presenter.rb