From 15180b5e5e9958e68da11d3b340afbeb65d2022b Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Fri, 30 Jul 2010 00:30:25 +0200 Subject: [PATCH] prevent exception when user isn't logged in --- pyweb/mumble/views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index 5ae3005..66f5585 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -107,9 +107,12 @@ def show( request, server ): }, context_instance = RequestContext(request) ) isAdmin = srv.isUserAdmin( request.user ) - try: - user = MumbleUser.objects.get( server=srv, owner=request.user ) - except MumbleUser.DoesNotExist: + if request.user.is_authenticated(): + try: + user = MumbleUser.objects.get( server=srv, owner=request.user ) + except MumbleUser.DoesNotExist: + user = None + else: user = None from mumble.forms import EXT_FORMS_PROVIDER, MumbleUserPasswordForm, MumbleUserLinkForm, MumbleUserForm @@ -133,6 +136,7 @@ def show( request, server ): 'RegForm': regformname, 'MumbleActive': True, 'MumbleAccount':user, + 'IsAdmin': isAdmin, }, context_instance = RequestContext(request) ) def mobile_show( request, server ):