aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGalen Guyer <galen@galenguyer.com>2022-08-11 12:20:29 -0400
committerGalen Guyer <galen@galenguyer.com>2022-08-11 12:20:29 -0400
commit6168aff1c4cbeb0ab4858794c0a5bb21157be905 (patch)
tree5038abcc0a922179ead8184a3445a96567d132cc
parent39fa49a8389aa220cec3c249f2d09167b2556ded (diff)
update readme with what I've just done
-rw-r--r--README.md6
-rw-r--r--main.go21
2 files changed, 11 insertions, 16 deletions
diff --git a/README.md b/README.md
index 9c15208..d85b0a7 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ Imagine this. You're a somehow still functioning student organization of compute
Anyways, now we can vote online. It's cool, I guess? We have things such as:
- **Server-side rendering**. That's right, this site (should) (mostly) work without JavaScript.
- **Server Sent Events** for real-time vote results
- - **Limited voting options**. It's worse than Google Forms! (See To-Dos. I hope to change that someday(tm))
+ - **(Slightly less) limited voting options**. It's worse than Google Forms! (See To-Dos. All that's left now is ranked choice voting)
## Configuration
You'll need to set up these values in your environment. Ask an RTP for OIDC credentials. A docker-compose file is provided for convenience. Otherwise, I trust you to figure it out!
@@ -20,6 +20,6 @@ VOTE_STATE=
```
## To-Dos
-- [ ] Custom vote options
-- [ ] Write-in votes
+- [x] Custom vote options
+- [x] Write-in votes
- [ ] Ranked choice voting
diff --git a/main.go b/main.go
index baa186b..1a716d8 100644
--- a/main.go
+++ b/main.go
@@ -191,22 +191,17 @@ func main() {
return
}
- var vote database.Vote
+ vote := database.Vote{
+ Id: "",
+ PollId: pId,
+ UserId: claims.UserInfo.Username,
+ Option: c.PostForm("option"),
+ }
if hasOption(poll, c.PostForm("option")) {
- vote = database.Vote{
- Id: "",
- PollId: pId,
- UserId: claims.UserInfo.Username,
- Option: c.PostForm("option"),
- }
+ vote.Option = c.PostForm("option")
} else if poll.AllowWriteIns && c.PostForm("option") == "writein" {
- vote = database.Vote{
- Id: "",
- PollId: pId,
- UserId: claims.UserInfo.Username,
- Option: c.PostForm("writeinOption"),
- }
+ vote.Option = c.PostForm("writeinOption")
} else {
c.JSON(500, gin.H{"error": "Invalid Option"})
return