Sha256: b07bffee08e921c6348547b340778e11ee9c3215f9e0679495ffbd21f485662c

Contents?: true

Size: 800 Bytes

Versions: 4

Compression:

Stored size: 800 Bytes

Contents

# frozen_string_literal: true

module Decidim
  #
  # Decorator for users
  #
  class UserPresenter < SimpleDelegator
    include Rails.application.routes.mounted_helpers
    include ActionView::Helpers::UrlHelper

    #
    # nickname presented in a twitter-like style
    #
    def nickname
      "@#{super}"
    end

    def badge
      return "" unless officialized?

      "verified-badge"
    end

    delegate :url, to: :avatar, prefix: true

    def profile_url
      return "" if deleted?

      decidim.profile_url(__getobj__.nickname, host: __getobj__.organization.host)
    end

    def profile_path
      return "" if deleted?

      decidim.profile_path(__getobj__.nickname)
    end

    def display_mention
      link_to nickname, profile_path, class: "user-mention"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-core-0.9.3 app/presenters/decidim/user_presenter.rb
decidim-core-0.9.2 app/presenters/decidim/user_presenter.rb
decidim-core-0.9.1 app/presenters/decidim/user_presenter.rb
decidim-core-0.9.0 app/presenters/decidim/user_presenter.rb