[open-ils-commits] r1187 - in servres/trunk/conifer: syrup syrup/views templates/admin (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Jan 10 19:56:14 EST 2011
Author: gfawcett
Date: 2011-01-10 19:56:13 -0500 (Mon, 10 Jan 2011)
New Revision: 1187
Added:
servres/trunk/conifer/templates/admin/su.xhtml
Modified:
servres/trunk/conifer/syrup/urls.py
servres/trunk/conifer/syrup/views/admin.py
Log:
superuser tweaks.
Modified: servres/trunk/conifer/syrup/urls.py
===================================================================
--- servres/trunk/conifer/syrup/urls.py 2011-01-11 00:47:41 UTC (rev 1186)
+++ servres/trunk/conifer/syrup/urls.py 2011-01-11 00:56:13 UTC (rev 1187)
@@ -54,7 +54,7 @@
(r'^admin/update_depts_courses/$', 'admin_update_depts_courses'),
(r'^admin/update_terms/$', 'admin_update_terms'),
(r'^admin/staff/add/$', 'admin_staff_add'),
- (r'^admin/su/(?P<userid>.*)', 'admin_su'),
+ (r'^admin/su/', 'admin_su'),
# (r'^phys/$', 'phys_index'),
Modified: servres/trunk/conifer/syrup/views/admin.py
===================================================================
--- servres/trunk/conifer/syrup/views/admin.py 2011-01-11 00:47:41 UTC (rev 1186)
+++ servres/trunk/conifer/syrup/views/admin.py 2011-01-11 00:56:13 UTC (rev 1187)
@@ -177,13 +177,17 @@
return g.render('admin/staff_add.xhtml', **locals())
@admin_only
-def admin_su(request, userid):
- user, created = User.objects.get_or_create(username=userid)
- user.maybe_decorate()
- if created and not user.last_name:
- raise Exception(user)
- user.delete()
- elif user.is_active:
- request.session['_auth_user_id'] = user.id
- return HttpResponseRedirect('../../')
+def admin_su(request):
+ if request.method != 'POST':
+ return g.render('admin/su.xhtml')
+ else:
+ userid = request.POST['userid'].lower().strip()
+ user, created = User.objects.get_or_create(username=userid)
+ user.maybe_decorate()
+ if created and not user.last_name:
+ user.delete()
+ return g.render('admin/su.xhtml')
+ elif user.is_active:
+ request.session['_auth_user_id'] = user.id
+ return HttpResponseRedirect('../../')
Added: servres/trunk/conifer/templates/admin/su.xhtml
===================================================================
--- servres/trunk/conifer/templates/admin/su.xhtml (rev 0)
+++ servres/trunk/conifer/templates/admin/su.xhtml 2011-01-11 00:56:13 UTC (rev 1187)
@@ -0,0 +1,22 @@
+<?python
+title = _('Impersonate another user')
+?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:py="http://genshi.edgewall.org/">
+<xi:include href="../master.xhtml"/>
+<head>
+ <title>${title}</title>
+ <style type="text/css">
+ ul { margin-bottom: 2em; }
+ </style>
+</head>
+<body>
+ <h1>${title}</h1>
+ <form action="." method="POST">
+ <p>UWin ID to impersonate:</p>
+ <p><input type="text" name="userid"/></p>
+ <p><input type="submit" value="Impersonate"/></p>
+ </form>
+</body>
+</html>
More information about the open-ils-commits
mailing list