mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 21:56:50 -04:00
Add publishing of awards to TBA.
This commit is contained in:
@@ -73,3 +73,17 @@ func (web *Web) awardsPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
http.Redirect(w, r, "/setup/awards", 303)
|
||||
}
|
||||
|
||||
// Publishes the awards to the web.
|
||||
func (web *Web) awardsPublishHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if !web.userIsAdmin(w, r) {
|
||||
return
|
||||
}
|
||||
|
||||
err := web.arena.TbaClient.PublishAwards(web.arena.Database)
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to publish awards: "+err.Error(), 500)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/setup/awards", 303)
|
||||
}
|
||||
|
||||
@@ -33,3 +33,14 @@ func TestSetupAwards(t *testing.T) {
|
||||
assert.Equal(t, 200, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), "Englebert")
|
||||
}
|
||||
|
||||
func TestSetupAwardsPublish(t *testing.T) {
|
||||
web := setupTestWeb(t)
|
||||
|
||||
web.arena.TbaClient.BaseUrl = "fakeurl"
|
||||
web.arena.EventSettings.TbaPublishingEnabled = true
|
||||
|
||||
recorder := web.postHttpResponse("/setup/awards/publish", "")
|
||||
assert.Equal(t, 500, recorder.Code)
|
||||
assert.Contains(t, recorder.Body.String(), "Failed to publish awards")
|
||||
}
|
||||
|
||||
@@ -145,6 +145,7 @@ func (web *Web) newHandler() http.Handler {
|
||||
router.HandleFunc("/reports/csv/wpa_keys", web.wpaKeysCsvReportHandler).Methods("GET")
|
||||
router.HandleFunc("/setup/awards", web.awardsGetHandler).Methods("GET")
|
||||
router.HandleFunc("/setup/awards", web.awardsPostHandler).Methods("POST")
|
||||
router.HandleFunc("/setup/awards/publish", web.awardsPublishHandler).Methods("POST")
|
||||
router.HandleFunc("/setup/db/clear", web.clearDbHandler).Methods("POST")
|
||||
router.HandleFunc("/setup/db/restore", web.restoreDbHandler).Methods("POST")
|
||||
router.HandleFunc("/setup/db/save", web.saveDbHandler).Methods("GET")
|
||||
|
||||
Reference in New Issue
Block a user