Add links to the forge
This commit is contained in:
parent
562cd5b397
commit
6c471b5ec1
@ -262,7 +262,7 @@
|
||||
{#await my_submission}
|
||||
<div class="spinner-grow spinner-grow-sm mx-1" role="status"></div>
|
||||
{:then submission}
|
||||
<strong>{submission.commit} ({submission.tag})</strong> (taille : {submission.size} o, date : <DateFormat date={new Date(submission.date)} dateStyle="medium" timeStyle="medium" />)
|
||||
<strong><a href="/api/works/{w.id}/forge/-/tree/{submission.commit}" target="_blank">{submission.commit}</a> (<a href="/api/works/{w.id}/forge/-/tree/{submission.tag}" target="_blank">{submission.tag}</a>)</strong> (taille : {submission.size} o, date : <DateFormat date={new Date(submission.date)} dateStyle="medium" timeStyle="medium" />)
|
||||
{:catch}
|
||||
<strong>-</strong>
|
||||
{/await}
|
||||
|
20
works.go
20
works.go
@ -370,6 +370,26 @@ func declareAPIAuthWorksRoutes(router *gin.RouterGroup) {
|
||||
})
|
||||
|
||||
// Grades related to works
|
||||
worksRoutes.GET("/forge/*path", func(c *gin.Context) {
|
||||
w := c.MustGet("work").(*Work)
|
||||
|
||||
var u *User
|
||||
if user, ok := c.Get("user"); ok {
|
||||
u = user.(*User)
|
||||
} else {
|
||||
u = c.MustGet("LoggedUser").(*User)
|
||||
}
|
||||
|
||||
repo, err := u.getRepositoryByWork(w.Id)
|
||||
if err != nil {
|
||||
log.Printf("Unable to getRepositoryByWork(uid=%d, wid=%d): %s", u.Id, w.Id, err.Error())
|
||||
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": "Unable to find a corresponding repository."})
|
||||
return
|
||||
}
|
||||
|
||||
c.Redirect(http.StatusFound, strings.TrimSuffix(strings.Replace(strings.Replace(repo.URI, ":", "/", 1), "git@", "https://", 1), ".git")+c.Param("path"))
|
||||
})
|
||||
|
||||
worksRoutes.GET("/score", func(c *gin.Context) {
|
||||
u := c.MustGet("LoggedUser").(*User)
|
||||
w := c.MustGet("work").(*Work)
|
||||
|
Reference in New Issue
Block a user