1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-26 11:28:27 +00:00

Fix tracked time issues (#11349) (#11354)

Backport #11349 

* Fix tracked time issues (#11349)

* Fix nil exeption: #11313

* fix 500

* activate test 😆

* move logic

* Add missing import

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
This commit is contained in:
guillep2k
2020-05-09 14:08:41 -03:00
committed by GitHub
parent dd6e604f8f
commit 0b216f40fd
3 changed files with 14 additions and 7 deletions

View File

@@ -5,6 +5,7 @@
package repo
import (
"fmt"
"net/http"
"time"
@@ -296,6 +297,10 @@ func DeleteTime(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "GetTrackedTimeByID", err)
return
}
if time.Deleted {
ctx.NotFound(fmt.Errorf("tracked time [%d] already deleted", time.ID))
return
}
if !ctx.User.IsAdmin && time.UserID != ctx.User.ID {
//Only Admin and User itself can delete their time