admin: Add link to forge
This commit is contained in:
parent
80917ae436
commit
2c76b5c7a3
7 changed files with 129 additions and 3 deletions
|
@ -85,6 +85,11 @@ func declareExercicesRoutes(router *gin.RouterGroup) {
|
|||
router.GET("/remote/themes/:thid/exercices/:exid/flags", sync.ApiGetRemoteExerciceFlags)
|
||||
}
|
||||
|
||||
type Exercice struct {
|
||||
*fic.Exercice
|
||||
ForgeLink string `json:"forge_link,omitempty"`
|
||||
}
|
||||
|
||||
func ExerciceHandler(c *gin.Context) {
|
||||
eid, err := strconv.ParseInt(string(c.Params.ByName("eid")), 10, 32)
|
||||
if err != nil {
|
||||
|
@ -359,7 +364,16 @@ func listExerciceQuiz(c *gin.Context) {
|
|||
}
|
||||
|
||||
func showExercice(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("exercice").(*fic.Exercice))
|
||||
exercice := c.MustGet("exercice").(*fic.Exercice)
|
||||
|
||||
var forgelink string
|
||||
if fli, ok := sync.GlobalImporter.(sync.ForgeLinkedImporter); ok {
|
||||
if u, _ := fli.GetExerciceLink(exercice); u != nil {
|
||||
forgelink = u.String()
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, Exercice{exercice, forgelink})
|
||||
}
|
||||
|
||||
func getExerciceHistory(c *gin.Context) {
|
||||
|
|
Reference in a new issue