New option to allow teams to self reset their progression
This commit is contained in:
parent
a0c34018cf
commit
d6ff46ca7f
9 changed files with 173 additions and 3 deletions
|
|
@ -52,6 +52,7 @@ func main() {
|
|||
http.Handle(fmt.Sprintf("%s/wantchoices/", *prefix), http.StripPrefix(fmt.Sprintf("%s/wantchoices/", *prefix), submissionTeamChecker{"wantint choices", WantChoicesHandler, *teamsDir, *simulator}))
|
||||
http.Handle(fmt.Sprintf("%s/registration", *prefix), http.StripPrefix(fmt.Sprintf("%s/registration", *prefix), submissionChecker{"registration", RegistrationHandler}))
|
||||
http.Handle(fmt.Sprintf("%s/resolution/", *prefix), http.StripPrefix(fmt.Sprintf("%s/resolution/", *prefix), ResolutionHandler{}))
|
||||
http.Handle(fmt.Sprintf("%s/reset_progress", *prefix), http.StripPrefix(fmt.Sprintf("%s/reset_progress", *prefix), submissionTeamChecker{"reset_progress", ResetProgressHandler, *teamsDir, *simulator}))
|
||||
http.Handle(fmt.Sprintf("%s/submission/", *prefix), http.StripPrefix(fmt.Sprintf("%s/submission/", *prefix), submissionTeamChecker{"submission", SubmissionHandler, *teamsDir, *simulator}))
|
||||
|
||||
if *simulator != "" {
|
||||
|
|
|
|||
26
receiver/reset.go
Normal file
26
receiver/reset.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"path"
|
||||
"time"
|
||||
)
|
||||
|
||||
var enableResetProgression = false
|
||||
|
||||
func ResetProgressHandler(w http.ResponseWriter, r *http.Request, team string, sURL []string) {
|
||||
if !enableResetProgression {
|
||||
http.Error(w, "{\"errmsg\":\"Le challenge est terminé, trop tard !\"}", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
if challengeEnd != nil && time.Now().After(*challengeEnd) {
|
||||
http.Error(w, "{\"errmsg\":\"Le challenge est terminé, trop tard !\"}", http.StatusGone)
|
||||
return
|
||||
}
|
||||
|
||||
// Enqueue file for backend treatment
|
||||
if saveTeamFile(path.Join(team, "reset_progress"), w, r) {
|
||||
http.Error(w, "{\"errmsg\":\"Demande acceptée...\"}", http.StatusAccepted)
|
||||
}
|
||||
}
|
||||
|
|
@ -64,4 +64,5 @@ func reloadSettings(config *settings.Settings) {
|
|||
denyNameChange = config.DenyNameChange
|
||||
acceptNewIssues = config.AcceptNewIssue
|
||||
allowRegistration = config.AllowRegistration
|
||||
enableResetProgression = config.WorkInProgress && config.CanResetProgression
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue