admin: new form to update history coefficient
This commit is contained in:
parent
2b75287d16
commit
ba5642da8f
5 changed files with 174 additions and 4 deletions
|
|
@ -23,6 +23,7 @@ func init() {
|
|||
router.DELETE("/api/exercices/:eid", apiHandler(exerciceHandler(deleteExercice)))
|
||||
|
||||
router.GET("/api/exercices/:eid/history.json", apiHandler(exerciceHandler(getExerciceHistory)))
|
||||
router.PATCH("/api/exercices/:eid/history.json", apiHandler(exerciceHandler(updateExerciceHistory)))
|
||||
router.DELETE("/api/exercices/:eid/history.json", apiHandler(exerciceHandler(delExerciceHistory)))
|
||||
|
||||
router.GET("/api/exercices/:eid/files", apiHandler(exerciceHandler(listExerciceFiles)))
|
||||
|
|
@ -145,6 +146,16 @@ type uploadedExerciceHistory struct {
|
|||
Kind string
|
||||
Time time.Time
|
||||
Secondary *int64
|
||||
Coeff float32
|
||||
}
|
||||
|
||||
func updateExerciceHistory(exercice fic.Exercice, body []byte) (interface{}, error) {
|
||||
var uh uploadedExerciceHistory
|
||||
if err := json.Unmarshal(body, &uh); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return exercice.UpdateHistoryItem(uh.Coeff, uh.IdTeam, uh.Kind, uh.Time, uh.Secondary)
|
||||
}
|
||||
|
||||
func delExerciceHistory(exercice fic.Exercice, body []byte) (interface{}, error) {
|
||||
|
|
|
|||
Reference in a new issue