# 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}\''
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
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,
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
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
# 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