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

#avatarObject



31
32
33
# File 'app/presenters/decidim/user_presenter.rb', line 31

def avatar
  attached_uploader(:avatar)
end

#avatar_url(variant = nil) ⇒ Object



35
36
37
38
39
# File 'app/presenters/decidim/user_presenter.rb', line 35

def avatar_url(variant = nil)
  return avatar.default_url unless avatar.attached?

  avatar.path(variant: variant)
end

#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)


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

def can_be_contacted?
  true
end

#can_follow?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'app/presenters/decidim/user_presenter.rb', line 70

def can_follow?
  true
end

#default_avatar_urlObject



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

def default_avatar_url
  attached_uploader.default_url
end

#direct_messages_enabled?(context) ⇒ Boolean

Returns:

  • (Boolean)


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

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

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

#display_mentionObject



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

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

#has_tooltip?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'app/presenters/decidim/user_presenter.rb', line 74

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



65
66
67
68
# File 'app/presenters/decidim/user_presenter.rb', line 65

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

#profile_pathObject



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

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

  decidim.profile_path(__getobj__.nickname)
end

#profile_urlObject



25
26
27
28
29
# File 'app/presenters/decidim/user_presenter.rb', line 25

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

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