summaryrefslogtreecommitdiffstats
path: root/app/models/time_entry_activity.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/time_entry_activity.rb')
-rw-r--r--app/models/time_entry_activity.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/time_entry_activity.rb b/app/models/time_entry_activity.rb
index f4562a8e1..d988129c9 100644
--- a/app/models/time_entry_activity.rb
+++ b/app/models/time_entry_activity.rb
@@ -22,6 +22,16 @@ class TimeEntryActivity < Enumeration
OptionName = :enumeration_activities
+ def self.default(project=nil)
+ default_activity = super()
+
+ if default_activity.nil? || project.nil? || project.activities.blank? || project.activities.include?(default_activity)
+ return default_activity
+ end
+
+ project.activities.detect { |activity| activity.parent_id == default_activity.id }
+ end
+
def option_name
OptionName
end