Updating style and ordering of user index

This commit is contained in:
Will Bradley 2013-01-25 21:11:01 -07:00
parent 7193ec832c
commit e9c648d36e
4 changed files with 34 additions and 15 deletions

View File

@ -1,4 +1,6 @@
// Place all the styles related to the users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.iconinfo, .hoverinfo { font-size: 1.5em; }
.hoverinfo { cursor: progress; }

View File

@ -15,7 +15,7 @@ class UsersController < ApplicationController
when "waiver"
@users = @users.sort_by{ |u| [-u.waiver.to_i,u.name] }
when "member"
@users = @users.sort_by{ |u| [-u.member.to_i,u.name] }
@users = @users.sort_by{ |u| [-u.member.to_i,-u.member_level.to_i,u.name] }
when "card"
@users = @users.sort_by{ |u| [-u.cards.count,u.name] }
when "instructor"

View File

@ -6,23 +6,40 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :admin, :instructor, :member, :emergency_name, :emergency_phone, :current_skills, :desired_skills, :waiver, :emergency_email, :phone, :payment_method, :orientation, :member_level, :certifications, :hidden
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :admin, :instructor, :member, :emergency_name, :emergency_phone, :current_skills, :desired_skills, :waiver, :emergency_email, :phone, :payment_method, :orientation, :member_level, :certifications, :hidden #TODO: make admin/instructor/member/etc not accessible
has_many :cards
has_many :user_certifications
has_many :certifications, :through => :user_certifications
def member_status
# 1 = inactive, show an X
if self.member == 1 then
"<span class='hoverinfo' title='Inactive'>!!</span>"
# 25 or higher is paying, show a check
elsif self.member == 25 then
"<span class='hoverinfo' title='25'>&#x2713;</span>"
elsif self.member == 50 then
"<span class='hoverinfo' title='50'>&#x2713;</span>"
elsif self.member == 100 then
"<span class='hoverinfo' title='100'>&#x2713;</span>"
output = ""
if self.member_level.to_i >= 1 then
output = "<span class='hoverinfo' title='Inactive'>&#9676;</span>"
end
unless self.member.nil? then
# 1 = inactive, show an X
if self.member >= 10 then
output = "<span class='hoverinfo' title='Volunteer'>&#9684;</span>"
# 25 or higher is paying, show a check
end
if self.member >= 25 then
output = "<span class='hoverinfo' title='25'>&#9681;</span>"
end
if self.member >= 50 then
output = "<span class='hoverinfo' title='50'>&#9685;</span>"
end
if self.member >= 100 then
output = "<span class='hoverinfo' title='100'>&#9679;</span>"
end
if self.member < self.member_level.to_i then
output = "<span class='hoverinfo' title='Lapsed'>&#x2717;</span>"
end
end
return output
end
end

View File

@ -42,9 +42,9 @@
</td><% end %>
<td><%= unless user.waiver.blank? then raw("<span class='hoverinfo' title='"+user.waiver.strftime("%B %d %Y")+"'>&#x2713;</span>") end %></td>
<td><%= raw(user.member_status) %></td>
<td><%= unless user.cards.blank? then raw("&#x2713;") end %></td>
<td><%= if user.instructor? then raw("&#x2713;") end %></td>
<td><%= if user.admin? then raw("&#x2713;") end %></td>
<td><%= unless user.cards.blank? then raw("<span class='iconinfo'>&#x2713;</span>") end %></td>
<td><%= if user.instructor? then raw("<span class='iconinfo'>&#x2713;</a>") end %></td>
<td><%= if user.admin? then raw("<span class='iconinfo'>&#x2713;</a>") end %></td>
<td><%= link_to 'Edit', edit_user_path(user) if can? :update, user %></td>
<td><%= link_to 'Destroy', user, :confirm => 'Are you sure? WARNING: THIS DOES NOT REMOVE THE USER FROM THE DOOR SYSTEM! DISABLE THEM FIRST.', :method => :delete if can? :destroy, user %></td>
</tr>