Setup HTTP endpoint to hit to republish schedule, no UI changes yet

This commit is contained in:
Oliver Graff
2016-10-05 04:55:07 -04:00
committed by Kunal Mehta
parent 3be13a869d
commit fbd9bda712
2 changed files with 19 additions and 0 deletions

View File

@@ -94,6 +94,24 @@ func ScheduleGeneratePostHandler(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/setup/schedule", 302)
}
// Publishes the schedule in the database to TBA
func ScheduleRepublishPostHandler(w http.ResponseWriter, r *http.Request) {
if eventSettings.TbaPublishingEnabled {
// Publish schedule to The Blue Alliance.
err := DeletePublishedMatches()
if err != nil {
http.Error(w, "Failed to delete published matches: "+err.Error(), 500)
return
}
err = PublishMatches()
if err != nil {
http.Error(w, "Failed to publish matches: "+err.Error(), 500)
return
}
}
http.Redirect(w, r, "/setup/schedule", 302)
}
// Saves the generated schedule to the database.
func ScheduleSavePostHandler(w http.ResponseWriter, r *http.Request) {
if !UserIsAdmin(w, r) {