diff --git a/quest/views.py b/quest/views.py index a208918..8087e59 100644 --- a/quest/views.py +++ b/quest/views.py @@ -21,11 +21,11 @@ def quest(request, quest_id, page_num=1): """ 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.filter(page_num=page_num) - if posts.count() == 0: + if 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) + messages = quest.message_set.all() + posts = quest.post_set.filter(page_num=page_num) # TODO: filter by page_num as well dice_rolls = DiceRoll.objects.filter(dicecall__post__quest=quest) poll_options = PollOption.objects.filter(poll__post__quest=quest)