Assigning users to submissions
[edumed.git] / forum / middleware.py
1 from urllib import urlencode
2
3 from django.contrib.auth import REDIRECT_FIELD_NAME
4 from django.http import HttpResponseRedirect
5 from django.core.urlresolvers import reverse
6 from django_cas.views import login as cas_login
7
8
9 class ForumMiddleware:
10     def process_request(self, request):
11         if request.path.startswith(reverse('pybb:index')) \
12             and (not hasattr(request, 'user') or not request.user.is_authenticated()):
13             params = urlencode({REDIRECT_FIELD_NAME: request.get_full_path()})
14             return HttpResponseRedirect(reverse(cas_login) + '?' + params)