From 7a2f74c86e4ae75126448ec923ce0d920bab2100 Mon Sep 17 00:00:00 2001 From: iou1name Date: Mon, 1 Oct 2018 08:35:24 -0400 Subject: [PATCH] added quest homepage --- quest/jinja2/quest/quest_homepage.html | 89 ++++++++++++++++++++++++++ quest/views.py | 7 +- 2 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 quest/jinja2/quest/quest_homepage.html diff --git a/quest/jinja2/quest/quest_homepage.html b/quest/jinja2/quest/quest_homepage.html new file mode 100644 index 0000000..4246f71 --- /dev/null +++ b/quest/jinja2/quest/quest_homepage.html @@ -0,0 +1,89 @@ +{% extends "base.html" %} +{% block title %}{{ quest.title }}: Home{% endblock %} +{% block head %} + +{% endblock %} +{% block header %} +{% if request.user == quest.owner %} + Edit Quest + + + +{% endif %} + + + + {% if quest.live %} + + LIVE + + {% else %} + {% if quest.live_time %} + + Live in: ({{ localtime(quest.live_time).strftime('%Y-%m-%d %H:%M') }}) + + {% endif %} + {% endif %} + {% if request.session.get("hide_chat") == True %}←{% else %}→{% endif %} +{% endblock %} +{% block content %} +
+

Pages

+ + {% if appendices %} +

Appendices

+ + {% endif %} + {% if vars['next_page'] %} +
+ +
+ {% endif %} +
+
+

Chat

+
+ {% autoescape false %} + {% for message in chat_messages %} +
+
+ {{ message.user.username or quest.anon_name }} + {{ localtime(message.timestamp).strftime('%Y-%m-%d %H:%M:%S') }} + No.{{ message.id }} +
+
{{ message.message }}
+
+
+ {% endfor %} + {% endautoescape %} +
+
+
+ +{% endblock %} diff --git a/quest/views.py b/quest/views.py index 7d80ed3..38da6c6 100644 --- a/quest/views.py +++ b/quest/views.py @@ -33,7 +33,7 @@ def quest(request, quest_id, page_num='1'): page = Page.objects.get(quest=quest, page_num=page_num) except Page.DoesNotExist: messages.error(request, "Page not found, redirecting you.") - return redirect('quest:quest', quest_id=quest.id, page_num='1') + return redirect('quest:quest', quest_id=quest.id, page_num='0') posts = quest.post_set.filter(page=page) # TODO: filter by page_num as well dice_rolls = DiceRoll.objects.filter(dicecall__post__quest=quest) @@ -41,7 +41,10 @@ def quest(request, quest_id, page_num='1'): 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) + if page_num == '0': + return render(request, 'quest/quest_homepage.html', context) + else: + return render(request, 'quest/quest.html', context) def edit_quest(request, quest_id, page_num=1):