New route to display user's traces
This commit is contained in:
parent
706e786190
commit
084244449c
4 changed files with 34 additions and 0 deletions
19
works.go
19
works.go
|
@ -201,6 +201,25 @@ func declareAPIAdminWorksRoutes(router *gin.RouterGroup) {
|
|||
g.Delete()
|
||||
c.JSON(http.StatusOK, true)
|
||||
})
|
||||
gradesRoutes.GET("/traces", func(c *gin.Context) {
|
||||
g := c.MustGet("grade").(*WorkGrade)
|
||||
|
||||
var u *User
|
||||
if user, ok := c.Get("user"); ok {
|
||||
u = user.(*User)
|
||||
} else {
|
||||
u = c.MustGet("LoggedUser").(*User)
|
||||
}
|
||||
|
||||
repo, err := u.getRepositoryByWork(g.IdWork)
|
||||
if err != nil {
|
||||
log.Printf("Unable to getRepositoryByWork(uid=%d, wid=%d): %s", u.Id, g.IdWork, err.Error())
|
||||
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": "Unable to find a corresponding repository."})
|
||||
return
|
||||
}
|
||||
|
||||
c.Redirect(http.StatusFound, fmt.Sprintf("%s/%s", droneEndpoint, repo.TestsRef))
|
||||
})
|
||||
}
|
||||
|
||||
func declareAPIAuthWorksRoutes(router *gin.RouterGroup) {
|
||||
|
|
Reference in a new issue