Able to sync and export standalone exercices
This commit is contained in:
parent
76f830b332
commit
adb0e36dd4
15 changed files with 159 additions and 31 deletions
|
@ -113,13 +113,17 @@ func ExerciceHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
theme, err = exercice.GetTheme()
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to find the attached theme."})
|
||||
return
|
||||
}
|
||||
if exercice.IdTheme != nil {
|
||||
theme, err = exercice.GetTheme()
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to find the attached theme."})
|
||||
return
|
||||
}
|
||||
|
||||
c.Set("theme", theme)
|
||||
c.Set("theme", theme)
|
||||
} else {
|
||||
c.Set("theme", &fic.Theme{Path: sync.StandaloneExercicesDirectory})
|
||||
}
|
||||
}
|
||||
|
||||
c.Set("exercice", exercice)
|
||||
|
|
|
@ -58,6 +58,16 @@ func declareSyncRoutes(router *gin.RouterGroup) {
|
|||
|
||||
apiSyncDeepRoutes := apiSyncRoutes.Group("/deep/:thid")
|
||||
apiSyncDeepRoutes.Use(ThemeHandler)
|
||||
// Special route to handle standalone exercices
|
||||
apiSyncRoutes.POST("/deep/0", func(c *gin.Context) {
|
||||
var st []string
|
||||
for _, se := range multierr.Errors(sync.SyncThemeDeep(sync.GlobalImporter, &fic.Theme{Path: sync.StandaloneExercicesDirectory}, 0, 250, nil)) {
|
||||
st = append(st, se.Error())
|
||||
}
|
||||
sync.EditDeepReport(&sync.SyncReport{Exercices: st}, false)
|
||||
sync.DeepSyncProgress = 255
|
||||
c.JSON(http.StatusOK, st)
|
||||
})
|
||||
apiSyncDeepRoutes.POST("", func(c *gin.Context) {
|
||||
theme := c.MustGet("theme").(*fic.Theme)
|
||||
|
||||
|
|
Reference in a new issue