Class: UserPresenter
- Inherits:
-
BasePresenter
- Object
- BasePresenter
- UserPresenter
- Defined in:
- app/presenters/user_presenter.rb
Instance Method Summary collapse
-
#avatar_for(size = 32) ⇒ Object
gives the public avatar for a user ——————————————————————————.
-
#last_access ⇒ Object
——————————————————————————.
-
#role_label ⇒ Object
——————————————————————————.
Methods inherited from BasePresenter
Methods included from DmCore::LiquidHelper
#liquidize_html, #liquidize_markdown, #liquidize_textile, #markdown, #sanitize_text
Constructor Details
This class inherits a constructor from BasePresenter
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class BasePresenter
Instance Method Details
#avatar_for(size = 32) ⇒ Object
gives the public avatar for a user
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/presenters/user_presenter.rb', line 30 def avatar_for(size = 32) case when size.class == String && size.end_with?('%') avatar = user.user_profile.public_avatar_url(:sq200) when size <= 35 avatar = user.user_profile.public_avatar_url(:sq35) when size <= 100 avatar = user.user_profile.public_avatar_url(:sq100) when size <= 200 avatar = user.user_profile.public_avatar_url(:sq200) else avatar = user.user_profile.public_avatar_url end # image_tag('dm_core/user.gif', width: size, height: size, class: 'image') image_tag(avatar, width: size, class: 'image') end |
#last_access ⇒ Object
24 25 26 |
# File 'app/presenters/user_presenter.rb', line 24 def last_access user.last_access_at.nil? ? colored_label('n/a', :warning) : "#{time_ago_in_words(user.last_access_at)} ago" end |
#role_label ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/presenters/user_presenter.rb', line 7 def role_label if user.is_admin? colored_label('Admin', :success) elsif user.has_role?(:manager) colored_label('Manager', :info) elsif user.has_role?(:content_manager) || user.has_role?(:event_manager) || user.has_role?(:forum_manager) colored_label('Submanager', :warning) elsif user.has_role?(:reviewer) colored_label('Reviewer', :default) elsif user.has_role?(:beta) colored_label('Beta', :danger) else 'User' end end |