Skip to content

Commit 0b18a29

Browse files
authored
Add feedback for why users cant vote (#74)
* Added alert on results screen for when you already voted * Added banner alert telling user that they already voted * Tried to make the alert have vertically centered text * Fixed vertical centering (thanks noah) * Added alert for if user is inactive * Updated alert to account for inactive and gatekept, added alert for db error * Updated alert to account for inactive and gatekept, added alert for db error * Added sentence telling people to contact evals or opcomm for more info
1 parent f3885da commit 0b18a29

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ func main() {
430430
"IsOpen": poll.Open,
431431
"IsHidden": poll.Hidden,
432432
"CanModify": canModify,
433+
"CanVote": canVote(claims.UserInfo, *poll, poll.AllowedUsers),
433434
"Username": claims.UserInfo.Username,
434435
"FullName": claims.UserInfo.FullName,
435436
"Gatekeep": poll.Gatekeep,

templates/result.tmpl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
media="screen"
1010
/>
1111
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
12+
13+
<style>
14+
.container div.d-none {
15+
display: none!important;
16+
}
17+
</style>
1218
</head>
1319
<body>
1420
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
@@ -25,6 +31,33 @@
2531
</nav>
2632

2733
<div class="container main p-5">
34+
{{ if eq .CanVote 9 }}
35+
<div id="already-voted" class="alert alert-info alert-dismissible d-flex flex-row align-items-center" role="alert">
36+
<h5 class="m-0">You have already voted in this poll.</h5>
37+
<button class="close m-0" style="cursor: pointer;" onclick="document.getElementById('already-voted').classList.add('d-none');">
38+
<span class="align-items-center">&times;</span>
39+
</button>
40+
</div>
41+
{{ else if eq .CanVote 1 }}
42+
<div id="db-error" class="alert alert-danger alert-dismissible d-flex flex-row align-items-center" role="alert">
43+
<h5 class="m-0">There was an error checking your voting eligibility. Try refreshing the page or contacting the RTPs if the issue persists.</h5>
44+
<button class="close m-0" style="cursor: pointer;" onclick="document.getElementById('db-error').classList.add('d-none');">
45+
<span class="align-items-center">&times;</span>
46+
</button>
47+
</div>
48+
{{ else if gt .CanVote 1 }}
49+
<div id="cannot-vote" class="alert alert-warning alert-dismissible d-flex flex-row align-items-center" role="alert">
50+
<h5 class="m-0">
51+
You are not eligible to vote in this poll. This is likely because you are not an Active Member,
52+
or because you did not meet the gatekeep requirements by the time the poll opened.
53+
If you believe this is an error, please contact Evals or Opcomm.
54+
</h5>
55+
<button class="close m-0 ml-3" style="cursor: pointer;" onclick="document.getElementById('cannot-vote').classList.add('d-none');">
56+
<span class="align-items-center">&times;</span>
57+
</button>
58+
</div>
59+
{{ end }}
60+
2861
<h2 style="white-space: normal; word-wrap: break-word;">{{ .ShortDescription }}</h2>
2962
{{ if .LongDescription }}
3063
<h4>{{ .LongDescription | MakeLinks }}</h4>
@@ -38,6 +71,7 @@
3871
<h4>Results will be available once the poll closes</h4>
3972
</div>
4073
{{ else }}
74+
4175
{{/* Displays information about required quorum and number of voters */}}
4276
<div id="quorum-info">
4377
<h5>Number of Eligible Voters: {{ len .EligibleVoters }}</h5>

0 commit comments

Comments
 (0)