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"
|
||||
switch vars["function"] {
|
||||
default:
|
||||
type votesPageData struct {
|
||||
Votes []Vote
|
||||
}
|
||||
page.TemplateData = votesPageData{Votes: dbGetAllVotes()}
|
||||
page.show("admin-votes.html", w)
|
||||
}
|
||||
}
|
||||
|
5
main.go
5
main.go
@ -32,6 +32,8 @@ type siteData struct {
|
||||
DevMode bool
|
||||
|
||||
CurrentJam string
|
||||
|
||||
AllVotes []Vote
|
||||
}
|
||||
|
||||
// pageData is stuff that changes per request
|
||||
@ -199,6 +201,9 @@ func initialize() {
|
||||
} else {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
|
||||
// Load all votes into memory
|
||||
site.AllVotes = dbGetAllVotes()
|
||||
}
|
||||
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range $i, $v, := .TemplateData.Votes }}
|
||||
{{ range $i, $v, := .Site.AllVotes }}
|
||||
<tr>
|
||||
<td>{{ $v.Timestamp }}</td>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user