basic support for new pages
This commit is contained in:
parent
5eb19761bd
commit
fb7ffc4d78
|
@ -406,6 +406,21 @@ def write_in(socket, data):
|
||||||
socket.send('update_post', data)
|
socket.send('update_post', data)
|
||||||
|
|
||||||
|
|
||||||
|
def new_page(socket, data):
|
||||||
|
"""
|
||||||
|
Called when the QM creates a new page.
|
||||||
|
"""
|
||||||
|
title = data.get('page_title')
|
||||||
|
|
||||||
|
quest = Quest.objects.get(id=socket.quest_id)
|
||||||
|
p = PageTitle(
|
||||||
|
quest=quest,
|
||||||
|
page_num=PageTitle.objects.filter(quest=quest).count() + 1,
|
||||||
|
title=title,
|
||||||
|
)
|
||||||
|
p.save()
|
||||||
|
|
||||||
|
|
||||||
events = {}
|
events = {}
|
||||||
for obj in dir():
|
for obj in dir():
|
||||||
if type(locals()[obj]) == types.FunctionType:
|
if type(locals()[obj]) == types.FunctionType:
|
||||||
|
|
|
@ -37,7 +37,7 @@ class PollForm(forms.Form):
|
||||||
continue
|
continue
|
||||||
self.fields[key] = forms.CharField(max_length=200)
|
self.fields[key] = forms.CharField(max_length=200)
|
||||||
|
|
||||||
class EditQuest(forms.Form):
|
class EditQuestForm(forms.Form):
|
||||||
"""
|
"""
|
||||||
Form for the /edit_quest page.
|
Form for the /edit_quest page.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -46,13 +46,13 @@
|
||||||
{{ localtime(post.timestamp).strftime('%Y-%m-%d %H:%M') }}
|
{{ localtime(post.timestamp).strftime('%Y-%m-%d %H:%M') }}
|
||||||
{% if request.user == quest.owner %}
|
{% if request.user == quest.owner %}
|
||||||
{% if post.post_type == "text" %}
|
{% if post.post_type == "text" %}
|
||||||
<br /><a href="javascript:void(0);" id="editPost-{{ post.id }}" onclick="edit_post({{ post.id }})">Edit</a>
|
<br><a href="javascript:void(0);" id="editPost-{{ post.id }}" onclick="edit_post({{ post.id }})">Edit</a>
|
||||||
<a href="javascript:void(0);" id="savePost-{{ post.id }}" onclick="save_post('{{ post.id }}')" style="display:none;">Save</a>
|
<a href="javascript:void(0);" id="savePost-{{ post.id }}" onclick="save_post('{{ post.id }}')" style="display:none;">Save</a>
|
||||||
{% elif post.post_type == "dice" %}
|
{% elif post.post_type == "dice" %}
|
||||||
<br /><a href="javascript:void(0);" id="closePost-{{ post.id }}" onclick="close_post_send({{ post.id }})"{% if not post.dicecall.open %} style="display:none;"{% endif %}>Close</a>
|
<br><a href="javascript:void(0);" id="closePost-{{ post.id }}" onclick="close_post_send({{ post.id }})"{% if not post.dicecall.open %} style="display:none;"{% endif %}>Close</a>
|
||||||
<a href="javascript:void(0);" id="openPost-{{ post.id }}" onclick="open_post_send({{ post.id }})"{% if post.dicecall.open %} style="display:none;"{% endif %}>Open</a>
|
<a href="javascript:void(0);" id="openPost-{{ post.id }}" onclick="open_post_send({{ post.id }})"{% if post.dicecall.open %} style="display:none;"{% endif %}>Open</a>
|
||||||
{% elif post.post_type == "poll" %}
|
{% elif post.post_type == "poll" %}
|
||||||
<br /><a href="javascript:void(0);" id="closePost-{{ post.id }}" onclick="close_post_send({{ post.id }})"{% if not post.poll.open %} style="display:none;"{% endif %}>Close</a>
|
<br><a href="javascript:void(0);" id="closePost-{{ post.id }}" onclick="close_post_send({{ post.id }})"{% if not post.poll.open %} style="display:none;"{% endif %}>Close</a>
|
||||||
<a href="javascript:void(0);" id="openPost-{{ post.id }}" onclick="open_post_send({{ post.id }})"{% if post.poll.open %} style="display:none;"{% endif %}>Open</a>
|
<a href="javascript:void(0);" id="openPost-{{ post.id }}" onclick="open_post_send({{ post.id }})"{% if post.poll.open %} style="display:none;"{% endif %}>Open</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
{% for option in poll_options.filter(poll=post.poll).order_by("id") %}
|
{% for option in poll_options.filter(poll=post.poll).order_by("id") %}
|
||||||
<tr id="optionRow-{{ option.id }}">
|
<tr id="optionRow-{{ option.id }}">
|
||||||
<td class="pollCheckBox">
|
<td class="pollCheckBox">
|
||||||
<input type="checkbox" {% if poll_votes.filter(option=option, ip_address=ip_address) %}checked="true"{% endif %} id="pollInput-{{ option.id }}" onchange="vote({{ post.id }}, {{ option.id }})"{% if not post.poll.open %} disabled{% endif %}/>
|
<input type="checkbox" {% if poll_votes.filter(option=option, ip_address=ip_address) %}checked="true"{% endif %} id="pollInput-{{ option.id }}" onchange="vote({{ post.id }}, {{ option.id }})"{% if not post.poll.open %} disabled{% endif %}>
|
||||||
<label for="pollInput-{{ option.id }}"></label>
|
<label for="pollInput-{{ option.id }}"></label>
|
||||||
</td>
|
</td>
|
||||||
<td class="option_text">{{ option.text }}</td>
|
<td class="option_text">{{ option.text }}</td>
|
||||||
|
@ -85,8 +85,8 @@
|
||||||
</table>
|
</table>
|
||||||
{% if post.poll.open and post.poll.allow_writein %}
|
{% if post.poll.open and post.poll.allow_writein %}
|
||||||
<div id="writeinContainer-{{ post.id }}">
|
<div id="writeinContainer-{{ post.id }}">
|
||||||
Write-in: <input type="text" id="writeinInput-{{ post.id }}" placeholder="Custom choice..." maxlength="200" /><br />
|
Write-in: <input type="text" id="writeinInput-{{ post.id }}" placeholder="Custom choice..." maxlength="200"><br>
|
||||||
<input type="submit" id="writeinSubmit-{{ post.id }}" value="Submit" onclick="submitWritein({{ post.id }});"/>
|
<input type="submit" id="writeinSubmit-{{ post.id }}" value="Submit" onclick="submitWritein({{ post.id }});">
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -101,27 +101,28 @@
|
||||||
<li><a class="QMPostTab active" href="javascript:void(0);" onclick="openPostTab(event, 'QMPostText')">Text</a></li>
|
<li><a class="QMPostTab active" href="javascript:void(0);" onclick="openPostTab(event, 'QMPostText')">Text</a></li>
|
||||||
<li><a class="QMPostTab" href="javascript:void(0);" onclick="openPostTab(event, 'QMPostDice')">Dice</a></li>
|
<li><a class="QMPostTab" href="javascript:void(0);" onclick="openPostTab(event, 'QMPostDice')">Dice</a></li>
|
||||||
<li><a class="QMPostTab" href="javascript:void(0);" onclick="openPostTab(event, 'QMPostPoll')">Poll</a></li>
|
<li><a class="QMPostTab" href="javascript:void(0);" onclick="openPostTab(event, 'QMPostPoll')">Poll</a></li>
|
||||||
|
<li><a class="QMPostTab" href="javascript:void(0);" onclick="openPostTab(event, 'QMPage')">Page</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="QMPostText" class="QMPostTabContent" style="display:initial;">
|
<div id="QMPostText" class="QMPostTabContent" style="display:initial;">
|
||||||
<textarea id="postTextArea"></textarea><br />
|
<textarea id="postTextArea"></textarea><br>
|
||||||
<input type="submit" name="newPost" value="Post" onclick="makePost();"/>
|
<input type="submit" name="newPost" value="Post" onclick="makePost();">
|
||||||
</div>
|
</div>
|
||||||
<div id="QMPostDice" class="QMPostTabContent" style="display:none;">
|
<div id="QMPostDice" class="QMPostTabContent" style="display:none;">
|
||||||
Dice for the dice god.<br />
|
Dice for the dice god.<br>
|
||||||
<form id="QMDicePostForm" action="javascript:void(0);" onsubmit="form_post('QMDicePostForm', 'dice_post');">
|
<form id="QMDicePostForm" action="javascript:void(0);" onsubmit="form_post('QMDicePostForm', 'dice_post');">
|
||||||
Dice: <input type="number" name="diceNum" min="1" max="99" required/>
|
Dice: <input type="number" name="diceNum" min="1" max="99" required>
|
||||||
d <input type="number" name="diceSides" min="1" max="99" required/>
|
d <input type="number" name="diceSides" min="1" max="99" required>
|
||||||
±<input type="number" name="diceMod" min="-999" max="999"/>
|
±<input type="number" name="diceMod" min="-999" max="999">
|
||||||
<input type="checkbox" name="diceStrict"/>
|
<input type="checkbox" name="diceStrict">
|
||||||
<span class="tooltip" title="Only take matching rolls.">Strict</span><br />
|
<span class="tooltip" title="Only take matching rolls.">Strict</span><br>
|
||||||
<input type="checkbox" onclick="document.getElementById('diceChal').disabled=!this.checked;"/>
|
<input type="checkbox" onclick="document.getElementById('diceChal').disabled=!this.checked;">
|
||||||
<span class="tooltip" title="Dice challenge">DC:</span>
|
<span class="tooltip" title="Dice challenge">DC:</span>
|
||||||
<input type="number" name="diceChal" id="diceChal" min="1" max="999" disabled/><br />
|
<input type="number" name="diceChal" id="diceChal" min="1" max="999" disabled><br>
|
||||||
<input type="checkbox" onclick="document.getElementById('diceRollsTaken').disabled=!this.checked;"/>
|
<input type="checkbox" onclick="document.getElementById('diceRollsTaken').disabled=!this.checked;">
|
||||||
<span class="tooltip" title="Automatically close the dice call after this many rolls have been made.">Rolls Taken:</span>
|
<span class="tooltip" title="Automatically close the dice call after this many rolls have been made.">Rolls Taken:</span>
|
||||||
<input type="number" name="diceRollsTaken" id="diceRollsTaken" min="1" max="99" disabled/><br />
|
<input type="number" name="diceRollsTaken" id="diceRollsTaken" min="1" max="99" disabled><br>
|
||||||
<input type="submit" name="submit" value="Roll 'em"/>
|
<input type="submit" name="submit" value="Roll 'em">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div id="QMPostPoll" class="QMPostTabContent" style="display:none;">
|
<div id="QMPostPoll" class="QMPostTabContent" style="display:none;">
|
||||||
|
@ -130,13 +131,19 @@
|
||||||
<a href="javascript:void(0);" id="pollInsertNewOption" onclick="insertPollOption()">[+]</a>
|
<a href="javascript:void(0);" id="pollInsertNewOption" onclick="insertPollOption()">[+]</a>
|
||||||
<a href="javascript:void(0);" onclick="removePollOption()">[-]</a>
|
<a href="javascript:void(0);" onclick="removePollOption()">[-]</a>
|
||||||
<div id="pollOptions">
|
<div id="pollOptions">
|
||||||
<div><input type="text" name="pollOption-1" class="pollOption" placeholder="Option 1" maxlength="200" /></div>
|
<div><input type="text" name="pollOption-1" class="pollOption" placeholder="Option 1" maxlength="200"></div>
|
||||||
<div><input type="text" name="pollOption-2" class="pollOption" placeholder="Option 2" maxlength="200" /></div>
|
<div><input type="text" name="pollOption-2" class="pollOption" placeholder="Option 2" maxlength="200"></div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<input type="checkbox" name="multi_choice" />Allow multiple choices<br />
|
<input type="checkbox" name="multi_choice">Allow multiple choices<br>
|
||||||
<input type="checkbox" name="allow_writein" />Allow user-created options<br />
|
<input type="checkbox" name="allow_writein">Allow user-created options<br>
|
||||||
<input type="submit" name="submit" value="Submit" />
|
<input type="submit" name="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div id="QMPage" class="QMPostTabContent" style="display:none;">
|
||||||
|
<form id="QMPageForm" action="javascript:void(0);" onsubmit="form_post('QMPageForm', 'new_page');">
|
||||||
|
New Page: <input type="text" name="page_title" maxlength="200" value="Page {{ pages.count() + 1 }}"><br>
|
||||||
|
<input type="submit" name="submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -159,7 +166,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endautoescape %}
|
{% endautoescape %}
|
||||||
</div>
|
</div>
|
||||||
<div id="messageTextDiv"><textarea id="messageTextArea"></textarea></div>
|
<div id="messageTextDiv"><textarea id="messageTextArea" maxlength="512"></textarea></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="preview" style="display:none;"></div>
|
<div id="preview" style="display:none;"></div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -6,7 +6,7 @@ from django.shortcuts import render, redirect
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
from .models import Quest, DiceRoll, PollOption, PollVote, PageTitle
|
from .models import Quest, DiceRoll, PollOption, PollVote, PageTitle
|
||||||
from .forms import EditQuest
|
from .forms import EditQuestForm
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
"""
|
"""
|
||||||
|
@ -22,7 +22,7 @@ def quest(request, quest_id, page_num=1):
|
||||||
quest = Quest.objects.get(id=quest_id)
|
quest = Quest.objects.get(id=quest_id)
|
||||||
pages = PageTitle.objects.filter(quest=quest).order_by('page_num')
|
pages = PageTitle.objects.filter(quest=quest).order_by('page_num')
|
||||||
messages = quest.message_set.all()
|
messages = quest.message_set.all()
|
||||||
posts = quest.post_set.all()
|
posts = quest.post_set.filter(page_num=page_num)
|
||||||
dice_rolls = DiceRoll.objects.filter(dicecall__post__quest=quest)
|
dice_rolls = DiceRoll.objects.filter(dicecall__post__quest=quest)
|
||||||
poll_options = PollOption.objects.filter(poll__post__quest=quest)
|
poll_options = PollOption.objects.filter(poll__post__quest=quest)
|
||||||
poll_votes = PollVote.objects.filter(option__poll__post__quest=quest)
|
poll_votes = PollVote.objects.filter(option__poll__post__quest=quest)
|
||||||
|
@ -39,7 +39,7 @@ def edit_quest(request, quest_id, page_num=1):
|
||||||
if quest.owner != request.user:
|
if quest.owner != request.user:
|
||||||
return redirect('quest:quest', quest_id=quest_id, page_num=page_num)
|
return redirect('quest:quest', quest_id=quest_id, page_num=page_num)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = EditQuest(request.POST)
|
form = EditQuestForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
quest.anon_name = form.cleaned_data['anon_name']
|
quest.anon_name = form.cleaned_data['anon_name']
|
||||||
quest.save()
|
quest.save()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user