Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10887 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e43448f6ca
commit
9a270c46c0
|
@ -27,7 +27,7 @@ class IssueCategory < ActiveRecord::Base
|
|||
|
||||
safe_attributes 'name', 'assigned_to_id'
|
||||
|
||||
scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
|
||||
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
|
||||
|
||||
alias :destroy_without_reassign :destroy
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class IssueStatus < ActiveRecord::Base
|
|||
validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
|
||||
|
||||
scope :sorted, order("#{table_name}.position ASC")
|
||||
scope :named, lambda {|arg| where(["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip])}
|
||||
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
|
||||
|
||||
def update_default
|
||||
IssueStatus.update_all({:is_default => false}, ['id <> ?', id]) if self.is_default?
|
||||
|
|
|
@ -35,10 +35,11 @@ class Version < ActiveRecord::Base
|
|||
validates_inclusion_of :sharing, :in => VERSION_SHARINGS
|
||||
validate :validate_version
|
||||
|
||||
scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
|
||||
scope :open, :conditions => {:status => 'open'}
|
||||
scope :visible, lambda {|*args| { :include => :project,
|
||||
:conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
|
||||
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
|
||||
scope :open, where(:status => 'open')
|
||||
scope :visible, lambda {|*args|
|
||||
includes(:project).where(Project.allowed_to_condition(args.first || User.current, :view_issues))
|
||||
}
|
||||
|
||||
safe_attributes 'name',
|
||||
'description',
|
||||
|
@ -79,7 +80,7 @@ class Version < ActiveRecord::Base
|
|||
|
||||
# Returns the total reported time for this version
|
||||
def spent_hours
|
||||
@spent_hours ||= TimeEntry.sum(:hours, :joins => :issue, :conditions => ["#{Issue.table_name}.fixed_version_id = ?", id]).to_f
|
||||
@spent_hours ||= TimeEntry.joins(:issue).where("#{Issue.table_name}.fixed_version_id = ?", id).sum(:hours).to_f
|
||||
end
|
||||
|
||||
def closed?
|
||||
|
|
Loading…
Reference in New Issue