Syncing
This commit is contained in:
parent
96a53b6090
commit
7162c8c34d
@ -11,10 +11,6 @@ func handleAdminVotes(w http.ResponseWriter, req *http.Request, page *pageData)
|
|||||||
page.SubTitle = "Votes"
|
page.SubTitle = "Votes"
|
||||||
switch vars["function"] {
|
switch vars["function"] {
|
||||||
default:
|
default:
|
||||||
type votesPageData struct {
|
|
||||||
Votes []Vote
|
|
||||||
}
|
|
||||||
page.TemplateData = votesPageData{Votes: dbGetAllVotes()}
|
|
||||||
page.show("admin-votes.html", w)
|
page.show("admin-votes.html", w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
main.go
5
main.go
@ -32,6 +32,8 @@ type siteData struct {
|
|||||||
DevMode bool
|
DevMode bool
|
||||||
|
|
||||||
CurrentJam string
|
CurrentJam string
|
||||||
|
|
||||||
|
AllVotes []Vote
|
||||||
}
|
}
|
||||||
|
|
||||||
// pageData is stuff that changes per request
|
// pageData is stuff that changes per request
|
||||||
@ -199,6 +201,9 @@ func initialize() {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load all votes into memory
|
||||||
|
site.AllVotes = dbGetAllVotes()
|
||||||
}
|
}
|
||||||
|
|
||||||
func loggingHandler(h http.Handler) http.Handler {
|
func loggingHandler(h http.Handler) http.Handler {
|
||||||
|
@ -57,5 +57,8 @@ func handlePublicSaveVote(w http.ResponseWriter, req *http.Request) {
|
|||||||
if err := dbSaveVote(page.ClientId, timestamp, voteSlice); err != nil {
|
if err := dbSaveVote(page.ClientId, timestamp, voteSlice); err != nil {
|
||||||
page.session.setFlashMessage("Error Saving Vote: "+err.Error(), "error")
|
page.session.setFlashMessage("Error Saving Vote: "+err.Error(), "error")
|
||||||
}
|
}
|
||||||
|
if newVote, err := dbGetVote(page.ClientId, timestamp); err == nil {
|
||||||
|
site.AllVotes = append(site.AllVotes, *newVote)
|
||||||
|
}
|
||||||
redirect("/", w, req)
|
redirect("/", w, req)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{ range $i, $v, := .TemplateData.Votes }}
|
{{ range $i, $v, := .Site.AllVotes }}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $v.Timestamp }}</td>
|
<td>{{ $v.Timestamp }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user