remove trailing white-spaces from app/models/enumeration.rb.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6501 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
2dc684c486
commit
8be05afff8
|
@ -1,31 +1,31 @@
|
||||||
# redMine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class Enumeration < ActiveRecord::Base
|
class Enumeration < ActiveRecord::Base
|
||||||
default_scope :order => "#{Enumeration.table_name}.position ASC"
|
default_scope :order => "#{Enumeration.table_name}.position ASC"
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
|
||||||
acts_as_list :scope => 'type = \'#{type}\''
|
acts_as_list :scope => 'type = \'#{type}\''
|
||||||
acts_as_customizable
|
acts_as_customizable
|
||||||
acts_as_tree :order => 'position ASC'
|
acts_as_tree :order => 'position ASC'
|
||||||
|
|
||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name, :scope => [:type, :project_id]
|
validates_uniqueness_of :name, :scope => [:type, :project_id]
|
||||||
validates_length_of :name, :maximum => 30
|
validates_length_of :name, :maximum => 30
|
||||||
|
@ -45,7 +45,7 @@ class Enumeration < ActiveRecord::Base
|
||||||
find(:first, :conditions => { :is_default => true })
|
find(:first, :conditions => { :is_default => true })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Overloaded on concrete classes
|
# Overloaded on concrete classes
|
||||||
def option_name
|
def option_name
|
||||||
nil
|
nil
|
||||||
|
@ -56,12 +56,12 @@ class Enumeration < ActiveRecord::Base
|
||||||
Enumeration.update_all("is_default = #{connection.quoted_false}", {:type => type})
|
Enumeration.update_all("is_default = #{connection.quoted_false}", {:type => type})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Overloaded on concrete classes
|
# Overloaded on concrete classes
|
||||||
def objects_count
|
def objects_count
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
def in_use?
|
def in_use?
|
||||||
self.objects_count != 0
|
self.objects_count != 0
|
||||||
end
|
end
|
||||||
|
@ -70,9 +70,9 @@ class Enumeration < ActiveRecord::Base
|
||||||
def is_override?
|
def is_override?
|
||||||
!self.parent.nil?
|
!self.parent.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
alias :destroy_without_reassign :destroy
|
alias :destroy_without_reassign :destroy
|
||||||
|
|
||||||
# Destroy the enumeration
|
# Destroy the enumeration
|
||||||
# If a enumeration is specified, objects are reassigned
|
# If a enumeration is specified, objects are reassigned
|
||||||
def destroy(reassign_to = nil)
|
def destroy(reassign_to = nil)
|
||||||
|
@ -81,11 +81,11 @@ class Enumeration < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
destroy_without_reassign
|
destroy_without_reassign
|
||||||
end
|
end
|
||||||
|
|
||||||
def <=>(enumeration)
|
def <=>(enumeration)
|
||||||
position <=> enumeration.position
|
position <=> enumeration.position
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s; name end
|
def to_s; name end
|
||||||
|
|
||||||
# Returns the Subclasses of Enumeration. Each Subclass needs to be
|
# Returns the Subclasses of Enumeration. Each Subclass needs to be
|
||||||
|
@ -115,13 +115,13 @@ class Enumeration < ActiveRecord::Base
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Are the new and previous fields equal?
|
# Are the new and previous fields equal?
|
||||||
def self.same_active_state?(new, previous)
|
def self.same_active_state?(new, previous)
|
||||||
new = (new == "1" ? true : false)
|
new = (new == "1" ? true : false)
|
||||||
return new == previous
|
return new == previous
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def check_integrity
|
def check_integrity
|
||||||
raise "Can't delete enumeration" if self.in_use?
|
raise "Can't delete enumeration" if self.in_use?
|
||||||
|
|
Loading…
Reference in New Issue