Changes misleading scopes on Enumeration.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3083 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2009-11-21 12:00:49 +00:00
parent 4bdfef4dc4
commit d8c5549168
4 changed files with 11 additions and 19 deletions

View File

@ -38,7 +38,7 @@ module TimelogHelper
def activity_collection_for_select_options(time_entry=nil, project=nil)
project ||= @project
if project.nil?
activities = TimeEntryActivity.active
activities = TimeEntryActivity.shared.active
else
activities = project.activities
end

View File

@ -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

View File

@ -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

View File

@ -3,7 +3,7 @@
<% Enumeration.get_subclasses.each do |klass| %>
<h3><%= l(klass::OptionName) %></h3>
<% enumerations = klass.all %>
<% enumerations = klass.shared %>
<% if enumerations.any? %>
<table class="list">
<tr>