@@ -38,7 +38,7 module TimelogHelper | |||
|
38 | 38 | def activity_collection_for_select_options(time_entry=nil, project=nil) |
|
39 | 39 | project ||= @project |
|
40 | 40 | if project.nil? |
|
41 | activities = TimeEntryActivity.active | |
|
41 | activities = TimeEntryActivity.shared.active | |
|
42 | 42 | else |
|
43 | 43 | activities = project.activities |
|
44 | 44 | end |
@@ -16,6 +16,8 | |||
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class Enumeration < ActiveRecord::Base |
|
19 | default_scope :order => "#{Enumeration.table_name}.position ASC" | |
|
20 | ||
|
19 | 21 | belongs_to :project |
|
20 | 22 | |
|
21 | 23 | acts_as_list :scope => 'type = \'#{type}\'' |
@@ -58,14 +60,8 class Enumeration < ActiveRecord::Base | |||
|
58 | 60 | end |
|
59 | 61 | # End backwards compatiblity named_scopes |
|
60 | 62 | |
|
61 |
named_scope : |
|
|
62 | ||
|
63 | named_scope :active, lambda { | |
|
64 | { | |
|
65 | :conditions => {:active => true, :project_id => nil}, | |
|
66 | :order => 'position' | |
|
67 | } | |
|
68 | } | |
|
63 | named_scope :shared, :conditions => { :project_id => nil } | |
|
64 | named_scope :active, :conditions => { :active => true } | |
|
69 | 65 | |
|
70 | 66 | def self.default |
|
71 | 67 | # Creates a fake default scope so Enumeration.default will check |
@@ -21,11 +21,7 class Project < ActiveRecord::Base | |||
|
21 | 21 | STATUS_ARCHIVED = 9 |
|
22 | 22 | |
|
23 | 23 | # Specific overidden Activities |
|
24 |
has_many :time_entry_activities |
|
|
25 | def active | |
|
26 | find(:all, :conditions => {:active => true}) | |
|
27 | end | |
|
28 | end | |
|
24 | has_many :time_entry_activities | |
|
29 | 25 | has_many :members, :include => [:user, :roles], :conditions => "#{User.table_name}.type='User' AND #{User.table_name}.status=#{User::STATUS_ACTIVE}" |
|
30 | 26 | has_many :member_principals, :class_name => 'Member', |
|
31 | 27 | :include => :principal, |
@@ -572,7 +568,7 class Project < ActiveRecord::Base | |||
|
572 | 568 | overridden_activity_ids = self.time_entry_activities.active.collect(&:parent_id) |
|
573 | 569 | |
|
574 | 570 | if overridden_activity_ids.empty? |
|
575 | return TimeEntryActivity.active | |
|
571 | return TimeEntryActivity.shared.active | |
|
576 | 572 | else |
|
577 | 573 | return system_activities_and_project_overrides |
|
578 | 574 | end |
@@ -584,7 +580,7 class Project < ActiveRecord::Base | |||
|
584 | 580 | overridden_activity_ids = self.time_entry_activities.collect(&:parent_id) |
|
585 | 581 | |
|
586 | 582 | if overridden_activity_ids.empty? |
|
587 |
return TimeEntryActivity. |
|
|
583 | return TimeEntryActivity.shared | |
|
588 | 584 | else |
|
589 | 585 | return system_activities_and_project_overrides(true) |
|
590 | 586 | end |
@@ -593,12 +589,12 class Project < ActiveRecord::Base | |||
|
593 | 589 | # Returns the systemwide active activities merged with the project specific overrides |
|
594 | 590 | def system_activities_and_project_overrides(include_inactive=false) |
|
595 | 591 | if include_inactive |
|
596 |
return TimeEntryActivity. |
|
|
592 | return TimeEntryActivity.shared. | |
|
597 | 593 | find(:all, |
|
598 | 594 | :conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) + |
|
599 | 595 | self.time_entry_activities |
|
600 | 596 | else |
|
601 | return TimeEntryActivity.active. | |
|
597 | return TimeEntryActivity.shared.active. | |
|
602 | 598 | find(:all, |
|
603 | 599 | :conditions => ["id NOT IN (?)", self.time_entry_activities.active.collect(&:parent_id)]) + |
|
604 | 600 | self.time_entry_activities.active |
General Comments 0
You need to be logged in to leave comments.
Login now