add 'next page' button to quest page
This commit is contained in:
parent
247fc6729a
commit
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) {
|
||||
|
|
|
@ -23,6 +23,10 @@ def quest(request, quest_id, page_num=1):
|
|||
pages = PageTitle.objects.filter(quest=quest).order_by('page_num')
|
||||
messages = quest.message_set.all()
|
||||
posts = quest.post_set.filter(page_num=page_num)
|
||||
if posts.count() == 0:
|
||||
page_num = pages.reverse()[0].page_num
|
||||
return redirect('quest:quest', quest_id=quest.id, 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