Skip to content

Commit

Permalink
Add Team School Name to team Edit (#193)
Browse files Browse the repository at this point in the history
* Add Team School Name to team Edit

* fix test

---------

Co-authored-by: Corey Applegate <[email protected]>
  • Loading branch information
spacey-sooty and cpapplefamily authored Aug 4, 2024
1 parent f0ff0df commit 9b5c7e4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
6 changes: 6 additions & 0 deletions templates/edit_team.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
<input type="text" class="form-control" name="nickname" value="{{.Team.Nickname}}">
</div>
</div>
<div class="row mb-3">
<label class="col-lg-3 control-label">School Name</label>
<div class="col-lg-9">
<input type="text" class="form-control" name="schoolName" value="{{.Team.SchoolName}}">
</div>
</div>
<div class="row mb-3">
<label class="col-lg-3 control-label">City</label>
<div class="col-lg-9">
Expand Down
4 changes: 2 additions & 2 deletions templates/teams.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Number,Name,Nickname,City,StateProv,Country,RookieYear,RobotName,HasConnected
{{range $team := .}}{{$team.Id}},"{{$team.Name}}","{{$team.Nickname}}","{{$team.City}}","{{$team.StateProv}}","{{$team.Country}}",{{$team.RookieYear}},"{{$team.RobotName}}",{{$team.HasConnected}}
Number,Name,Nickname,SchoolName,City,StateProv,Country,RookieYear,RobotName,HasConnected
{{range $team := .}}{{$team.Id}},"{{$team.Name}}","{{$team.Nickname}}","{{$team.SchoolName}}","{{$team.City}}","{{$team.StateProv}}","{{$team.Country}}",{{$team.RookieYear}},"{{$team.RobotName}}",{{$team.HasConnected}}
{{end}}
10 changes: 5 additions & 5 deletions web/reports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,19 @@ func TestSchedulePdfReport(t *testing.T) {
func TestTeamsCsvReport(t *testing.T) {
web := setupTestWeb(t)

team1 := model.Team{Id: 254, Name: "NASA", Nickname: "The Cheesy Poofs", City: "San Jose", StateProv: "CA",
team1 := model.Team{Id: 254, Name: "NASA", Nickname: "The Cheesy Poofs", SchoolName: "Bellarmine College Preparatory", City: "San Jose", StateProv: "CA",
Country: "USA", RookieYear: 1999, RobotName: "Barrage"}
team2 := model.Team{Id: 1114, Name: "GM", Nickname: "Simbotics", City: "St. Catharines", StateProv: "ON",
team2 := model.Team{Id: 1114, Name: "GM", Nickname: "Simbotics", SchoolName: "Governor Simcoe Secondary School", City: "St. Catharines", StateProv: "ON",
Country: "Canada", RookieYear: 2003, RobotName: "Simbot Evolution"}
web.arena.Database.CreateTeam(&team1)
web.arena.Database.CreateTeam(&team2)

recorder := web.getHttpResponse("/reports/csv/teams")
assert.Equal(t, 200, recorder.Code)
assert.Equal(t, "text/plain", recorder.Header()["Content-Type"][0])
expectedBody := "Number,Name,Nickname,City,StateProv,Country,RookieYear,RobotName,HasConnected\n254,\"NASA\"," +
"\"The Cheesy Poofs\",\"San Jose\",\"CA\",\"USA\",1999,\"Barrage\",false\n1114,\"GM\",\"Simbotics\"," +
"\"St. Catharines\",\"ON\",\"Canada\",2003,\"Simbot Evolution\",false\n\n"
expectedBody := "Number,Name,Nickname,SchoolName,City,StateProv,Country,RookieYear,RobotName,HasConnected\n254,\"NASA\"," +
"\"The Cheesy Poofs\",\"Bellarmine College Preparatory\",\"San Jose\",\"CA\",\"USA\",1999,\"Barrage\",false\n1114,\"GM\",\"Simbotics\"," +
"\"Governor Simcoe Secondary School\",\"St. Catharines\",\"ON\",\"Canada\",2003,\"Simbot Evolution\",false\n\n"
assert.Equal(t, expectedBody, recorder.Body.String())
}

Expand Down
1 change: 1 addition & 0 deletions web/setup_teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func (web *Web) teamEditPostHandler(w http.ResponseWriter, r *http.Request) {
team.Name = r.PostFormValue("name")
team.Nickname = r.PostFormValue("nickname")
team.City = r.PostFormValue("city")
team.SchoolName = r.PostFormValue("schoolName")
team.StateProv = r.PostFormValue("stateProv")
team.Country = r.PostFormValue("country")
team.RookieYear, _ = strconv.Atoi(r.PostFormValue("rookieYear"))
Expand Down

0 comments on commit 9b5c7e4

Please sign in to comment.