Sha256: fa51e132be116646caaa15e1333892a89f0cf506f2b66731d55018b554578fc9

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

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

    #
    # 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_users.count
    end

    def can_be_contacted?
      true
    end

    def officialization_text
      translated_attribute(officialized_as).presence ||
        I18n.t("decidim.profiles.default_officialization_text_for_users")
    end

    def can_follow?
      true
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-core-0.15.2 app/presenters/decidim/user_presenter.rb
decidim-core-0.15.1 app/presenters/decidim/user_presenter.rb
decidim-core-0.15.0 app/presenters/decidim/user_presenter.rb