Class: Decidim::UserPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::UserPresenter
- Includes:
- ActionView::Helpers::UrlHelper, TranslatableAttributes
- Defined in:
- decidim-core/app/presenters/decidim/user_presenter.rb
Overview
Decorator for users
Direct Known Subclasses
Instance Method Summary collapse
- #avatar ⇒ Object
- #avatar_url(variant = nil) ⇒ Object
- #badge ⇒ Object
- #can_be_contacted? ⇒ Boolean
- #can_follow? ⇒ Boolean
- #default_avatar_url ⇒ Object
- #direct_messages_enabled?(context) ⇒ Boolean
- #display_mention ⇒ Object
- #has_tooltip? ⇒ Boolean
-
#nickname ⇒ Object
nickname presented in a twitter-like style.
- #officialization_text ⇒ Object
- #profile_path ⇒ Object
- #profile_url ⇒ Object
Methods included from TranslatableAttributes
Instance Method Details
#avatar ⇒ Object
32 33 34 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 32 def avatar attached_uploader(:avatar) end |
#avatar_url(variant = nil) ⇒ Object
36 37 38 39 40 41 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 36 def avatar_url(variant = nil) return default_avatar_url if __getobj__.blocked? return default_avatar_url unless avatar.attached? avatar.path(variant:) end |
#badge ⇒ Object
20 21 22 23 24 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 20 def badge return "" unless officialized? "verified-badge" end |
#can_be_contacted? ⇒ Boolean
63 64 65 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 63 def can_be_contacted? true unless blocked? end |
#can_follow? ⇒ Boolean
72 73 74 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 72 def can_follow? true end |
#default_avatar_url ⇒ Object
43 44 45 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 43 def default_avatar_url avatar.default_url end |
#direct_messages_enabled?(context) ⇒ Boolean
53 54 55 56 57 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 53 def (context) return false unless __getobj__.respond_to?(:accepts_conversation?) __getobj__.accepts_conversation?(context[:current_user]) end |
#display_mention ⇒ Object
59 60 61 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 59 def display_mention link_to nickname, profile_url, data: { "external-link": false } end |
#has_tooltip? ⇒ Boolean
76 77 78 79 80 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 76 def has_tooltip? return if respond_to?(:deleted?) && deleted? true end |
#nickname ⇒ Object
nickname presented in a twitter-like style
14 15 16 17 18 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 14 def nickname return "" if __getobj__.blocked? "@#{__getobj__.nickname}" end |
#officialization_text ⇒ Object
67 68 69 70 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 67 def officialization_text translated_attribute(officialized_as).presence || I18n.t("decidim.profiles.default_officialization_text_for_users") end |
#profile_path ⇒ Object
47 48 49 50 51 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 47 def profile_path return "" if respond_to?(:deleted?) && deleted? decidim.profile_path(__getobj__.nickname) end |
#profile_url ⇒ Object
26 27 28 29 30 |
# File 'decidim-core/app/presenters/decidim/user_presenter.rb', line 26 def profile_url return "" if respond_to?(:deleted?) && deleted? decidim.profile_url(__getobj__.nickname) end |