From 288643fe4ef426fff305eae441ca9af607dbf425 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Sat, 4 Jun 2011 14:28:14 +0200 Subject: [PATCH] add a setting to hide offline servers from the servers list. fixes #144 --- pyweb/mumble/views.py | 4 ++++ pyweb/settings.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index a9e7cc0..114a9ea 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -81,6 +81,8 @@ def mobile_mumbles( request ): def mumbles( request, mobile=False ): """ Display a list of all configured Mumble servers, or redirect if only one configured. """ mms = Mumble.objects.all().order_by( "name" ) + if settings.HIDE_OFFLINE_SERVERS: + mms = filter(lambda srv: srv.booted, mms) if len(mms) == 1: return HttpResponseRedirect( reverse( @@ -99,6 +101,8 @@ def mumbles( request, mobile=False ): @EXT_DIRECT_PROVIDER.register_method( "MumbleList" ) def servers( request ): mms = Mumble.objects.all().order_by( "name" ) + if settings.HIDE_OFFLINE_SERVERS: + mms = filter(lambda srv: srv.booted, mms) return [{ 'id': mm.id, 'name': mm.name, 'booted': mm.booted } for mm in mms] @EXT_DIRECT_PROVIDER.register_method( "MumbleList" ) diff --git a/pyweb/settings.py b/pyweb/settings.py index 28407a9..5d99e73 100644 --- a/pyweb/settings.py +++ b/pyweb/settings.py @@ -134,6 +134,8 @@ MUNIN_TITLE = 'Mumble Users' # see for a list of valid categories. MUNIN_CATEGORY = 'mumble' +# Set to True if you do not wish offline servers to appear in the server list. +HIDE_OFFLINE_SERVERS=False ################################################################### ## ##