From 90a2131b6d06d7b3e6c965feb2d276aed68b86e9 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Tue, 11 Jan 2011 00:56:13 +0000 Subject: [PATCH] superuser tweaks. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1187 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/syrup/urls.py | 2 +- conifer/syrup/views/admin.py | 22 +++++++++++++--------- conifer/templates/admin/su.xhtml | 22 ++++++++++++++++++++++ 3 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 conifer/templates/admin/su.xhtml diff --git a/conifer/syrup/urls.py b/conifer/syrup/urls.py index 511935b..ba4965a 100644 --- a/conifer/syrup/urls.py +++ b/conifer/syrup/urls.py @@ -54,7 +54,7 @@ urlpatterns = patterns('conifer.syrup.views', (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.*)', 'admin_su'), + (r'^admin/su/', 'admin_su'), # (r'^phys/$', 'phys_index'), diff --git a/conifer/syrup/views/admin.py b/conifer/syrup/views/admin.py index 432e780..17a83e0 100644 --- a/conifer/syrup/views/admin.py +++ b/conifer/syrup/views/admin.py @@ -177,13 +177,17 @@ def admin_staff_add(request): 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('../../') diff --git a/conifer/templates/admin/su.xhtml b/conifer/templates/admin/su.xhtml new file mode 100644 index 0000000..87421ea --- /dev/null +++ b/conifer/templates/admin/su.xhtml @@ -0,0 +1,22 @@ + + + + + ${title} + + + +

${title}

+
+

UWin ID to impersonate:

+

+

+
+ + -- 2.11.0