Sha256: 3ca31f45d532fc60f14ece82d385696f1b2973614c126ca61d0452fcf2ab4c6a

Contents?: true

Size: 1.36 KB

Versions: 9

Compression:

Stored size: 1.36 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 respond_to?(:deleted?) && deleted?

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

    def profile_path
      return "" if respond_to?(:deleted?) && deleted?

      decidim.profile_path(__getobj__.nickname)
    end

    def direct_messages_enabled?(context)
      return false unless __getobj__.respond_to?(:accepts_conversation?)

      __getobj__.accepts_conversation?(context[:current_user])
    end

    def display_mention
      link_to nickname, profile_path, class: "user-mention"
    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

    def has_tooltip?
      true
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-core-0.23.6 app/presenters/decidim/user_presenter.rb
decidim-core-0.23.5 app/presenters/decidim/user_presenter.rb
decidim-core-0.23.4 app/presenters/decidim/user_presenter.rb
decidim-core-0.23.3 app/presenters/decidim/user_presenter.rb
decidim-core-0.23.2 app/presenters/decidim/user_presenter.rb
decidim-core-0.23.1 app/presenters/decidim/user_presenter.rb
decidim-core-0.23.1.rc1 app/presenters/decidim/user_presenter.rb
decidim-core-0.23.0 app/presenters/decidim/user_presenter.rb
decidim-core-0.22.0 app/presenters/decidim/user_presenter.rb