[open-ils-commits] r254 - servres/trunk/conifer/syrup (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Apr 3 19:44:29 EDT 2009
Author: gfawcett
Date: 2009-04-03 19:44:28 -0400 (Fri, 03 Apr 2009)
New Revision: 254
Modified:
servres/trunk/conifer/syrup/views.py
Log:
on visit to restricted URL, show login form and redirect to destination afterward.
Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py 2009-04-03 23:30:33 UTC (rev 253)
+++ servres/trunk/conifer/syrup/views.py 2009-04-03 23:44:28 UTC (rev 254)
@@ -129,11 +129,16 @@
allowed = bool(res[0][0])
return allowed
-def _access_denied(message):
- return g.render('simplemessage.xhtml',
- title=_(_('Access denied.')),
- content=message,
- _django_type=HttpResponseForbidden)
+def _access_denied(request, message):
+ if request.user.is_anonymous():
+ # then take them to login screen....
+ dest = '/accounts/login/?next=' + request.environ['PATH_INFO']
+ return HttpResponseRedirect(dest)
+ else:
+ return g.render('simplemessage.xhtml',
+ title=_(_('Access denied.')),
+ content=message,
+ _django_type=HttpResponseForbidden)
# todo, these decorators could be refactored.
@@ -147,7 +152,7 @@
if allowed:
return handler(request, course_id, *args, **kwargs)
else:
- return _access_denied(_('Only instructors are allowed here.'))
+ return _access_denied(request, _('Only instructors are allowed here.'))
return hdlr
# decorator
@@ -168,7 +173,7 @@
msg = _('Please log in, so that you can enter this site.')
else:
msg = _('Only course members are allowed here.')
- return _access_denied(msg)
+ return _access_denied(request, msg)
return hdlr
# decorator
@@ -180,7 +185,7 @@
if allowed:
return handler(request, *args, **kwargs)
else:
- return _access_denied(_('Only administrators are allowed here.'))
+ return _access_denied(request, _('Only administrators are allowed here.'))
return hdlr
#decorator
More information about the open-ils-commits
mailing list