From 40ae2e5999cea7e7e1566e3a412effaaef346627 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Mon, 25 Jan 2010 13:46:20 +0100 Subject: [PATCH] merge the "mumbles" and "mobile_mumbles" views, as they practically do the same thing --- pyweb/mumble/views.py | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index 00f553a..5e4ff15 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -58,31 +58,22 @@ def redir( request ): else: return HttpResponseRedirect( reverse( mumbles ) ); -def mumbles( request ): - """ Display a list of all configured Mumble servers, or redirect if only one configured. """ - mumbles = get_list_or_404( Mumble ); - - if len(mumbles) == 1: - return HttpResponseRedirect( reverse( show, kwargs={ 'server': mumbles[0].id, } ) ); - - return render_to_response( - 'mumble/list.html', - { 'MumbleObjects': mumbles, - 'MumbleActive': True, - }, - context_instance = RequestContext(request) - ); - def mobile_mumbles( request ): + return mumbles( request, mobile=True ); + +def mumbles( request, mobile=False ): """ Display a list of all configured Mumble servers, or redirect if only one configured. """ - mumbles = get_list_or_404( Mumble ); + mms = get_list_or_404( Mumble ); - if len(mumbles) == 1: - return HttpResponseRedirect( reverse( mobile_show, kwargs={ 'server': mumbles[0].id, } ) ); + if len(mms) == 1: + return HttpResponseRedirect( reverse( + { False: show, True: mobile_show }[mobile], + kwargs={ 'server': mms[0].id, } + ) ); return render_to_response( - 'mumble/mobile_list.html', - { 'MumbleObjects': mumbles, + 'mumble/%s.html' % { False: 'list', True: 'mobile_list' }[mobile], + { 'MumbleObjects': mms, 'MumbleActive': True, }, context_instance = RequestContext(request)