diff --git a/quest/events.py b/quest/events.py
index d5ef839..44d611f 100644
--- a/quest/events.py
+++ b/quest/events.py
@@ -11,6 +11,7 @@ import types
import random
import bleach
+from django.db import IntegrityError
from django.utils.timezone import localtime
from quest.models import *
@@ -341,12 +342,15 @@ def vote(socket, data):
)
if user.username:
v.user = user
- v.save()
+ try:
+ v.save()
+ except IntegrityError: # shouldn't we check this first?
+ return
- data = {}
- data['option_id'] = option_id
- data['polarity'] = polarity
- socket.send('vote', data)
+ data = {}
+ data['option_id'] = option_id
+ data['polarity'] = polarity
+ socket.send('vote', data)
events = {}
diff --git a/quest/jinja2/quest/quest.html b/quest/jinja2/quest/quest.html
index bd93db4..38da27b 100644
--- a/quest/jinja2/quest/quest.html
+++ b/quest/jinja2/quest/quest.html
@@ -71,7 +71,7 @@
{% for option in poll_options.filter(poll=post.poll).order_by("id") %}
-
+
|
{{ option.text }} |
diff --git a/quest/migrations/0012_auto_20180904_0732.py b/quest/migrations/0012_auto_20180904_0732.py
new file mode 100644
index 0000000..eb987ca
--- /dev/null
+++ b/quest/migrations/0012_auto_20180904_0732.py
@@ -0,0 +1,17 @@
+# Generated by Django 2.1 on 2018-09-04 11:32
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('quest', '0011_auto_20180902_2007'),
+ ]
+
+ operations = [
+ migrations.AlterUniqueTogether(
+ name='pollvote',
+ unique_together={('option', 'ip_address')},
+ ),
+ ]
diff --git a/quest/models.py b/quest/models.py
index e8196ac..e9a4a5c 100644
--- a/quest/models.py
+++ b/quest/models.py
@@ -126,6 +126,9 @@ class PollVote(models.Model):
null=True)
ip_address = models.GenericIPAddressField()
+ class Meta:
+ unique_together = ('option', 'ip_address')
+
class PageTitle(models.Model):
"""
diff --git a/quest/static/quest.js b/quest/static/quest.js
index d17bea4..e8fece6 100644
--- a/quest/static/quest.js
+++ b/quest/static/quest.js
@@ -140,6 +140,14 @@ function vote(post_id, option_id) {
let polarity = document.getElementById('pollInput-' + option_id).checked;
socket.send('vote', {post_id: post_id, option_id: option_id, polarity: polarity, quest_id: quest_id});
}
+function submitWritein(post_id) {
+ let writeinInput = document.getElementById('writeinInput');
+ if (!writeinInput) { return; }
+ let option_text = writeinInput.value;
+ writeinInput.value = '';
+ if (!option_text) { return; }
+ socket.emit('write_in', {option_text: option_text, post_id: post_id, room: room_id});
+}
/* Helpers */
function padToTwo(number) {
diff --git a/todo b/todo
new file mode 100644
index 0000000..ca52b9b
--- /dev/null
+++ b/todo
@@ -0,0 +1,34 @@
+New Features:
+Pages/appendixes
+Live indicator/countdown
+Notifications
+Anonymous names
+Banner images
+Search page
+Front page to show new quests
+Webm posting
+(you) counter
+Enable namefagging
+Account managament/logout
+Display profile link in header bar
+Tagging system
+Quote backlinks
+Make chat hideable
+
+Improvements:
+Revamp post editing
+More options for text posts (lists and so on)
+More rigorous input checking in events.py
+New post displays chat message
+Record email on signup
+Change urls
+Poll vote highlights entire option
+Poll vote doesn't disappear checkbox
+Total voters per poll
+Chat archives
+Only last 100 (50?) chat messages are loaded on page load
+Adjust quote preview postioning
+
+Port from old code:
+Edit post
+Writein