Can lock theme

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

View file

@ -25,6 +25,7 @@ type exportedExercice struct {
type exportedTheme struct {
Name string `json:"name"`
URLId string `json:"urlid"`
Locked bool `json:"locked,omitempty"`
Authors string `json:"authors"`
Headline string `json:"headline,omitempty"`
Intro string `json:"intro"`
@ -42,11 +43,16 @@ func ExportThemes() (interface{}, error) {
} else {
ret := map[string]exportedTheme{}
for _, theme := range themes {
exos := []exportedExercice{}
if exercices, err := theme.GetExercices(); err != nil {
return nil, err
} else {
exos := []exportedExercice{}
for _, exercice := range exercices {
if exercice.Disabled {
continue
}
tags, _ := exercice.GetTags()
exos = append(exos, exportedExercice{
exercice.Id,
@ -60,29 +66,30 @@ func ExportThemes() (interface{}, error) {
exercice.TriedTeamCount(),
})
}
}
imgpath := ""
if len(theme.Image) > 0 {
imgpath = path.Join(FilesDir, theme.Image)
}
imgpath := ""
if len(theme.Image) > 0 {
imgpath = path.Join(FilesDir, theme.Image)
}
partnerImgpath := ""
if len(theme.PartnerImage) > 0 {
partnerImgpath = path.Join(FilesDir, theme.PartnerImage)
}
partnerImgpath := ""
if len(theme.PartnerImage) > 0 {
partnerImgpath = path.Join(FilesDir, theme.PartnerImage)
}
ret[fmt.Sprintf("%d", theme.Id)] = exportedTheme{
theme.Name,
theme.URLId,
theme.Authors,
theme.Headline,
strings.Replace(theme.Intro, "$FILES$", FilesDir, -1),
imgpath,
partnerImgpath,
theme.PartnerLink,
theme.PartnerText,
exos,
}
ret[fmt.Sprintf("%d", theme.Id)] = exportedTheme{
theme.Name,
theme.URLId,
theme.Locked,
theme.Authors,
theme.Headline,
strings.Replace(theme.Intro, "$FILES$", FilesDir, -1),
imgpath,
partnerImgpath,
theme.PartnerLink,
theme.PartnerText,
exos,
}
}