diff --git a/src/postorius/context_processors.py b/src/postorius/context_processors.py index 6a9a4b4..8d5e65b 100644 --- a/src/postorius/context_processors.py +++ b/src/postorius/context_processors.py @@ -20,6 +20,7 @@ from django.conf import settings from django.core.urlresolvers import reverse, NoReverseMatch +from django.shortcuts import resolve_url logger = logging.getLogger(__name__) @@ -47,4 +48,8 @@ 'postorius_base_template': template_to_extend, 'request': request, 'hyperkitty_url': hyperkitty_url, + # Resolve the login and logout URLs from the settings (they can be + # either URLs or view names since Django 1.6) + 'login_url': resolve_url(settings.LOGIN_URL), + 'logout_url': resolve_url(settings.LOGOUT_URL), } diff --git a/src/postorius/templates/postorius/base.html b/src/postorius/templates/postorius/base.html index 890c1ec..80acfcc 100644 --- a/src/postorius/templates/postorius/base.html +++ b/src/postorius/templates/postorius/base.html @@ -34,9 +34,9 @@
{% trans "You have to log in to subscribe to this list." %}
- + {% endif %} diff --git a/src/postorius/urls.py b/src/postorius/urls.py index f5aafe8..729dc8e 100644 --- a/src/postorius/urls.py +++ b/src/postorius/urls.py @@ -20,6 +20,7 @@ from django.conf import settings from django.conf.urls.static import static from django.contrib.auth.views import login as login_view +from django.contrib.auth.views import logout as logout_view from postorius.views import * from postorius.views.generic import * @@ -103,7 +104,7 @@ # /account/ url(r'^accounts/login/$', login_view, {"template_name": "postorius/login.html"}, name='user_login'), - url(r'^accounts/logout/$', 'user_logout', name='user_logout'), + url(r'^accounts/logout/$', logout_view, name='user_logout'), url(r'^accounts/profile/$', 'user_profile', name='user_profile'), url(r'^tasks/$', 'user_tasks', name='user_tasks'), url(r'^accounts/subscriptions/$', UserSubscriptionsView.as_view(), diff --git a/src/postorius/views/user.py b/src/postorius/views/user.py index dffd02b..a16767e 100644 --- a/src/postorius/views/user.py +++ b/src/postorius/views/user.py @@ -302,15 +302,8 @@ context_instance=RequestContext(request)) -def user_logout(request): - logout(request) - return redirect('user_login') - - @login_required() def user_profile(request, user_email=None): - if not request.user.is_authenticated(): - return redirect('user_login') # try: # the_user = User.objects.get(email=user_email) # except MailmanApiError: