From f58b0c0a04928e2626e1b9a4f819091814b0568b Mon Sep 17 00:00:00 2001 From: iou1name Date: Fri, 12 Oct 2018 13:54:58 -0400 Subject: [PATCH] frontend of subscription system started --- jinja2/base.html | 4 ++++ quest/jinja2/quest/quest_header.html | 3 --- quest/jinja2/quest/quest_homepage.html | 2 +- static/base.css | 4 ++++ titivillus/jinja2.py | 10 ++++++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/jinja2/base.html b/jinja2/base.html index 6959ce4..3a3e656 100644 --- a/jinja2/base.html +++ b/jinja2/base.html @@ -17,6 +17,10 @@
diff --git a/quest/jinja2/quest/quest_header.html b/quest/jinja2/quest/quest_header.html index 5ebe8d0..9fd9c50 100644 --- a/quest/jinja2/quest/quest_header.html +++ b/quest/jinja2/quest/quest_header.html @@ -24,8 +24,5 @@ Live in: ({% if quest.live_time %}{{ localtime(quest.live_time).strftime('%Y-%m-%d %H:%M') }}{% endif %}) - {% if request.user.is_authenticated %} - {{ request.user.username }} - {% endif %} {% if request.session.get("hide_chat") == True %}←{% else %}→{% endif %} diff --git a/quest/jinja2/quest/quest_homepage.html b/quest/jinja2/quest/quest_homepage.html index 3f48d60..2d95b79 100644 --- a/quest/jinja2/quest/quest_homepage.html +++ b/quest/jinja2/quest/quest_homepage.html @@ -40,7 +40,7 @@ {% if request.user.is_authenticated %}
{{ csrf_input }} - Subscribe + Subscribe
{% endif %}

Pages

diff --git a/static/base.css b/static/base.css index 99b8fc4..d57dd03 100644 --- a/static/base.css +++ b/static/base.css @@ -55,6 +55,10 @@ a:hover { padding-left: 0; } +#subscriptions { + background-color: orange; +} + #headerHidden { width: 1em; border-right: 1px solid #ccc; diff --git a/titivillus/jinja2.py b/titivillus/jinja2.py index c85594d..265c871 100644 --- a/titivillus/jinja2.py +++ b/titivillus/jinja2.py @@ -8,6 +8,15 @@ from django.urls import reverse from django.utils.timezone import template_localtime from django.contrib.staticfiles.storage import staticfiles_storage +def get_sub_msgs(**kwargs): + """Returns all messages 'subscription' in the tag.""" + messages = api.get_messages(**kwargs) + sub_msgs = [] + for message in messages: + if 'subscription' in message.tags: + sub_msgs.append(messages) + return sub_msgs + def environment(**options): """ Custom Jinja2 environment. @@ -23,5 +32,6 @@ def environment(**options): 'static': staticfiles_storage.url, 'get_messages': api.get_messages, 'localtime': template_localtime, + 'get_sub_msgs': get_sub_msgs, }) return env