Import logos from challenge.json
Some checks are pending
continuous-integration/drone/push Build is running
Some checks are pending
continuous-integration/drone/push Build is running
This commit is contained in:
parent
f4188ec289
commit
11a12e1d44
5 changed files with 81 additions and 27 deletions
38
admin/sync/challengeinfo.go
Normal file
38
admin/sync/challengeinfo.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
"srs.epita.fr/fic-server/settings"
|
||||
)
|
||||
|
||||
// ImportChallengeInfo imports images defined in the challengeinfo.
|
||||
func ImportChallengeInfo(ci *settings.ChallengeInfo) (err error) {
|
||||
if len(ci.MainLogo) > 0 {
|
||||
for i, logo := range ci.MainLogo {
|
||||
dest := path.Join(fic.FilesDir, "logo", path.Base(logo))
|
||||
err = importFile(GlobalImporter, logo, dest)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ci.MainLogo[i] = path.Join("$FILES$", strings.TrimPrefix(dest, fic.FilesDir))
|
||||
}
|
||||
}
|
||||
|
||||
if len(ci.Partners) > 0 {
|
||||
for i, partner := range ci.Partners {
|
||||
dest := path.Join(fic.FilesDir, "partner", path.Base(partner.Src))
|
||||
err = importFile(GlobalImporter, partner.Src, dest)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ci.Partners[i].Src = path.Join("$FILES$", strings.TrimPrefix(dest, fic.FilesDir))
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in a new issue