Class: Decidim::UserPresenter

Inherits:
SimpleDelegator
  • Object
show all
Includes:
ActionView::Helpers::UrlHelper, TranslatableAttributes
Defined in:
app/presenters/decidim/user_presenter.rb

Overview

Decorator for users

Direct Known Subclasses

UserGroupPresenter

Instance Method Summary collapse

Methods included from TranslatableAttributes

#default_locale?

Instance Method Details

#badgeObject



19
20
21
22
23
# File 'app/presenters/decidim/user_presenter.rb', line 19

def badge
  return "" unless officialized?

  "verified-badge"
end

#can_be_contacted?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'app/presenters/decidim/user_presenter.rb', line 49

def can_be_contacted?
  true
end

#can_follow?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'app/presenters/decidim/user_presenter.rb', line 58

def can_follow?
  true
end

#direct_messages_enabled?(context) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
# File 'app/presenters/decidim/user_presenter.rb', line 39

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

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

#display_mentionObject



45
46
47
# File 'app/presenters/decidim/user_presenter.rb', line 45

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

#has_tooltip?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/presenters/decidim/user_presenter.rb', line 62

def has_tooltip?
  true
end

#nicknameObject

nickname presented in a twitter-like style



15
16
17
# File 'app/presenters/decidim/user_presenter.rb', line 15

def nickname
  "@#{__getobj__.nickname}"
end

#officialization_textObject



53
54
55
56
# File 'app/presenters/decidim/user_presenter.rb', line 53

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

#profile_pathObject



33
34
35
36
37
# File 'app/presenters/decidim/user_presenter.rb', line 33

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

  decidim.profile_path(__getobj__.nickname)
end

#profile_urlObject



27
28
29
30
31
# File 'app/presenters/decidim/user_presenter.rb', line 27

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

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