Skip to content

Commit 7e31843

Browse files
committed
Make polls modifiable by removing Reveal
Polls that are hidden really shouldn't be revealed
1 parent c058f33 commit 7e31843

File tree

3 files changed

+1
-51
lines changed

3 files changed

+1
-51
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ gofmt -w -s *.go logging sse database
4646

4747
- [ ] Don't let the user fuck it up
4848
- [ ] Show E-Board polls with a higher priority
49-
- [ ] Move Hide Vote to create instead of after you vote :skull:
49+
- [x] Move Hide Vote to create instead of after you vote :skull:
5050
- [ ] Display the reason why a user is on the results page of a running poll
5151
- [ ] Display minimum time left that a poll is open

main.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,6 @@ func main() {
230230
}
231231

232232
canModify := containsString(claims.UserInfo.Groups, "active_rtp") || containsString(claims.UserInfo.Groups, "eboard") || poll.CreatedBy == claims.UserInfo.Username
233-
if poll.Gatekeep {
234-
canModify = false
235-
}
236233

237234
c.HTML(200, "poll.tmpl", gin.H{
238235
"Id": poll.Id,
@@ -400,9 +397,6 @@ func main() {
400397
}
401398

402399
canModify := containsString(claims.UserInfo.Groups, "active_rtp") || containsString(claims.UserInfo.Groups, "eboard") || poll.CreatedBy == claims.UserInfo.Username
403-
if poll.Gatekeep {
404-
canModify = false
405-
}
406400

407401
c.HTML(200, "result.tmpl", gin.H{
408402
"Id": poll.Id,
@@ -455,43 +449,6 @@ func main() {
455449
c.Redirect(302, "/results/"+poll.Id)
456450
}))
457451

458-
r.POST("/poll/:id/reveal", csh.AuthWrapper(func(c *gin.Context) {
459-
cl, _ := c.Get("cshauth")
460-
claims := cl.(cshAuth.CSHClaims)
461-
462-
poll, err := database.GetPoll(c, c.Param("id"))
463-
if err != nil {
464-
c.JSON(500, gin.H{"error": err.Error()})
465-
return
466-
}
467-
468-
if poll.CreatedBy != claims.UserInfo.Username {
469-
c.JSON(403, gin.H{"error": "Only the creator can reveal a poll result"})
470-
return
471-
}
472-
473-
err = poll.Reveal(c)
474-
if err != nil {
475-
c.JSON(500, gin.H{"error": err.Error()})
476-
return
477-
}
478-
pId, _ := primitive.ObjectIDFromHex(poll.Id)
479-
action := database.Action{
480-
Id: "",
481-
PollId: pId,
482-
Date: primitive.NewDateTimeFromTime(time.Now()),
483-
User: claims.UserInfo.Username,
484-
Action: "Reveal Results",
485-
}
486-
err = database.WriteAction(c, &action)
487-
if err != nil {
488-
c.JSON(500, gin.H{"error": err.Error()})
489-
return
490-
}
491-
492-
c.Redirect(302, "/results/"+poll.Id)
493-
}))
494-
495452
r.POST("/poll/:id/close", csh.AuthWrapper(func(c *gin.Context) {
496453
cl, _ := c.Get("cshauth")
497454
claims := cl.(cshAuth.CSHClaims)

templates/result.tmpl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@
5252
{{ end }}
5353
</div>
5454
{{ end }}
55-
{{ if and (.CanModify) (.IsHidden) }}
56-
<br />
57-
<br />
58-
<form action="/poll/{{ .Id }}/reveal" method="POST">
59-
<button type="submit" class="btn btn-success">Reveal Votes</button>
60-
</form>
61-
{{ end }}
6255
{{ if and (.CanModify) (not .IsHidden) }}
6356
<br />
6457
<br />

0 commit comments

Comments
 (0)