Door log filtering, user case-insensitive and status-insensitive sorting, new user scope

Presumably changed by meznak or blhack, not myself
This commit is contained in:
Will Bradley 2016-09-12 20:56:31 -07:00
parent 96a748ba0b
commit 6957ab7ac1
4 changed files with 13 additions and 10 deletions

View File

@ -5,7 +5,8 @@ class DoorLogsController < ApplicationController
# GET /door_logs
# GET /door_logs.json
def index
@door_logs = DoorLog.find(:all, :order => "created_at DESC", :limit => 1000)
# @door_logs = DoorLog.find(:all, :order => "created_at DESC", :limit => 1000)
@door_logs = DoorLog.where("key NOT LIKE 'alarm%' AND key != 'armed' AND key != 'activated'").order("created_at DESC").limit(1000)
begin

View File

@ -18,7 +18,8 @@ class UsersController < ApplicationController
def index
unless params[:full] # by default, show summary
@users = @users.paying + @users.volunteer
@users = @users.active.sort_by{|u| [-u.member_level, u.name.downcase] }
#@users.paying + @users.volunteer
#.joins(:payments).where("payments.date > ? OR ", (DateTime.now - 60.days)).uniq
respond_to do |format|
@ -30,23 +31,23 @@ class UsersController < ApplicationController
case params[:sort]
when "name"
@users = @users.sort_by(&:name)
@users = @users.sort_by{ |u| u.name.downcase }
when "cert"
@users = @users.sort_by{ |u| [-sort_by_cert(u.certifications,params[:cert].to_i),u.name] }
@users = @users.sort_by{ |u| [-sort_by_cert(u.certifications,params[:cert].to_i),u.name.downcase] }
when "orientation"
@users = @users.sort_by{ |u| [-u.orientation.to_i,u.name] }
@users = @users.sort_by{ |u| [-u.orientation.to_i,u.name.downcase] }
when "waiver"
@users = @users.sort_by{ |u| [-u.contract_date.to_i,u.name] }
@users = @users.sort_by{ |u| [-u.contract_date.to_i,u.name.downcase] }
when "member"
@users = @users.sort_by{ |u| [-u.member_status.to_i,u.name] }
@users = @users.sort_by{ |u| [-u.member_status.to_i,u.name.downcase] }
when "card"
@users = @users.sort_by{ |u| [-u.cards.count,u.name] }
@users = @users.sort_by{ |u| [-u.cards.count,u.name.downcase] }
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)
@users = @users.sort_by{ |u| u.name.downcase }
end

View File

@ -21,6 +21,7 @@ class User < ActiveRecord::Base
has_many :resources
scope :volunteer, -> { where('member_level >= 10 AND member_level < 25') }
scope :active, -> { where('member_level >= 10') }
scope :paying, -> { joins(:payments).where("payments.date > ?", (DateTime.now - 90.days)).uniq }
validates_format_of [:twitter_url, :facebook_url, :github_url, :website_url], :with => URI::regexp(%w(http https)), :allow_blank => true

View File

@ -36,7 +36,7 @@
<div class="users">
<%= render @users.sort_by{|u| [-u.member_status, u.name] } %>
<%= render @users %>
</div>
<% if current_user.orientation.blank? then %>