Compare commits
2 Commits
247fc6729a
...
cb487f231e
Author | SHA1 | Date | |
---|---|---|---|
cb487f231e | |||
55cc375aea |
|
@ -13,6 +13,7 @@ import random
|
|||
import bleach
|
||||
from django.db import IntegrityError
|
||||
from django.utils.timezone import localtime
|
||||
from django.urls import reverse
|
||||
|
||||
from quest.models import *
|
||||
from quest.tools import handle_img
|
||||
|
@ -420,6 +421,12 @@ def new_page(socket, data):
|
|||
)
|
||||
p.save()
|
||||
|
||||
data = {}
|
||||
data['page_num'] = p.page_num
|
||||
data['title'] = title
|
||||
data['url'] = reverse('quest:quest', args=[socket.quest_id, p.page_num])
|
||||
socket.send('new_page', data)
|
||||
|
||||
|
||||
events = {}
|
||||
for obj in dir():
|
||||
|
|
|
@ -148,6 +148,11 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if page_num != pages.reverse()[0].page_num %}
|
||||
<div id="nextPageContainer">
|
||||
<input type="button" id="nextPage" value="Next Page: {{ pages[page_num].title }}" onclick="window.location.href='{{ url('quest:quest', args=[quest_id, page_num+1]) }}'">
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="chatPane" style="display:{% if request.session.get("hide_chat") == True %}none{% else %}flex{% endif %};">
|
||||
<h1>Chat</h1>
|
||||
|
|
|
@ -96,6 +96,20 @@ h3 {
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
#nextPageContainer {
|
||||
width: 100%;
|
||||
height: 5em;
|
||||
padding: 1em;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#nextPage {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#chatPane {
|
||||
height: calc(100% - var(--header-height));
|
||||
width: 30%;
|
||||
|
|
|
@ -154,6 +154,11 @@ socket.events['vote'] = function(data) {
|
|||
socket.events['set_option_box'] = function(data) {
|
||||
document.getElementById('pollInput-' + data.option_id).checked = data.polarity;
|
||||
}
|
||||
socket.events['new_page'] = function(data) {
|
||||
if (page_num != data.page_num-1) { return; }
|
||||
let html_str = '<div id="nextPageContainer"><input type="button" id="nextPage" value="Next Page: ' + data.title + '" onclick="window.location.href=\'' + SCRIPT_NAME + data.url + '\'"></div>';
|
||||
document.getElementById('questPane').innerHTML = document.getElementById('questPane').innerHTML + html_str;
|
||||
}
|
||||
|
||||
/* Websocket send */
|
||||
function vote(post_id, option_id) {
|
||||
|
|
|
@ -21,8 +21,12 @@ def quest(request, quest_id, page_num=1):
|
|||
"""
|
||||
quest = Quest.objects.get(id=quest_id)
|
||||
pages = PageTitle.objects.filter(quest=quest).order_by('page_num')
|
||||
if page_num > pages.reverse()[0].page_num:
|
||||
page_num = pages.reverse()[0].page_num
|
||||
return redirect('quest:quest', quest_id=quest.id, page_num=page_num)
|
||||
messages = quest.message_set.all()
|
||||
posts = quest.post_set.filter(page_num=page_num)
|
||||
# TODO: filter by page_num as well
|
||||
dice_rolls = DiceRoll.objects.filter(dicecall__post__quest=quest)
|
||||
poll_options = PollOption.objects.filter(poll__post__quest=quest)
|
||||
poll_votes = PollVote.objects.filter(option__poll__post__quest=quest)
|
||||
|
|
Loading…
Reference in New Issue
Block a user