From ec139a97a8d24e5797ae7635311a4df20254526d Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Mon, 23 Sep 2013 20:24:38 -0700 Subject: [PATCH] Separating certs into columns --- app/controllers/users_controller.rb | 14 ++++++++++++-- app/views/users/index.html.erb | 29 +++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b0025d6..f7382bf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,14 +2,24 @@ class UsersController < ApplicationController load_and_authorize_resource before_filter :authenticate_user! + def sort_by_cert(certs,id) + result = 0 + certs.each do |c| + if c.id == id + result = 1 + end + end + return result + end + # GET /users # GET /users.json def index case params[:sort] when "name" @users = @users.sort_by(&:name) - when "certifications" - @users = @users.sort_by{ |u| [-u.certifications.count,u.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" diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index e49a361..941dbdd 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -10,30 +10,37 @@ | <%= link_to 'Inactive Users', users_inactive_path %> | <%= link_to 'Recent Activity', users_activity_path %> <% end %> +<% @certifications = Certification.all.sort_by(&:id) %> <% if current_user.admin? then %><% end %> - + <% if current_user.admin? %><% end %> - + <% col_count = 0 %> + <% @certifications.each do |c| %> + class="col_highlight"<% end %> /> + <% col_count = col_count + 1 %> + <% end %> + <% if current_user.admin? then %><% end %> - <% if current_user.admin? then %> <% end %> - <% if current_user.admin? then %><% end %> + <% @certifications.each do |c| %> + + <% end %> @@ -43,18 +50,24 @@ + <% if current_user.admin? then %><% end %> - <% if current_user.admin? then %><% end %> - <% if current_user.admin? then %><% end %> + <% @certifications.each do |c| %> + + <% end %>
NameMember?EmailCertificationsOrientation?Waiver?Member? Card? Instructor?Admin?<%= c.name %>
<%= image_tag user.gravatar_url(:default => "http://members.heatsynclabs.org/assets/nil.png"), :class => :avatar %> <%= link_to user.name, user %><%= raw(user.member_status_symbol) %><%= user.email %><% user.certifications.each do |c| %> - <%= link_to c.name, c %><%= "," unless c.id == user.certifications.last.id %> - <% end %> <%= unless user.orientation.blank? then raw("") end %> <%= unless user.waiver.blank? then raw("") end %><%= raw(user.member_status_symbol) %> <%= unless user.cards.blank? then raw("") end %> <%= if user.instructor? then raw("✓") end %><%= if user.admin? then raw("✓") end %> + <% user.user_certifications.each do |u| %> + <% if u.certification_id == c.id %> + <%= link_to raw(""), u %> + <% end %> + <% end %> + <%= link_to 'Edit', edit_user_path(user) if can? :update, user %> <%= 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 %>