';
- } else if (data.post_type == 'dice') {
+ } else if (data.post_type === 'dice') {
post_str += 'dicePost active_post">';
- } else if (data.post_type == 'poll') {
+ } else if (data.post_type === 'poll') {
post_str += 'pollPost active_post">';
}
post_str += '
' + data.date;
/* QM only */
- if (data.post_type == 'text') {
+ if (data.post_type === 'text') {
post_str += '
Edit';
post_str += '
Save';
- } else if (data.post_type == 'dice' || data.post_type == 'poll') {
+ } else if (data.post_type === 'dice' || data.post_type === 'poll') {
post_str += '
Close';
post_str += '
Open'
}
/* end QM only */
post_str += '
';
- if (data.post_type == 'text') {
+ if (data.post_type === 'text') {
post_str += data.post_text;
- } else if (data.post_type == 'dice') {
+ } else if (data.post_type === 'dice') {
post_str += '
' + data.post_text + ' - Open
';
- } else if (data.post_type == 'poll') {
+ } else if (data.post_type === 'poll') {
post_str += '
' + data.post_text + ' - Open
';
post_str += '
';
post_str += '';
@@ -52,7 +52,7 @@ function makePost() {
let qparea = document.getElementById('postTextArea');
let text = qparea.value.trim();
qparea.value = '';
- if (text == '') { return; }
+ if (text === '') { return; }
socket.send('text_post', {text: text, page_num: page_num, quest_id: quest_id});
}
function form_post(form_id, event) {
@@ -67,20 +67,22 @@ function form_post(form_id, event) {
document.getElementById(form_id).reset();
}
function close_post_send(post_id) {
+ data = {post_id: post_id, quest_id: quest_id}
let post = document.getElementById('questPostData-' + post_id);
if (post.parentElement.classList.contains('dicePost')) {
- data = {post_type: 'dice', post_id: post_id};
+ data.post_type = 'dice';
} else if (post.parentElement.classList.contains('pollPost')) {
- data = {post_type: 'poll', post_id: post_id};
+ data.post_type = 'poll';
}
socket.send('close_post', data);
}
function open_post_send(post_id) {
+ data = {post_id: post_id, quest_id: quest_id}
let post = document.getElementById('questPostData-' + post_id);
if (post.parentElement.classList.contains('dicePost')) {
- data = {post_type: 'dice', post_id: post_id};
+ data.post_type = 'dice';
} else if (post.parentElement.classList.contains('pollPost')) {
- data = {post_type: 'poll', post_id: post_id};
+ data.post_type = 'poll';
}
socket.send('open_post', data);
}
diff --git a/quest/views.py b/quest/views.py
index ff26a65..2e825c6 100644
--- a/quest/views.py
+++ b/quest/views.py
@@ -5,7 +5,7 @@ Quest and quest accessory views.
from django.shortcuts import render
from django.http import HttpResponse
-from .models import Quest
+from .models import Quest, DiceRoll
def index(request):
"""
@@ -22,5 +22,6 @@ def quest(request, quest_id, page_num=1):
quest = Quest.objects.get(id=quest_id)
messages = quest.message_set.all()
posts = quest.post_set.all()
- context = {'quest': quest, 'posts': posts, 'messages': messages, 'page_num': page_num}
+ dice_rolls = DiceRoll.objects.filter(dicecall__post__quest__id=quest_id)
+ context = locals()
return render(request, 'quest/quest.html', context)