mirror of
https://github.com/redmine/redmine.git
synced 2025-11-09 06:46:01 +01:00
Order scopes cleanup.
git-svn-id: http://svn.redmine.org/redmine/trunk@13526 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -42,7 +42,7 @@ class CustomField < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
scope :sorted, lambda { order("#{table_name}.position ASC") }
|
||||
scope :sorted, lambda { order(:position) }
|
||||
scope :visible, lambda {|*args|
|
||||
user = args.shift || User.current
|
||||
if user.admin?
|
||||
|
||||
@@ -36,7 +36,7 @@ class Enumeration < ActiveRecord::Base
|
||||
validates_length_of :name, :maximum => 30
|
||||
|
||||
scope :shared, lambda { where(:project_id => nil) }
|
||||
scope :sorted, lambda { order("#{table_name}.position ASC") }
|
||||
scope :sorted, lambda { order(:position) }
|
||||
scope :active, lambda { where(:active => true) }
|
||||
scope :system, lambda { where(:project_id => nil) }
|
||||
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
|
||||
|
||||
@@ -32,7 +32,7 @@ class Group < Principal
|
||||
|
||||
before_destroy :remove_references_before_destroy
|
||||
|
||||
scope :sorted, lambda { order("#{table_name}.type, #{table_name}.lastname ASC") }
|
||||
scope :sorted, lambda { order(:type => :asc, :lastname => :desc) }
|
||||
scope :named, lambda {|arg| where("LOWER(#{table_name}.lastname) = LOWER(?)", arg.to_s.strip)}
|
||||
scope :givable, lambda {where(:type => 'Group')}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class IssueStatus < ActiveRecord::Base
|
||||
validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
|
||||
attr_protected :id
|
||||
|
||||
scope :sorted, lambda { order("#{table_name}.position ASC") }
|
||||
scope :sorted, lambda { order(:position) }
|
||||
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
|
||||
|
||||
def update_default
|
||||
|
||||
@@ -39,8 +39,8 @@ class Role < ActiveRecord::Base
|
||||
['own', :label_issues_visibility_own]
|
||||
]
|
||||
|
||||
scope :sorted, lambda { order("#{table_name}.builtin ASC, #{table_name}.position ASC") }
|
||||
scope :givable, lambda { order("#{table_name}.position ASC").where(:builtin => 0) }
|
||||
scope :sorted, lambda { order(:builtin, :position) }
|
||||
scope :givable, lambda { order(:position).where(:builtin => 0) }
|
||||
scope :builtin, lambda { |*args|
|
||||
compare = (args.first == true ? 'not' : '')
|
||||
where("#{compare} builtin = 0")
|
||||
|
||||
@@ -41,7 +41,7 @@ class Tracker < ActiveRecord::Base
|
||||
validates_uniqueness_of :name
|
||||
validates_length_of :name, :maximum => 30
|
||||
|
||||
scope :sorted, lambda { order("#{table_name}.position ASC") }
|
||||
scope :sorted, lambda { order(:position) }
|
||||
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
|
||||
|
||||
def to_s; name end
|
||||
|
||||
Reference in New Issue
Block a user