Commit 1ecf0949 by Thanh Hung Pham

Auto logtime when create new or update task

parent c5e74175
Pipeline #640 failed with stages
in 0 seconds
module AutoTimelog extend ActiveSupport::Concern
# Auto create timelog tracking (26/05/2020)
def auto_create_timelog(issue)
time_entry = TimeEntry.find_by(:project => @project, :issue => issue, :user => User.current, :spent_on => User.current.today)
return if time_entry
time_entry = TimeEntry.new(:project => @project, :issue => issue, :user => User.current, :spent_on => User.current.today)
time_entry.hours = 0.5
time_entry.comments = 'Logtime Tracking!'
time_entry.activity_id = 11 #Requirement
time_entry.activity_id = 29 if issue.tracker_id == 3 #Support
time_entry.save!
end
end
......@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class IssuesController < ApplicationController
include AutoTimelog
default_search_scope :issues
before_action :find_issue, :only => [:show, :edit, :update]
......@@ -139,6 +140,7 @@ class IssuesController < ApplicationController
end
auto_create_subtasks(@issue)
auto_create_timelog(@issue) if @issue.tracker_id != 12 # Auto create timelog tracking (26/05/2020)
return
else
......@@ -196,6 +198,8 @@ class IssuesController < ApplicationController
auto_delete_subtasks(@issue)
end
auto_create_timelog(@issue) # Auto create timelog tracking (26/05/2020)
else
respond_to do |format|
format.html { render :action => 'edit' }
......@@ -623,8 +627,11 @@ class IssuesController < ApplicationController
subtask.parent_issue_id = @issue.id
subtask.estimated_hours = nil
subtask.save!
auto_create_timelog(subtask) if subtask_title == "Requirement" # Auto create timelog tracking (26/05/2020)
end
end
# Auto delete 8 subtasks (13/08/2018)
def auto_delete_subtasks(issue)
exclude_project_ids = [106, 107, 108, 109, 110, 111] #2zigexn
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment