Added setting to disable team info download for when there is no internet.

This commit is contained in:
Patrick Fairbank
2014-08-17 17:58:17 -07:00
parent e8574821a9
commit 384404b228
5 changed files with 28 additions and 18 deletions

View File

@@ -7,6 +7,7 @@ CREATE TABLE event_settings (
numelimalliances int,
selectionround2order VARCHAR(1),
selectionround3order VARCHAR(1),
teaminfodownloadenabled bool,
tbapublishingenabled bool,
tbaeventcode VARCHAR(16),
tbasecretid VARCHAR(255),

View File

@@ -6,23 +6,24 @@
package main
type EventSettings struct {
Id int
Name string
Code string
DisplayBackgroundColor string
NumElimAlliances int
SelectionRound2Order string
SelectionRound3Order string
TbaPublishingEnabled bool
TbaEventCode string
TbaSecretId string
TbaSecret string
NetworkSecurityEnabled bool
ApAddress string
ApUsername string
ApPassword string
SwitchAddress string
SwitchPassword string
Id int
Name string
Code string
DisplayBackgroundColor string
NumElimAlliances int
SelectionRound2Order string
SelectionRound3Order string
TeamInfoDownloadEnabled bool
TbaPublishingEnabled bool
TbaEventCode string
TbaSecretId string
TbaSecret string
NetworkSecurityEnabled bool
ApAddress string
ApUsername string
ApPassword string
SwitchAddress string
SwitchPassword string
}
const eventSettingsId = 0
@@ -38,6 +39,7 @@ func (database *Database) GetEventSettings() (*EventSettings, error) {
eventSettings.NumElimAlliances = 8
eventSettings.SelectionRound2Order = "L"
eventSettings.SelectionRound3Order = ""
eventSettings.TeamInfoDownloadEnabled = true
err = database.eventSettingsMap.Insert(eventSettings)
if err != nil {
return nil, err

View File

@@ -41,6 +41,7 @@ func SettingsPostHandler(w http.ResponseWriter, r *http.Request) {
eventSettings.NumElimAlliances = numAlliances
eventSettings.SelectionRound2Order = r.PostFormValue("selectionRound2Order")
eventSettings.SelectionRound3Order = r.PostFormValue("selectionRound3Order")
eventSettings.TeamInfoDownloadEnabled = r.PostFormValue("teamInfoDownloadEnabled") == "on"
eventSettings.TbaPublishingEnabled = r.PostFormValue("tbaPublishingEnabled") == "on"
eventSettings.TbaEventCode = r.PostFormValue("tbaEventCode")
eventSettings.TbaSecretId = r.PostFormValue("tbaSecretId")

View File

@@ -235,7 +235,7 @@ func canModifyTeamList() bool {
// Returns the data for the given team number.
func getOfficialTeamInfo(teamId int) (*Team, error) {
if officialTeamInfo == nil {
if officialTeamInfo == nil && eventSettings.TeamInfoDownloadEnabled {
// Download all team info from the FIRST website if it is not cached.
resp, err := http.Get(officialTeamInfoUrl)
if err != nil {

View File

@@ -85,6 +85,12 @@
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-7 control-label">Enable Team Info Download From usfirst.org</label>
<div class="col-lg-1 checkbox">
<input type="checkbox" name="teamInfoDownloadEnabled"{{if .TeamInfoDownloadEnabled}} checked{{end}}>
</div>
</div>
</fieldset>
<fieldset>
<legend>Publishing</legend>