Creating user summary page
This commit is contained in:
parent
8425aaecd2
commit
d943adc458
|
@ -19,16 +19,6 @@ pre {
|
|||
font-size: 11px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #000;
|
||||
&:visited {
|
||||
color: #666;
|
||||
}
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background-color: #000;
|
||||
}
|
||||
}
|
||||
|
||||
div {
|
||||
&.field, &.actions {
|
||||
|
|
|
@ -15,31 +15,43 @@ class UsersController < ApplicationController
|
|||
# GET /users
|
||||
# GET /users.json
|
||||
def index
|
||||
case params[:sort]
|
||||
when "name"
|
||||
@users = @users.sort_by(&:name)
|
||||
when "cert"
|
||||
@users = @users.sort_by{ |u| [-sort_by_cert(u.certifications,params[:cert].to_i),u.name] }
|
||||
when "orientation"
|
||||
@users = @users.sort_by{ |u| [-u.orientation.to_i,u.name] }
|
||||
when "waiver"
|
||||
@users = @users.sort_by{ |u| [-u.waiver.to_i,u.name] }
|
||||
when "member"
|
||||
@users = @users.sort_by{ |u| [-u.member_status.to_i,u.name] }
|
||||
when "card"
|
||||
@users = @users.sort_by{ |u| [-u.cards.count,u.name] }
|
||||
when "instructor"
|
||||
@users = @users.sort{ |a,b| [b.instructor.to_s,a.name] <=> [a.instructor.to_s,b.name] }
|
||||
when "admin"
|
||||
@users = @users.sort{ |a,b| [b.admin.to_s,a.name] <=> [a.admin.to_s,b.name] }
|
||||
else
|
||||
@users = @users.sort_by(&:name)
|
||||
end
|
||||
unless params[:full] # by default, show summary
|
||||
|
||||
@users = @users.joins(:payments).where("payments.date > ?", (DateTime.now - 60.days)).uniq
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render 'summary' }
|
||||
format.json { render :json => @users }
|
||||
end
|
||||
|
||||
else # show full
|
||||
|
||||
case params[:sort]
|
||||
when "name"
|
||||
@users = @users.sort_by(&:name)
|
||||
when "cert"
|
||||
@users = @users.sort_by{ |u| [-sort_by_cert(u.certifications,params[:cert].to_i),u.name] }
|
||||
when "orientation"
|
||||
@users = @users.sort_by{ |u| [-u.orientation.to_i,u.name] }
|
||||
when "waiver"
|
||||
@users = @users.sort_by{ |u| [-u.waiver.to_i,u.name] }
|
||||
when "member"
|
||||
@users = @users.sort_by{ |u| [-u.member_status.to_i,u.name] }
|
||||
when "card"
|
||||
@users = @users.sort_by{ |u| [-u.cards.count,u.name] }
|
||||
when "instructor"
|
||||
@users = @users.sort{ |a,b| [b.instructor.to_s,a.name] <=> [a.instructor.to_s,b.name] }
|
||||
when "admin"
|
||||
@users = @users.sort{ |a,b| [b.admin.to_s,a.name] <=> [a.admin.to_s,b.name] }
|
||||
else
|
||||
@users = @users.sort_by(&:name)
|
||||
end
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render :json => @users }
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render :json => @users }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class User < ActiveRecord::Base
|
||||
include Gravtastic
|
||||
gravtastic :size => 120, :default => ""
|
||||
gravtastic :size => 150, :default => ""
|
||||
|
||||
# Include default devise modules. Others available are:
|
||||
# :token_authenticatable, :confirmable,
|
||||
|
|
6
app/views/users/_user.html.erb
Normal file
6
app/views/users/_user.html.erb
Normal file
|
@ -0,0 +1,6 @@
|
|||
<div class="thumbnail col-lg-1 col-sm-2 col-xs-4">
|
||||
<%= image_tag user.gravatar_url(:default => "http://members.heatsynclabs.org/pirate.jpg") %>
|
||||
<span class="badges"><%= raw(user.member_status_symbol) %></span>
|
||||
|
||||
<h4><%= link_to user.name, user %></h4>
|
||||
</div>
|
45
app/views/users/summary.html.erb
Executable file
45
app/views/users/summary.html.erb
Executable file
|
@ -0,0 +1,45 @@
|
|||
<link href="/bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
|
||||
<link href="/bootstrap/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" />
|
||||
<script src="/bootstrap/js/bootstrap.min.js" type="text/javascript" ></script>
|
||||
|
||||
<style type="text/css">
|
||||
.users .thumbnail {
|
||||
height: 200px;
|
||||
position: relative;
|
||||
}
|
||||
.users .badges { position: absolute; top: 125px; }
|
||||
.users .thumbnail h4 { position: absolute; bottom: 1px; margin-bottom: 1px; }
|
||||
|
||||
</style>
|
||||
|
||||
<h1>HeatSync People
|
||||
<%= link_to 'Full Table View', {:controller => "users", :full => "full"}, class: "btn btn-primary" %>
|
||||
</h1>
|
||||
|
||||
<% if can? :create, User %>
|
||||
<%= link_to 'New User', new_user_path %> |
|
||||
<% end %>
|
||||
<% if can? :manage, User %>
|
||||
<%= link_to 'Merge Users', users_merge_path %> |
|
||||
<% end %>
|
||||
<% if current_user.admin? %>
|
||||
<%= link_to 'Inactive Users', users_inactive_path %> |
|
||||
<% end %>
|
||||
<% if can? :activity, User %>
|
||||
<%= link_to 'Recent Activity', users_activity_path %> |
|
||||
<% end %>
|
||||
<% if can? :new_member_report, User %>
|
||||
<%= link_to 'New Members Report', users_new_member_report_path %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
<div class="users">
|
||||
<%= render @users.sort_by(&:member_status).reverse %>
|
||||
</div>
|
||||
|
||||
<% if current_user.orientation.blank? then %>
|
||||
<p class="alert">There's a lot more to see here, but our records show you haven't completed the new member orientation yet. If that's incorrect, please contact a volunteer.</p>
|
||||
<% end %>
|
||||
|
||||
<br />
|
BIN
public/pirate.jpg
Normal file
BIN
public/pirate.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Loading…
Reference in New Issue
Block a user