Sha256: be7adbd1e05417c81b80b70e6d804887b73f12271a29a19f5ba74e84dd67fca9

Contents?: true

Size: 954 Bytes

Versions: 7

Compression:

Stored size: 954 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
      "@#{__getobj__.nickname}"
    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

    def followers_count
      __getobj__.followers.count
    end

    def following_count
      __getobj__.following_follows.count
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.13.1 app/presenters/decidim/user_presenter.rb
decidim-core-0.12.2 app/presenters/decidim/user_presenter.rb
decidim-core-0.13.0 app/presenters/decidim/user_presenter.rb
decidim-core-0.12.1 app/presenters/decidim/user_presenter.rb
decidim-core-0.13.0.pre1 app/presenters/decidim/user_presenter.rb
decidim-core-0.12.0 app/presenters/decidim/user_presenter.rb
decidim-core-0.12.0.pre app/presenters/decidim/user_presenter.rb