Titivillus/quest/views.py
2018-08-29 14:01:31 -04:00

30 lines
893 B
Python

#!/usr/bin/env python3
"""
Quest and quest accessory views.
"""
from django.shortcuts import render
from django.http import HttpResponse
from .models import Quest, DiceRoll, PollOption, PollVote
def index(request):
"""
/quest page index. Possibly not needed.
"""
#return render(request, "Hello, world. You're at the quest index.", {})
return HttpResponse("Hello, world. You're at the quest index.")
def quest(request, quest_id, page_num=1):
"""
Arbituary quest page view.
"""
quest = Quest.objects.get(id=quest_id)
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)
context = locals()
return render(request, 'quest/quest.html', context)