mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 21:56:50 -04:00
Setup HTTP endpoint to hit to republish schedule, no UI changes yet
This commit is contained in:
committed by
Kunal Mehta
parent
3be13a869d
commit
fbd9bda712
@@ -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
1
web.go
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user