Allow teams to change their name
This commit is contained in:
parent
f050dfce06
commit
136b436af5
7 changed files with 126 additions and 13 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"math/rand"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
|
@ -33,9 +34,15 @@ func treatSubmission(pathname string, team_id string, exercice_id string) {
|
|||
} else if err := json.Unmarshal(cnt_raw, &keys); err != nil {
|
||||
log.Println(id, "[ERR]", err)
|
||||
} else if exercice_id == "name" {
|
||||
team.Name = keys["newName"]
|
||||
if _, err := team.Update(); err != nil {
|
||||
log.Println(id, "[WRN] Unable to change team name:", err)
|
||||
if match, err := regexp.MatchString("^[A-Za-z0-9 àéèêëîïôùûü_-]{1,32}$", keys["newName"]); err == nil && match {
|
||||
team.Name = keys["newName"]
|
||||
if _, err := team.Update(); err != nil {
|
||||
log.Println(id, "[WRN] Unable to change team name:", err)
|
||||
}
|
||||
genTeamMyFile(team)
|
||||
}
|
||||
if err := os.Remove(pathname); err != nil {
|
||||
log.Println(id, "[ERR]", err)
|
||||
}
|
||||
} else if eid, err := strconv.Atoi(exercice_id); err != nil {
|
||||
log.Println(id, "[ERR]", err)
|
||||
|
|
Reference in a new issue