New route to display user's traces
This commit is contained in:
parent
706e786190
commit
084244449c
|
@ -670,6 +670,12 @@ func (u *User) getRepository(id int) (r *Repository, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (u *User) getRepositoryByWork(id int64) (r *Repository, err error) {
|
||||
r = new(Repository)
|
||||
err = DBQueryRow("SELECT id_repository, id_user, id_work, uri, secret, last_check, droneref, last_tests, testsref FROM user_work_repositories WHERE id_work=? AND id_user=? ORDER BY last_tests DESC LIMIT 1", id, u.Id).Scan(&r.Id, &r.IdUser, &r.IdWork, &r.URI, &r.Secret, &r.LastCheck, &r.DroneRef, &r.LastTests, &r.TestsRef)
|
||||
return
|
||||
}
|
||||
|
||||
func (u *User) NewRepository(w *Work, uri string) (*Repository, error) {
|
||||
secret := make([]byte, 24)
|
||||
_, err := rand.Read(secret)
|
||||
|
|
|
@ -95,6 +95,14 @@
|
|||
<td>{#if grade.comment}{grade.comment}{:else}-{/if}</td>
|
||||
<td>{grade.date}</td>
|
||||
<td>
|
||||
<a
|
||||
href="/api/users/{grade.id_user}/works/{w.id}/grades/{grade.id}/traces"
|
||||
target="_blank"
|
||||
class="btn btn-sm btn-outline-info mx-1"
|
||||
title="Voir le détail de la notation"
|
||||
>
|
||||
<i class="bi bi-list-check"></i>
|
||||
</a>
|
||||
<button
|
||||
class="btn btn-sm btn-danger mx-1"
|
||||
title="Supprimer la note"
|
||||
|
|
1
users.go
1
users.go
|
@ -98,6 +98,7 @@ func declareAPIAdminUsersRoutes(router *gin.RouterGroup) {
|
|||
|
||||
declareAPIAdminUserCorrectionsRoutes(usersRoutes)
|
||||
declareAPIAdminUserQuestionsRoutes(usersRoutes)
|
||||
declareAPIAdminWorksRoutes(usersRoutes)
|
||||
}
|
||||
|
||||
func userHandler(c *gin.Context) {
|
||||
|
|
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 New Issue
Block a user