frontend of subscription system started
This commit is contained in:
parent
7dd1c9bf30
commit
f58b0c0a04
|
@ -17,6 +17,10 @@
|
||||||
<div id="header" class="header" style="{% if request.session.get("hide_header") == True %}display:none;{% else %}display:flex;{% endif %}">
|
<div id="header" class="header" style="{% if request.session.get("hide_header") == True %}display:none;{% else %}display:flex;{% endif %}">
|
||||||
<span><a onclick="toggle_header();" href="javascript:void(0);">↑</a></span>
|
<span><a onclick="toggle_header();" href="javascript:void(0);">↑</a></span>
|
||||||
<span><a href="{{ url('homepage:index') }}">Home</a></span>
|
<span><a href="{{ url('homepage:index') }}">Home</a></span>
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
<span id="profileLink"><a href="{{ url('user:profile', args=[request.user.id]) }}">{{ request.user.username }}</a></span>
|
||||||
|
<span id="subscriptions">{{ get_sub_msgs(request=request)|length }}</span>
|
||||||
|
{% endif %}
|
||||||
{% block header %}{% endblock %}
|
{% block header %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
<div id="headerHidden" class="header" style="{% if request.session.get("hide_header") == True %}display:flex;{% else %}display:none;{% endif %}">
|
<div id="headerHidden" class="header" style="{% if request.session.get("hide_header") == True %}display:flex;{% else %}display:none;{% endif %}">
|
||||||
|
|
|
@ -24,8 +24,5 @@
|
||||||
Live in: <span id="liveCountdown"></span> (<span id="liveTime">{% if quest.live_time %}{{ localtime(quest.live_time).strftime('%Y-%m-%d %H:%M') }}{% endif %}</span>)
|
Live in: <span id="liveCountdown"></span> (<span id="liveTime">{% if quest.live_time %}{{ localtime(quest.live_time).strftime('%Y-%m-%d %H:%M') }}{% endif %}</span>)
|
||||||
</span>
|
</span>
|
||||||
<span id="space"></span>
|
<span id="space"></span>
|
||||||
{% if request.user.is_authenticated %}
|
|
||||||
<span id="profileLink"><a href="{{ url('user:profile', args=[request.user.id]) }}">{{ request.user.username }}</a></span>
|
|
||||||
{% endif %}
|
|
||||||
<span id="toggleChat"><a onclick="toggle_chat()" href="javascript:void(0);">{% if request.session.get("hide_chat") == True %}←{% else %}→{% endif %}</a></span>
|
<span id="toggleChat"><a onclick="toggle_chat()" href="javascript:void(0);">{% if request.session.get("hide_chat") == True %}←{% else %}→{% endif %}</a></span>
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
<form id="subscribe" method="post" action="{{ url('quest:subscribe', kwargs={'quest_id': quest_id}) }}">
|
<form id="subscribe" method="post" action="{{ url('quest:subscribe', kwargs={'quest_id': quest_id}) }}">
|
||||||
{{ csrf_input }}
|
{{ csrf_input }}
|
||||||
<a onclick="document.getElementById('subscribe').submit()">Subscribe</a>
|
<a href="javascript:void(0);" onclick="document.getElementById('subscribe').submit()">Subscribe</a>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<h3>Pages</h3>
|
<h3>Pages</h3>
|
||||||
|
|
|
@ -55,6 +55,10 @@ a:hover {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#subscriptions {
|
||||||
|
background-color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
#headerHidden {
|
#headerHidden {
|
||||||
width: 1em;
|
width: 1em;
|
||||||
border-right: 1px solid #ccc;
|
border-right: 1px solid #ccc;
|
||||||
|
|
|
@ -8,6 +8,15 @@ from django.urls import reverse
|
||||||
from django.utils.timezone import template_localtime
|
from django.utils.timezone import template_localtime
|
||||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
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):
|
def environment(**options):
|
||||||
"""
|
"""
|
||||||
Custom Jinja2 environment.
|
Custom Jinja2 environment.
|
||||||
|
@ -23,5 +32,6 @@ def environment(**options):
|
||||||
'static': staticfiles_storage.url,
|
'static': staticfiles_storage.url,
|
||||||
'get_messages': api.get_messages,
|
'get_messages': api.get_messages,
|
||||||
'localtime': template_localtime,
|
'localtime': template_localtime,
|
||||||
|
'get_sub_msgs': get_sub_msgs,
|
||||||
})
|
})
|
||||||
return env
|
return env
|
||||||
|
|
Loading…
Reference in New Issue
Block a user