summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-11-21 12:00:49 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-11-21 12:00:49 +0000
commitd8c5549168f3fe7e9f2b1633e70928178665773a (patch)
tree952fc56cbd0f0c5f6b3b7e81c4a50e905f859597 /app/models
parent4bdfef4dc4e09f9ccc4cb3cd3bfbc00d553017b5 (diff)
downloadredmine-d8c5549168f3fe7e9f2b1633e70928178665773a.tar.gz
redmine-d8c5549168f3fe7e9f2b1633e70928178665773a.zip
Changes misleading scopes on Enumeration.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3083 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/enumeration.rb12
-rw-r--r--app/models/project.rb14
2 files changed, 9 insertions, 17 deletions
diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb
index f219a4c7c..4836229b1 100644
--- a/app/models/enumeration.rb
+++ b/app/models/enumeration.rb
@@ -16,6 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class Enumeration < ActiveRecord::Base
+ default_scope :order => "#{Enumeration.table_name}.position ASC"
+
belongs_to :project
acts_as_list :scope => 'type = \'#{type}\''
@@ -58,14 +60,8 @@ class Enumeration < ActiveRecord::Base
end
# End backwards compatiblity named_scopes
- named_scope :all, :order => 'position', :conditions => { :project_id => nil }
-
- named_scope :active, lambda {
- {
- :conditions => {:active => true, :project_id => nil},
- :order => 'position'
- }
- }
+ named_scope :shared, :conditions => { :project_id => nil }
+ named_scope :active, :conditions => { :active => true }
def self.default
# Creates a fake default scope so Enumeration.default will check
diff --git a/app/models/project.rb b/app/models/project.rb
index 410cb2154..8829f04ad 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -21,11 +21,7 @@ class Project < ActiveRecord::Base
STATUS_ARCHIVED = 9
# Specific overidden Activities
- has_many :time_entry_activities do
- def active
- find(:all, :conditions => {:active => true})
- end
- end
+ has_many :time_entry_activities
has_many :members, :include => [:user, :roles], :conditions => "#{User.table_name}.type='User' AND #{User.table_name}.status=#{User::STATUS_ACTIVE}"
has_many :member_principals, :class_name => 'Member',
:include => :principal,
@@ -572,7 +568,7 @@ class Project < ActiveRecord::Base
overridden_activity_ids = self.time_entry_activities.active.collect(&:parent_id)
if overridden_activity_ids.empty?
- return TimeEntryActivity.active
+ return TimeEntryActivity.shared.active
else
return system_activities_and_project_overrides
end
@@ -584,7 +580,7 @@ class Project < ActiveRecord::Base
overridden_activity_ids = self.time_entry_activities.collect(&:parent_id)
if overridden_activity_ids.empty?
- return TimeEntryActivity.all
+ return TimeEntryActivity.shared
else
return system_activities_and_project_overrides(true)
end
@@ -593,12 +589,12 @@ class Project < ActiveRecord::Base
# Returns the systemwide active activities merged with the project specific overrides
def system_activities_and_project_overrides(include_inactive=false)
if include_inactive
- return TimeEntryActivity.all.
+ return TimeEntryActivity.shared.
find(:all,
:conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) +
self.time_entry_activities
else
- return TimeEntryActivity.active.
+ return TimeEntryActivity.shared.active.
find(:all,
:conditions => ["id NOT IN (?)", self.time_entry_activities.active.collect(&:parent_id)]) +
self.time_entry_activities.active