change check to base on Pages not Posts

This commit is contained in:
iou1name 2018-09-24 13:57:50 -04:00
parent 55cc375aea
commit cb487f231e

View File

@ -21,11 +21,11 @@ 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() if page_num > pages.reverse()[0].page_num:
posts = quest.post_set.filter(page_num=page_num)
if posts.count() == 0:
page_num = pages.reverse()[0].page_num page_num = pages.reverse()[0].page_num
return redirect('quest:quest', quest_id=quest.id, page_num=page_num) return redirect('quest:quest', quest_id=quest.id, page_num=page_num)
messages = quest.message_set.all()
posts = quest.post_set.filter(page_num=page_num)
# TODO: filter by page_num as well # TODO: filter by page_num as well
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)