Merge branch '3.2-master' of github.com:warpc/rosa-build into 3.2-master
This commit is contained in:
commit
877d82aa06
|
@ -20,6 +20,6 @@ class SearchController < ApplicationController
|
||||||
|
|
||||||
def find_collection(type)
|
def find_collection(type)
|
||||||
var = :"@#{type}"
|
var = :"@#{type}"
|
||||||
instance_variable_set var, type.classify.constantize.search(params[:query]).paginate(:page => params[:page]) unless instance_variable_defined?(var)
|
instance_variable_set var, type.classify.constantize.search(params[:query]).search_order.paginate(:page => params[:page]) unless instance_variable_defined?(var)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,6 +17,7 @@ class Group < ActiveRecord::Base
|
||||||
validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ }
|
validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ }
|
||||||
validate { errors.add(:uname, :taken) if User.where('uname LIKE ?', uname).present? }
|
validate { errors.add(:uname, :taken) if User.where('uname LIKE ?', uname).present? }
|
||||||
|
|
||||||
|
scope :search_order, order("CHAR_LENGTH(uname) ASC")
|
||||||
scope :search, lambda {|q| where("uname ILIKE ?", "%#{q}%")}
|
scope :search, lambda {|q| where("uname ILIKE ?", "%#{q}%")}
|
||||||
scope :by_owner, lambda {|owner| where(:owner_id => owner.id)}
|
scope :by_owner, lambda {|owner| where(:owner_id => owner.id)}
|
||||||
scope :by_admin, lambda {|admin| joins(:relations).where(:'relations.role' => 'admin', :'relations.target_id' => admin.id, :'relations.target_type' => 'User')}
|
scope :by_admin, lambda {|admin| joins(:relations).where(:'relations.role' => 'admin', :'relations.target_id' => admin.id, :'relations.target_type' => 'User')}
|
||||||
|
|
|
@ -26,6 +26,7 @@ class Platform < ActiveRecord::Base
|
||||||
after_destroy lambda { umount_directory_for_rsync unless hidden? }
|
after_destroy lambda { umount_directory_for_rsync unless hidden? }
|
||||||
after_update :update_owner_relation
|
after_update :update_owner_relation
|
||||||
|
|
||||||
|
scope :search_order, order("CHAR_LENGTH(name) ASC")
|
||||||
scope :search, lambda {|q| where("name ILIKE ?", "%#{q}%").open}
|
scope :search, lambda {|q| where("name ILIKE ?", "%#{q}%").open}
|
||||||
scope :by_visibilities, lambda {|v| where(:visibility => v)}
|
scope :by_visibilities, lambda {|v| where(:visibility => v)}
|
||||||
scope :open, where(:visibility => 'open')
|
scope :open, where(:visibility => 'open')
|
||||||
|
|
|
@ -42,6 +42,7 @@ class User < ActiveRecord::Base
|
||||||
attr_readonly :uname
|
attr_readonly :uname
|
||||||
attr_accessor :login
|
attr_accessor :login
|
||||||
|
|
||||||
|
scope :search_order, order("CHAR_LENGTH(uname) ASC")
|
||||||
scope :search, lambda {|q| where("uname ILIKE ?", "%#{q}%")}
|
scope :search, lambda {|q| where("uname ILIKE ?", "%#{q}%")}
|
||||||
|
|
||||||
after_create lambda { self.create_notifier }
|
after_create lambda { self.create_notifier }
|
||||||
|
|
Loading…
Reference in New Issue