Added manual editing and display of team accomplishments.

This commit is contained in:
Patrick Fairbank
2014-08-03 16:20:40 -07:00
parent aa9d7a06a1
commit 37a7c199a4
8 changed files with 49 additions and 27 deletions

View File

@@ -1,13 +1,14 @@
-- +goose Up
CREATE TABLE teams (
id INTEGER PRIMARY KEY,
name VARCHAR(255),
name VARCHAR(1000),
nickname VARCHAR(255),
city VARCHAR(255),
stateprov VARCHAR(255),
country VARCHAR(255),
rookieyear int,
robotname VARCHAR(255)
robotname VARCHAR(255),
accomplishments VARCHAR(1000)
);
-- +goose Down

View File

@@ -75,7 +75,8 @@ func TestSchedulePdfReport(t *testing.T) {
match := Match{Type: "practice", DisplayName: "1", Time: time.Unix(0, 0), Red1: 1, Red2: 2, Red3: 3,
Blue1: 4, Blue2: 5, Blue3: 6, Blue1IsSurrogate: true, Blue2IsSurrogate: true, Blue3IsSurrogate: true}
db.CreateMatch(&match)
team := Team{254, "NASA", "The Cheesy Poofs", "San Jose", "CA", "USA", 1999, "Barrage"}
team := Team{Id: 254, Name: "NASA", Nickname: "The Cheesy Poofs", City: "San Jose", StateProv: "CA",
Country: "USA", RookieYear: 1999, RobotName: "Barrage"}
db.CreateTeam(&team)
// Can't really parse the PDF content and check it, so just check that what's sent back is a PDF.
@@ -88,8 +89,10 @@ func TestTeamsCsvReport(t *testing.T) {
clearDb()
defer clearDb()
db, _ = OpenDatabase(testDbPath)
team1 := Team{254, "NASA", "The Cheesy Poofs", "San Jose", "CA", "USA", 1999, "Barrage"}
team2 := Team{1114, "GM", "Simbotics", "St. Catharines", "ON", "Canada", 2003, "Simbot Evolution"}
team1 := Team{Id: 254, Name: "NASA", Nickname: "The Cheesy Poofs", City: "San Jose", StateProv: "CA",
Country: "USA", RookieYear: 1999, RobotName: "Barrage"}
team2 := Team{Id: 1114, Name: "GM", Nickname: "Simbotics", City: "St. Catharines", StateProv: "ON",
Country: "Canada", RookieYear: 2003, RobotName: "Simbot Evolution"}
db.CreateTeam(&team1)
db.CreateTeam(&team2)
@@ -107,7 +110,8 @@ func TestTeamsPdfReport(t *testing.T) {
defer clearDb()
db, _ = OpenDatabase(testDbPath)
eventSettings, _ = db.GetEventSettings()
team := Team{254, "NASA", "The Cheesy Poofs", "San Jose", "CA", "USA", 1999, "Barrage"}
team := Team{Id: 254, Name: "NASA", Nickname: "The Cheesy Poofs", City: "San Jose", StateProv: "CA",
Country: "USA", RookieYear: 1999, RobotName: "Barrage"}
db.CreateTeam(&team)
// Can't really parse the PDF content and check it, so just check that what's sent back is a PDF.

View File

@@ -123,6 +123,7 @@ func TeamEditPostHandler(w http.ResponseWriter, r *http.Request) {
team.Country = r.PostFormValue("country")
team.RookieYear, _ = strconv.Atoi(r.PostFormValue("rookieYear"))
team.RobotName = r.PostFormValue("robotName")
team.Accomplishments = r.PostFormValue("accomplishments")
err = db.SaveTeam(team)
if err != nil {
handleWebErr(w, err)
@@ -240,9 +241,10 @@ func getOfficialTeamInfo(teamId int) (*Team, error) {
var team Team
if ok {
rookieYear, _ := strconv.Atoi(teamData[8])
team = Team{teamId, html.UnescapeString(teamData[2]), html.UnescapeString(teamData[7]),
html.UnescapeString(teamData[4]), html.UnescapeString(teamData[5]), html.UnescapeString(teamData[6]),
rookieYear, html.UnescapeString(teamData[9])}
team = Team{Id: teamId, Name: html.UnescapeString(teamData[2]), Nickname: html.UnescapeString(teamData[7]),
City: html.UnescapeString(teamData[4]), StateProv: html.UnescapeString(teamData[5]),
Country: html.UnescapeString(teamData[6]), RookieYear: rookieYear,
RobotName: html.UnescapeString(teamData[9])}
} else {
// If no team data exists, just fill in the team number.
team = Team{Id: teamId}

View File

@@ -16,12 +16,12 @@ var handleSetAudienceDisplay = function(targetScreen) {
var handleSetMatch = function(data) {
$("#matchName").text(data.MatchType + " Match " + data.MatchDisplayName);
$("#red1").html(teamTemplate(data.Red1));
$("#red2").html(teamTemplate(data.Red2));
$("#red3").html(teamTemplate(data.Red3));
$("#blue1").html(teamTemplate(data.Blue1));
$("#blue2").html(teamTemplate(data.Blue2));
$("#blue3").html(teamTemplate(data.Blue3));
$("#red1").html(teamTemplate(formatTeam(data.Red1)));
$("#red2").html(teamTemplate(formatTeam(data.Red2)));
$("#red3").html(teamTemplate(formatTeam(data.Red3)));
$("#blue1").html(teamTemplate(formatTeam(data.Blue1)));
$("#blue2").html(teamTemplate(formatTeam(data.Blue2)));
$("#blue3").html(teamTemplate(formatTeam(data.Blue3)));
};
var handleMatchTime = function(data) {
@@ -49,6 +49,12 @@ var postMatchResult = function(data) {
websocket.send("setAudienceDisplay", "score");
}
// Replaces newlines in team fields with HTML line breaks.
var formatTeam = function(team) {
team.Accomplishments = team.Accomplishments.replace(/[\r\n]+/g, "<br />");
return team;
};
$(function() {
// Set up the websocket back to the server.
websocket = new CheesyWebsocket("/displays/announcer/websocket", {

17
team.go
View File

@@ -6,14 +6,15 @@
package main
type Team struct {
Id int
Name string
Nickname string
City string
StateProv string
Country string
RookieYear int
RobotName string
Id int
Name string
Nickname string
City string
StateProv string
Country string
RookieYear int
RobotName string
Accomplishments string
}
func (database *Database) CreateTeam(team *Team) error {

View File

@@ -27,7 +27,8 @@ func TestTeamCrud(t *testing.T) {
assert.Nil(t, err)
defer db.Close()
team := Team{254, "NASA Ames Research Center", "The Cheesy Poofs", "San Jose", "CA", "USA", 1999, "Barrage"}
team := Team{Id: 254, Name: "NASA", Nickname: "The Cheesy Poofs", City: "San Jose", StateProv: "CA",
Country: "USA", RookieYear: 1999, RobotName: "Barrage"}
db.CreateTeam(&team)
team2, err := db.GetTeamById(254)
assert.Nil(t, err)
@@ -52,7 +53,8 @@ func TestTruncateTeams(t *testing.T) {
assert.Nil(t, err)
defer db.Close()
team := Team{254, "NASA Ames Research Center", "The Cheesy Poofs", "San Jose", "CA", "USA", 1999, "Barrage"}
team := Team{Id: 254, Name: "NASA", Nickname: "The Cheesy Poofs", City: "San Jose", StateProv: "CA",
Country: "USA", RookieYear: 1999, RobotName: "Barrage"}
db.CreateTeam(&team)
db.TruncateTeams()
team2, err := db.GetTeamById(254)
@@ -73,7 +75,7 @@ func TestGetAllTeams(t *testing.T) {
numTeams := 20
for i := 1; i <= numTeams; i++ {
db.CreateTeam(&Team{i, "", "", "", "", "", 2014, ""})
db.CreateTeam(&Team{Id: i, RookieYear: 2014})
}
teams, err = db.GetAllTeams()
assert.Nil(t, err)

View File

@@ -64,7 +64,7 @@
<td>{{"{{Name}}"}}</td>
<td class="nowrap">{{"{{RobotName}}"}}</td>
<td>{{"{{RookieYear}}"}}</td>
<td class="nowrap">2014 Central Valley Regional - Gracious Professionalism<br />Placeholder</td>
<td class="nowrap">{{"{{{Accomplishments}}}"}}</td>
{{"{{else}}"}}
<td colspan="100">No team present</td>
{{"{{/if}}"}}

View File

@@ -48,6 +48,12 @@
<input type="text" class="form-control" name="robotName" value="{{.Team.RobotName}}">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Recent Accomplishments</label>
<div class="col-lg-9">
<textarea class="form-control" rows="5" name="accomplishments">{{.Team.Accomplishments}}</textarea>
</div>
</div>
<div class="form-group">
<div class="col-lg-9 col-lg-offset-3">
<a href="/setup/teams"><button type="button" class="btn btn-default">Cancel</button></a>