Class: Decidim::UserPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::UserPresenter
- Includes:
- ActionView::Helpers::UrlHelper, TranslatableAttributes
- Defined in:
- 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
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 |
#badge ⇒ Object
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
61 62 63 |
# File 'app/presenters/decidim/user_presenter.rb', line 61 def can_be_contacted? true end |
#can_follow? ⇒ Boolean
70 71 72 |
# File 'app/presenters/decidim/user_presenter.rb', line 70 def can_follow? true end |
#default_avatar_url ⇒ Object
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
51 52 53 54 55 |
# File 'app/presenters/decidim/user_presenter.rb', line 51 def (context) return false unless __getobj__.respond_to?(:accepts_conversation?) __getobj__.accepts_conversation?(context[:current_user]) end |
#display_mention ⇒ Object
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
74 75 76 |
# File 'app/presenters/decidim/user_presenter.rb', line 74 def has_tooltip? true end |
#nickname ⇒ Object
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_text ⇒ Object
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_path ⇒ Object
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_url ⇒ Object
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 |