Class: UserPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/user_presenter.rb

Instance Attribute Summary

Attributes inherited from BasePresenter

object

Instance Method Summary (collapse)

Methods inherited from BasePresenter

#initialize

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

- (Object) admin_buttons



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/presenters/user_presenter.rb', line 46

def admin_buttons
  if user_signed_in? && current_user.role?(:maintainer)
    ( :p,
      ui_button( 'details', I18n.translate("userlist.detail"), details_user_path(user), :remote => true) +
      ui_button( 'edit', I18n.translate(:edit_role), edit_role_user_path(user)) +
      ui_button( 'cancel', I18n.translate(:cancel_this_account), user_path(user), :confirm => t(:sure?), :method => :delete)
    ) +
    ( :div, 
      :class=>'user_detail admin', 
      :id => "user_information_#{ user.id.to_s }", 
      :style => 'display: none; margin-top: 20px') {''}
  end
end

- (Object) authentication_icons



36
37
38
39
40
41
42
43
44
# File 'app/presenters/user_presenter.rb', line 36

def authentication_icons
  if user.authentications.any?
    ( :p, :style => 'margin-left: -140px; clear: both;' ) {
      user.authentications.map { |a| 
        image_tag("/images/#{a.provider}_thirtytwo.png",:class => 'omniauth_mini_icons')
      }.join().html_safe
    }.html_safe
  end
end

- (Object) avatar



14
15
16
17
18
19
20
# File 'app/presenters/user_presenter.rb', line 14

def avatar
  link_to_function( 
    image_tag( w3c_url(user.avatar_url(:thumb) )), 
    "image_popup('#{w3c_url(user.avatar_url(:popup))}')",
    :class => 'avatar'
  )
end

- (Object) header



22
23
24
25
26
27
# File 'app/presenters/user_presenter.rb', line 22

def header
  ( :address, :id=>"user_roles_#{user.name}") {
    user.role.to_s.humanize + ", " +
    I18n.translate(:last_login_at,:time => distance_of_time_in_words(Time.now(),user.||Time.at(0)))
  }
end

- (Object) location



5
6
7
8
9
10
11
12
# File 'app/presenters/user_presenter.rb', line 5

def location
  unless user.location_token.blank?
     :div, :class => 'user-location', :id => user.id.to_s do
      user.location_token
      javascript_tag "loadUserLocation('#{user.id.to_s}','#{user.location_token}');"
    end
  end
end

- (Object) summary



29
30
31
32
33
34
# File 'app/presenters/user_presenter.rb', line 29

def summary
   :div, :style => 'display: block-inline; margin-left: 140px;' do
     :b, link_to( user.name, user )
     :p, authentication_icons
  end
end