page titles populate drop down on quest page

This commit is contained in:
iou1name 2018-09-05 12:22:45 -04:00
parent 6117fbe1e7
commit eaef094444
3 changed files with 15 additions and 8 deletions

View File

@ -6,7 +6,7 @@ from django.contrib import messages
from django.shortcuts import redirect, render from django.shortcuts import redirect, render
from .forms import QuestForm, PostForm from .forms import QuestForm, PostForm
from quest.models import Quest, Post from quest.models import Quest, Post, PageTitle
def index(request): def index(request):
""" """
@ -21,6 +21,12 @@ def index(request):
quest.save() quest.save()
post.quest = quest post.quest = quest
post.save() post.save()
page = PageTitle(
quest=quest,
page_num=1,
title="Page 1"
)
page.save()
return redirect('quest:quest', quest_id=quest.id) return redirect('quest:quest', quest_id=quest.id)
else: else:
quest_form = QuestForm() quest_form = QuestForm()

View File

@ -19,9 +19,9 @@
{% endif %} {% endif %}
<li> <li>
<select onChange="window.location.href=this.value"> <select onChange="window.location.href=this.value">
{# for page in pages %} {% for page in pages %}
<option value="{{ url_for('.quest', quest_id=quest_id, page_num=page[1]) }}"{% if page[1] == page_num %} selected="yes"{% endif %}>{{ page[2] }}</option> <option value="{{ url('quest:quest', args=[quest_id, page.page_num]) }}"{% if page.page_num == page_num %} selected="yes"{% endif %}>{{ page.title }}</option>
{% endfor #} {% endfor %}
</select> </select>
</li> </li>
{% endblock %} {% endblock %}

View File

@ -5,7 +5,7 @@ Quest and quest accessory views.
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from .models import Quest, DiceRoll, PollOption, PollVote from .models import Quest, DiceRoll, PollOption, PollVote, PageTitle
def index(request): def index(request):
""" """
@ -20,11 +20,12 @@ def quest(request, quest_id, page_num=1):
Arbituary quest page view. Arbituary quest page view.
""" """
quest = Quest.objects.get(id=quest_id) quest = Quest.objects.get(id=quest_id)
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.all()
dice_rolls = DiceRoll.objects.filter(dicecall__post__quest__id=quest_id) dice_rolls = DiceRoll.objects.filter(dicecall__post__quest=quest)
poll_options = PollOption.objects.filter(poll__post__quest__id=quest_id) poll_options = PollOption.objects.filter(poll__post__quest=quest)
poll_votes = PollVote.objects.filter(option__poll__post__quest__id=quest_id) poll_votes = PollVote.objects.filter(option__poll__post__quest=quest)
ip_address = request.META['REMOTE_ADDR'] ip_address = request.META['REMOTE_ADDR']
context = locals() context = locals()
return render(request, 'quest/quest.html', context) return render(request, 'quest/quest.html', context)