Browse Source

add a setting to hide offline servers from the servers list. fixes #144

Natenom/support-murmur-13-1446181288462
Michael Ziegler 14 years ago
parent
commit
288643fe4e
  1. 4
      pyweb/mumble/views.py
  2. 2
      pyweb/settings.py

4
pyweb/mumble/views.py

@ -81,6 +81,8 @@ def mobile_mumbles( request ):
def mumbles( request, mobile=False ): def mumbles( request, mobile=False ):
""" Display a list of all configured Mumble servers, or redirect if only one configured. """ """ Display a list of all configured Mumble servers, or redirect if only one configured. """
mms = Mumble.objects.all().order_by( "name" ) mms = Mumble.objects.all().order_by( "name" )
if settings.HIDE_OFFLINE_SERVERS:
mms = filter(lambda srv: srv.booted, mms)
if len(mms) == 1: if len(mms) == 1:
return HttpResponseRedirect( reverse( return HttpResponseRedirect( reverse(
@ -99,6 +101,8 @@ def mumbles( request, mobile=False ):
@EXT_DIRECT_PROVIDER.register_method( "MumbleList" ) @EXT_DIRECT_PROVIDER.register_method( "MumbleList" )
def servers( request ): def servers( request ):
mms = Mumble.objects.all().order_by( "name" ) 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] return [{ 'id': mm.id, 'name': mm.name, 'booted': mm.booted } for mm in mms]
@EXT_DIRECT_PROVIDER.register_method( "MumbleList" ) @EXT_DIRECT_PROVIDER.register_method( "MumbleList" )

2
pyweb/settings.py

@ -134,6 +134,8 @@ MUNIN_TITLE = 'Mumble Users'
# see <http://munin.projects.linpro.no/wiki/graph_category_list> for a list of valid categories. # see <http://munin.projects.linpro.no/wiki/graph_category_list> for a list of valid categories.
MUNIN_CATEGORY = 'mumble' MUNIN_CATEGORY = 'mumble'
# Set to True if you do not wish offline servers to appear in the server list.
HIDE_OFFLINE_SERVERS=False
################################################################### ###################################################################
## ## ## ##

Loading…
Cancel
Save