Can lock theme

This commit is contained in:
nemunaire 2023-03-20 15:20:20 +01:00
parent b8c5ec6725
commit d4ce0dd474
9 changed files with 85 additions and 43 deletions

View file

@ -210,6 +210,23 @@ func updateTheme(c *gin.Context) {
return
}
if theme.Locked != ut.Locked {
exercices, err := theme.GetExercices()
if err != nil {
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": err.Error()})
return
}
for _, exercice := range exercices {
if exercice.Disabled != ut.Locked {
exercice.Disabled = ut.Locked
_, err = exercice.Update()
if err != nil {
log.Println("Unable to enable/disable exercice: ", exercice.Id, err.Error())
}
}
}
}
c.JSON(http.StatusOK, ut)
}