diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/application_helper.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 11 | ||||
-rw-r--r-- | app/views/users/index.html.erb | 2 |
3 files changed, 14 insertions, 3 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0911fdfc2..b9fcf9291 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -47,8 +47,8 @@ module ApplicationHelper def link_to_user(user, options={}) if user.is_a?(User) name = h(user.name(options[:format])) - if user.active? - link_to name, :controller => 'users', :action => 'show', :id => user + if user.active? || (User.current.admin? && user.logged?) + link_to name, {:controller => 'users', :action => 'show', :id => user}, :class => user.css_classes else name end diff --git a/app/models/user.rb b/app/models/user.rb index 348ae120d..87db4eb5a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -387,6 +387,17 @@ class User < Principal name end + CSS_CLASS_BY_STATUS = { + STATUS_ANONYMOUS => 'anon', + STATUS_ACTIVE => 'active', + STATUS_REGISTERED => 'registered', + STATUS_LOCKED => 'locked' + } + + def css_classes + "user #{CSS_CLASS_BY_STATUS[status]}" + end + # Returns the current day according to user's time zone def today if time_zone.nil? diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index f88b5231e..4f77a6493 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -36,7 +36,7 @@ </tr></thead> <tbody> <% for user in @users -%> - <tr class="user <%= cycle("odd", "even") %> <%= %w(anon active registered locked)[user.status] %>"> + <tr class="<%= user.css_classes %> <%= cycle("odd", "even") %>"> <td class="username"><%= avatar(user, :size => "14") %><%= link_to h(user.login), edit_user_path(user) %></td> <td class="firstname"><%= h(user.firstname) %></td> <td class="lastname"><%= h(user.lastname) %></td> |