admin: Check all theme/exercice attribute are in sync with repo
This commit is contained in:
parent
5e262b75a3
commit
74f388a2b9
18 changed files with 818 additions and 142 deletions
|
@ -699,26 +699,32 @@ func SyncExerciceFlags(i Importer, exercice *fic.Exercice, exceptions *CheckExce
|
|||
return
|
||||
}
|
||||
|
||||
func GetRemoteExerciceFlags(thid, exid string) ([]fic.Flag, error) {
|
||||
theme, exceptions, errs := BuildTheme(GlobalImporter, thid)
|
||||
if theme == nil {
|
||||
return nil, errs
|
||||
}
|
||||
|
||||
exercice, _, _, eexceptions, _, errs := BuildExercice(GlobalImporter, theme, path.Join(theme.Path, exid), nil, exceptions)
|
||||
if exercice == nil {
|
||||
return nil, errs
|
||||
}
|
||||
|
||||
flags, errs := CheckExerciceFlags(GlobalImporter, exercice, []string{}, eexceptions)
|
||||
if flags == nil {
|
||||
return nil, errs
|
||||
}
|
||||
|
||||
return flags, nil
|
||||
}
|
||||
|
||||
// ApiListRemoteExerciceFlags is an accessor letting foreign packages to access remote exercice flags.
|
||||
func ApiGetRemoteExerciceFlags(c *gin.Context) {
|
||||
theme, exceptions, errs := BuildTheme(GlobalImporter, c.Params.ByName("thid"))
|
||||
if theme != nil {
|
||||
exercice, _, _, eexceptions, _, errs := BuildExercice(GlobalImporter, theme, path.Join(theme.Path, c.Params.ByName("exid")), nil, exceptions)
|
||||
if exercice != nil {
|
||||
flags, errs := CheckExerciceFlags(GlobalImporter, exercice, []string{}, eexceptions)
|
||||
if flags != nil {
|
||||
c.JSON(http.StatusOK, flags)
|
||||
return
|
||||
}
|
||||
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, fmt.Errorf("%q", errs))
|
||||
return
|
||||
}
|
||||
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, fmt.Errorf("%q", errs))
|
||||
flags, err := GetRemoteExerciceFlags(c.Params.ByName("thid"), c.Params.ByName("exid"))
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, fmt.Errorf("%q", errs))
|
||||
return
|
||||
c.JSON(http.StatusOK, flags)
|
||||
}
|
||||
|
|
Reference in a new issue