##// END OF EJS Templates
Code cleanup....
Jean-Philippe Lang -
r10660:9a270c46c0aa
parent child
Show More
@@ -27,7 +27,7 class IssueCategory < ActiveRecord::Base
27
27
28 safe_attributes 'name', 'assigned_to_id'
28 safe_attributes 'name', 'assigned_to_id'
29
29
30 scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
30 scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
31
31
32 alias :destroy_without_reassign :destroy
32 alias :destroy_without_reassign :destroy
33
33
@@ -29,7 +29,7 class IssueStatus < ActiveRecord::Base
29 validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
29 validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
30
30
31 scope :sorted, order("#{table_name}.position ASC")
31 scope :sorted, order("#{table_name}.position ASC")
32 scope :named, lambda {|arg| where(["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip])}
32 scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
33
33
34 def update_default
34 def update_default
35 IssueStatus.update_all({:is_default => false}, ['id <> ?', id]) if self.is_default?
35 IssueStatus.update_all({:is_default => false}, ['id <> ?', id]) if self.is_default?
@@ -35,10 +35,11 class Version < ActiveRecord::Base
35 validates_inclusion_of :sharing, :in => VERSION_SHARINGS
35 validates_inclusion_of :sharing, :in => VERSION_SHARINGS
36 validate :validate_version
36 validate :validate_version
37
37
38 scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}}
38 scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
39 scope :open, :conditions => {:status => 'open'}
39 scope :open, where(:status => 'open')
40 scope :visible, lambda {|*args| { :include => :project,
40 scope :visible, lambda {|*args|
41 :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
41 includes(:project).where(Project.allowed_to_condition(args.first || User.current, :view_issues))
42 }
42
43
43 safe_attributes 'name',
44 safe_attributes 'name',
44 'description',
45 'description',
@@ -79,7 +80,7 class Version < ActiveRecord::Base
79
80
80 # Returns the total reported time for this version
81 # Returns the total reported time for this version
81 def spent_hours
82 def spent_hours
82 @spent_hours ||= TimeEntry.sum(:hours, :joins => :issue, :conditions => ["#{Issue.table_name}.fixed_version_id = ?", id]).to_f
83 @spent_hours ||= TimeEntry.joins(:issue).where("#{Issue.table_name}.fixed_version_id = ?", id).sum(:hours).to_f
83 end
84 end
84
85
85 def closed?
86 def closed?
General Comments 0
You need to be logged in to leave comments. Login now