From 72df6d5cc858595e340b2a1c45a327d758b4ba8b Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Mon, 25 May 2009 19:16:04 +0200 Subject: [PATCH] /mumble now redirects to /mumble/x if only one server has been configured --- pyweb/mumble/views.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index c61d195..67efbd5 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -34,10 +34,15 @@ class Storage( object ): def mumbles( request ): - "Displays a list of all configured Mumble servers." + "Displays a list of all configured Mumble servers, or redirects if only one configured." + mumbles = get_list_or_404( Mumble ); + + if len(mumbles) == 1: + return HttpResponseRedirect( '/mumble/%d' % mumbles[0].id ); + return render_to_response( 'mumble/list.htm', - { 'MumbleObjects': get_list_or_404( Mumble ), + { 'MumbleObjects': mumbles, 'MumbleActive': True, }, context_instance = RequestContext(request)