admin: can delete team history item

This commit is contained in:
nemunaire 2017-12-21 21:25:23 +01:00 committed by Pierre-Olivier Mercier
parent a0737d91b9
commit e9910fe827
4 changed files with 77 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import (
"fmt"
"strconv"
"strings"
"time"
"srs.epita.fr/fic-server/libfic"
@ -63,6 +64,7 @@ func init() {
return fic.GetTeamsStats(nil)
}
})))
router.DELETE("/api/teams/:tid/history.json", apiHandler(teamPublicHandler(delHistory)))
router.GET("/api/teams/:tid/tries", apiHandler(teamPublicHandler(
func(team *fic.Team, _ []byte) (interface{}, error) {
return fic.GetTries(team, nil) })))
@ -211,3 +213,20 @@ func dispMemberTeamName(ps httprouter.Params, body []byte) (interface{}, error)
return team.InitialName, nil
}
}
type uploadedHistory struct {
Kind string
Time time.Time
Primary *int64
Secondary *int64
}
func delHistory(team *fic.Team, body []byte) (interface{}, error) {
var uh uploadedHistory
if err := json.Unmarshal(body, &uh); err != nil {
return nil, err
}
return team.DelHistoryItem(uh.Kind, uh.Time, uh.Primary, uh.Secondary)
}