diff --git a/create_quest/views.py b/create_quest/views.py index 078c9c4..96ae897 100644 --- a/create_quest/views.py +++ b/create_quest/views.py @@ -6,7 +6,7 @@ from django.contrib import messages from django.shortcuts import redirect, render from .forms import QuestForm, PostForm -from quest.models import Quest, Post +from quest.models import Quest, Post, PageTitle def index(request): """ @@ -21,6 +21,12 @@ def index(request): quest.save() post.quest = quest post.save() + page = PageTitle( + quest=quest, + page_num=1, + title="Page 1" + ) + page.save() return redirect('quest:quest', quest_id=quest.id) else: quest_form = QuestForm() diff --git a/quest/jinja2/quest/quest.html b/quest/jinja2/quest/quest.html index f46e7dc..82c1eb0 100644 --- a/quest/jinja2/quest/quest.html +++ b/quest/jinja2/quest/quest.html @@ -19,9 +19,9 @@ {% endif %}
  • {% endblock %} diff --git a/quest/views.py b/quest/views.py index 509fb01..677ca6c 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, DiceRoll, PollOption, PollVote +from .models import Quest, DiceRoll, PollOption, PollVote, PageTitle def index(request): """ @@ -20,11 +20,12 @@ def quest(request, quest_id, page_num=1): Arbituary quest page view. """ quest = Quest.objects.get(id=quest_id) + pages = PageTitle.objects.filter(quest=quest).order_by('page_num') messages = quest.message_set.all() posts = quest.post_set.all() - dice_rolls = DiceRoll.objects.filter(dicecall__post__quest__id=quest_id) - poll_options = PollOption.objects.filter(poll__post__quest__id=quest_id) - poll_votes = PollVote.objects.filter(option__poll__post__quest__id=quest_id) + 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) ip_address = request.META['REMOTE_ADDR'] context = locals() return render(request, 'quest/quest.html', context)