Fix logging time via a commit message for project specific activities (#29838).

Patch by Jens Krämer.


git-svn-id: http://svn.redmine.org/redmine/trunk@19512 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2020-02-11 13:33:22 +00:00
parent 39c979b341
commit 777704249f
3 changed files with 42 additions and 8 deletions

View File

@@ -259,7 +259,9 @@ class Changeset < ActiveRecord::Base
:comments => l(:text_time_logged_by_changeset, :value => text_tag(issue.project),
:locale => Setting.default_language)
)
time_entry.activity = log_time_activity unless log_time_activity.nil?
if activity = issue.project.commit_logtime_activity
time_entry.activity = activity
end
unless time_entry.save
logger.warn("TimeEntry could not be created by changeset #{id}: #{time_entry.errors.full_messages}") if logger
@@ -267,12 +269,6 @@ class Changeset < ActiveRecord::Base
time_entry
end
def log_time_activity
if Setting.commit_logtime_activity_id.to_i > 0
TimeEntryActivity.find_by_id(Setting.commit_logtime_activity_id.to_i)
end
end
def split_comments
comments =~ /\A(.+?)\r?\n(.*)$/m
@short_comments = $1 || comments

View File

@@ -295,6 +295,15 @@ class Project < ActiveRecord::Base
end
end
# returns the time log activity to be used when logging time via a changeset
def commit_logtime_activity
activity_id = Setting.commit_logtime_activity_id.to_i
if activity_id > 0
activities
.find_by('id = ? OR parent_id = ?', activity_id, activity_id)
end
end
# Returns a :conditions SQL string that can be used to find the issues associated with this project.
#
# Examples: