add support for changing task item.
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-01-17 19:48:05 +01:00
parent eeba5bc9c8
commit 197fe227a4
4 changed files with 25 additions and 2 deletions
+18
View File
@@ -86,6 +86,24 @@ func Task(g *gin.RouterGroup, db database.Database) {
return nil, err
}
if update.ItemID != nil && *update.ItemID != task.ItemID {
_, err := l.FindItem(c.Request.Context(), *update.ItemID)
if err != nil {
return nil, err
}
logs, err := l.ListLogs(c.Request.Context(), models.LogFilter{
TaskIDs: []string{task.ID},
})
if err != nil {
return nil, err
}
if len(logs) > 0 {
return nil, slerrors.Forbidden("You cannot change the item if the task has logs.")
}
}
task.Update(update)
if task.EndTime != nil && task.EndTime.Before(task.CreatedTime) {
return nil, slerrors.BadRequest("Task end time must be later than it was created.")