summaryrefslogtreecommitdiffstats
path: root/app/models/time_entry_activity.rb
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2022-06-20 15:26:47 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2022-06-20 15:26:47 +0000
commitbfcb1b0054ce6ab397025622c4e7309bc8e1dbcb (patch)
treef0fd76f0112da704a3999cf43643204164d4126d /app/models/time_entry_activity.rb
parente0f0f2c210e0c05a28beb20ede23143fc302f0a6 (diff)
downloadredmine-bfcb1b0054ce6ab397025622c4e7309bc8e1dbcb.tar.gz
redmine-bfcb1b0054ce6ab397025622c4e7309bc8e1dbcb.zip
Fix time entry activity is not set as default when the default activity exists as project specific activity (#33914).
Patch by Mizuki ISHIKAWA. git-svn-id: https://svn.redmine.org/redmine/trunk@21668 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/time_entry_activity.rb')
-rw-r--r--app/models/time_entry_activity.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/time_entry_activity.rb b/app/models/time_entry_activity.rb
index 973ec923f..a0be39469 100644
--- a/app/models/time_entry_activity.rb
+++ b/app/models/time_entry_activity.rb
@@ -22,6 +22,15 @@ class TimeEntryActivity < Enumeration
OptionName = :enumeration_activities
+ def self.default(project=nil)
+ default_activity = super()
+ if project.nil? || project.activities.blank? || project.activities.include?(default_activity)
+ return default_activity
+ end
+
+ project.activities.find_by(parent_id: default_activity.id)
+ end
+
def option_name
OptionName
end