Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct TBA key for backup robots #23

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions db/migrations/20161003014944_AddOrigTeamNumberToTeams.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- +goose Up
ALTER TABLE teams ADD COLUMN origteamnumber INTEGER DEFAULT 0;

-- +goose Down
ALTER TABLE teams DROP COLUMN origteamnumber;
1 change: 1 addition & 0 deletions setup_teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func TeamEditPostHandler(w http.ResponseWriter, r *http.Request) {
team.StateProv = r.PostFormValue("stateProv")
team.Country = r.PostFormValue("country")
team.RookieYear, _ = strconv.Atoi(r.PostFormValue("rookieYear"))
team.OrigTeamNumber, _ = strconv.Atoi(r.PostFormValue("origTeamNumber"))
team.RobotName = r.PostFormValue("robotName")
team.Accomplishments = r.PostFormValue("accomplishments")
if eventSettings.NetworkSecurityEnabled {
Expand Down
7 changes: 6 additions & 1 deletion tba.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,12 @@ func DeletePublishedMatches() error {

// Converts an integer team number into the "frcXXXX" format TBA expects.
func getTbaTeam(team int) string {
return fmt.Sprintf("frc%d", team)
resolved_team, _ := db.GetTeamById(team)
if resolved_team.OrigTeamNumber != 0 {
return fmt.Sprintf("frc%dB", resolved_team.OrigTeamNumber)
} else {
return fmt.Sprintf("frc%d", team)
}
}

// HELPERS
Expand Down
1 change: 1 addition & 0 deletions team.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Team struct {
Accomplishments string
WpaKey string
YellowCard bool
OrigTeamNumber int
}

func (database *Database) CreateTeam(team *Team) error {
Expand Down
6 changes: 6 additions & 0 deletions templates/edit_team.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
<input type="text" class="form-control" name="rookieYear" value="{{.Team.RookieYear}}">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Original Team Number (if backup)</label>
<div class="col-lg-9">
<input type="text" class="form-control" name="origTeamNumber" value="{{.Team.OrigTeamNumber}}">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Robot Name</label>
<div class="col-lg-9">
Expand Down