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) {

1
web.go
View File

@@ -175,6 +175,7 @@ func newHandler() http.Handler {
router.HandleFunc("/setup/teams/generate_wpa_keys", TeamsGenerateWpaKeysHandler).Methods("GET")
router.HandleFunc("/setup/schedule", ScheduleGetHandler).Methods("GET")
router.HandleFunc("/setup/schedule/generate", ScheduleGeneratePostHandler).Methods("POST")
router.HandleFunc("/setup/schedule/republish", ScheduleRepublishPostHandler).Methods("POST")
router.HandleFunc("/setup/schedule/save", ScheduleSavePostHandler).Methods("POST")
router.HandleFunc("/setup/alliance_selection", AllianceSelectionGetHandler).Methods("GET")
router.HandleFunc("/setup/alliance_selection", AllianceSelectionPostHandler).Methods("POST")