Redirect to login url after logout
This commit is contained in:
36
apps/common/templatetags/settings.py
Normal file
36
apps/common/templatetags/settings.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import re
|
||||
|
||||
from django.template import Node, Variable
|
||||
from django.template import TemplateSyntaxError, Library, VariableDoesNotExist
|
||||
from django.template.defaultfilters import stringfilter
|
||||
from django.template.defaultfilters import date as datefilter
|
||||
from django.conf import settings
|
||||
|
||||
register = Library()
|
||||
|
||||
|
||||
class SettingsNode(Node):
|
||||
def __init__(self, format_string, var_name):
|
||||
self.format_string = format_string
|
||||
self.var_name = var_name
|
||||
def render(self, context):
|
||||
#context[self.var_name] = settings(self.format_string)
|
||||
context[self.var_name] = getattr(settings, self.format_string, '')
|
||||
return ''
|
||||
|
||||
|
||||
@register.tag
|
||||
def get_setting(parser, token):
|
||||
# This version uses a regular expression to parse tag contents.
|
||||
try:
|
||||
# Splitting by None == splitting by spaces.
|
||||
tag_name, arg = token.contents.split(None, 1)
|
||||
except ValueError:
|
||||
raise TemplateSyntaxError, "%r tag requires arguments" % token.contents.split()[0]
|
||||
m = re.search(r'(.*?) as (\w+)', arg)
|
||||
if not m:
|
||||
raise TemplateSyntaxError, "%r tag had invalid arguments" % tag_name
|
||||
format_string, var_name = m.groups()
|
||||
if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")):
|
||||
raise TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name
|
||||
return SettingsNode(format_string[1:-1], var_name)
|
||||
@@ -2,6 +2,7 @@
|
||||
{% load i18n %}
|
||||
{% load project_tags %}
|
||||
{% load navigation %}
|
||||
{% load settings %}
|
||||
|
||||
{% block html_title %}{% project_name %}{% block title %}{% endblock %}{% endblock %}
|
||||
|
||||
@@ -46,7 +47,8 @@
|
||||
<input type="submit" value="{% trans 'Go' %}" />
|
||||
</form>
|
||||
</li>
|
||||
<li><a class="logout" href="{% if user.is_anonymous %}{% url login_view %}?next=/{% else %}{% url logout_view %}{% endif %}">{% if user.is_anonymous %}{% trans 'Login' %}{% else %}{% trans 'Logout' %}{% endif %}</a></li>
|
||||
{% get_setting "LOGIN_URL" as login_url %}
|
||||
<li><a class="logout" href="{% if user.is_anonymous %}{% url login_view %}?next=/{% else %}{% url logout_view %}?next={{ login_url }}{% endif %}">{% if user.is_anonymous %}{% trans 'Login' %}{% else %}{% trans 'Logout' %}{% endif %}</a></li>
|
||||
{% endblock %}
|
||||
|
||||
{% block web_theme_main_navigation %}
|
||||
|
||||
Reference in New Issue
Block a user