diff options
Diffstat (limited to 'askbot/templatetags/extra_filters_jinja.py')
-rw-r--r-- | askbot/templatetags/extra_filters_jinja.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/askbot/templatetags/extra_filters_jinja.py b/askbot/templatetags/extra_filters_jinja.py index b74502df..2228eed4 100644 --- a/askbot/templatetags/extra_filters_jinja.py +++ b/askbot/templatetags/extra_filters_jinja.py @@ -6,6 +6,8 @@ from django.core import exceptions as django_exceptions from django.utils.translation import ugettext as _ from django.contrib.humanize.templatetags import humanize from django.template import defaultfilters +from django.core.urlresolvers import reverse, resolve +from django.http import Http404 from askbot import exceptions as askbot_exceptions from askbot import auth from askbot.conf import settings as askbot_settings @@ -31,6 +33,17 @@ def absolutize_urls_func(text): absolutize_urls = register.filter(absolutize_urls_func) @register.filter +def clean_login_url(url): + """pass through, unless user was originally on the logout page""" + try: + resolver_match = resolve(url) + if resolver_match.url_name == 'question': + return url + except Http404: + pass + return reverse('index') + +@register.filter def country_display_name(country_code): country_dict = dict(countries.COUNTRIES) return country_dict[country_code] |