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:
parent
96a748ba0b
commit
6957ab7ac1
|
@ -5,7 +5,8 @@ class DoorLogsController < ApplicationController
|
||||||
# GET /door_logs
|
# GET /door_logs
|
||||||
# GET /door_logs.json
|
# GET /door_logs.json
|
||||||
def index
|
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
|
begin
|
||||||
|
|
|
@ -18,7 +18,8 @@ class UsersController < ApplicationController
|
||||||
def index
|
def index
|
||||||
unless params[:full] # by default, show summary
|
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
|
#.joins(:payments).where("payments.date > ? OR ", (DateTime.now - 60.days)).uniq
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -30,23 +31,23 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
case params[:sort]
|
case params[:sort]
|
||||||
when "name"
|
when "name"
|
||||||
@users = @users.sort_by(&:name)
|
@users = @users.sort_by{ |u| u.name.downcase }
|
||||||
when "cert"
|
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"
|
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"
|
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"
|
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"
|
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"
|
when "instructor"
|
||||||
@users = @users.sort{ |a,b| [b.instructor.to_s,a.name] <=> [a.instructor.to_s,b.name] }
|
@users = @users.sort{ |a,b| [b.instructor.to_s,a.name] <=> [a.instructor.to_s,b.name] }
|
||||||
when "admin"
|
when "admin"
|
||||||
@users = @users.sort{ |a,b| [b.admin.to_s,a.name] <=> [a.admin.to_s,b.name] }
|
@users = @users.sort{ |a,b| [b.admin.to_s,a.name] <=> [a.admin.to_s,b.name] }
|
||||||
else
|
else
|
||||||
@users = @users.sort_by(&:name)
|
@users = @users.sort_by{ |u| u.name.downcase }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ class User < ActiveRecord::Base
|
||||||
has_many :resources
|
has_many :resources
|
||||||
|
|
||||||
scope :volunteer, -> { where('member_level >= 10 AND member_level < 25') }
|
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 }
|
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
|
validates_format_of [:twitter_url, :facebook_url, :github_url, :website_url], :with => URI::regexp(%w(http https)), :allow_blank => true
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="users">
|
<div class="users">
|
||||||
<%= render @users.sort_by{|u| [-u.member_status, u.name] } %>
|
<%= render @users %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if current_user.orientation.blank? then %>
|
<% if current_user.orientation.blank? then %>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user