Skip to content

Commit a41e967

Browse files
committed
Added display of total votes submitted to results
1 parent 6bd4691 commit a41e967

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

api.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ func GetPollById(c *gin.Context) {
103103
c.Redirect(http.StatusFound, "/results/"+poll.Id)
104104
return
105105
}
106-
107106
writeInAdj := 0
108107
if poll.AllowWriteIns {
109108
writeInAdj = 1
@@ -254,12 +253,15 @@ func GetPollResults(c *gin.Context) {
254253
})
255254
return
256255
}
256+
257+
fmt.Println(len(results))
257258
c.HTML(http.StatusOK, "result.tmpl", gin.H{
258259
"Id": poll.Id,
259260
"Title": poll.Title,
260261
"Description": poll.Description,
261262
"VoteType": poll.VoteType,
262263
"Results": results,
264+
"NumVotes": len(results),
263265
"IsOpen": poll.Open,
264266
"IsHidden": poll.Hidden,
265267
"CanModify": canModify,

templates/result.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{ template "header.tmpl" . }}
22

33
<div class="container main p-5">
4-
{{ if not .IsOpen }}
4+
{{ if .IsOpen }}
55
{{ if eq .CanVote 9 }}
66
<div id="already-voted" class="alert alert-info alert-dismissible fade show" role="alert">
77
<h5 class="m-0">You have already voted in this poll.</h5>
@@ -39,9 +39,11 @@
3939
{{/* This works currently because quorum type can only be set if gatekeep is required */}}
4040
{{ if not .Gatekeep }}
4141
<h6>No quorum required for this poll.</h6>
42+
<h6>Votes Cast: {{ .NumVotes }}</h6>
4243
{{ else }}
4344
<h6>Quorum Type: {{ .Quorum }}%</h6>
4445
<h6>Votes Needed For Quorum: {{ .VotesNeededForQuorum }}</h6>
46+
<h6>Votes Cast: {{ .NumVotes }}</h6>
4547
{{ end }}
4648
<br/>
4749
<br/>

0 commit comments

Comments
 (0)