From 54856fa7f178c603668cfa7fd3fa758a268f37a6 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Mon, 8 Mar 2010 16:18:37 +0100 Subject: [PATCH] fix banning and prevent unwanted erasing of the supw and defaultchannel fields, various minor cleanups. --- pyweb/mumble/MumbleCtlIce.py | 5 +++++ pyweb/mumble/forms.py | 18 +++++++++++------- pyweb/mumble/models.py | 2 +- pyweb/mumble/templatetags/mumble_extras.py | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pyweb/mumble/MumbleCtlIce.py b/pyweb/mumble/MumbleCtlIce.py index 920417b..aeb9676 100644 --- a/pyweb/mumble/MumbleCtlIce.py +++ b/pyweb/mumble/MumbleCtlIce.py @@ -15,6 +15,7 @@ * GNU General Public License for more details. """ +from time import time from functools import wraps from StringIO import StringIO from os.path import exists, join @@ -527,6 +528,10 @@ class MumbleCtlIce_120(MumbleCtlIce_118): session = self.getState(srvid, sessionid); if "bits" not in kwargs: kwargs["bits"] = 128; + if "start" not in kwargs: + kwargs["start"] = int(time()); + if "duration" not in kwargs: + kwargs["duration"] = 3600; return self.addBan(srvid, address=session.address, **kwargs); @protectDjangoErrPage diff --git a/pyweb/mumble/forms.py b/pyweb/mumble/forms.py index 17127a3..aad84d8 100644 --- a/pyweb/mumble/forms.py +++ b/pyweb/mumble/forms.py @@ -98,13 +98,17 @@ class MumbleForm( PropertyModelForm ): # Populate the `default channel' field's choices choices = [ ('', '----------') ] - if self.instance and self.instance.srvid is not None and self.instance.booted: - def add_item( item, level ): - if item.is_server or item.is_channel: - choices.append( ( str(item.chanid), ( "-"*level + " " + item.name ) ) ) - - self.instance.rootchan.visit(add_item) - + if self.instance and self.instance.srvid is not None: + if self.instance.booted: + def add_item( item, level ): + if item.is_server or item.is_channel: + choices.append( ( item.chanid, ( "-"*level + " " + item.name ) ) ) + + self.instance.rootchan.visit(add_item) + else: + current = self.instance.defchan + if current is not None: + choices.append( ( current, "Current value: %d" % current ) ) self.fields['defchan'].choices = choices class Meta: diff --git a/pyweb/mumble/models.py b/pyweb/mumble/models.py index 52666a5..4920cd7 100644 --- a/pyweb/mumble/models.py +++ b/pyweb/mumble/models.py @@ -139,7 +139,7 @@ class Mumble( models.Model ): "and port fields are used. If display and bind ports are equal, you can omit it here.") ); supw = property( lambda self: '', - lambda self, value: self.ctl.setSuperUserPassword( self.srvid, value ), + lambda self, value: ( value and self.ctl.setSuperUserPassword( self.srvid, value ) ) or None, doc=_('Superuser Password') ) diff --git a/pyweb/mumble/templatetags/mumble_extras.py b/pyweb/mumble/templatetags/mumble_extras.py index b4fe7b9..2398aba 100644 --- a/pyweb/mumble/templatetags/mumble_extras.py +++ b/pyweb/mumble/templatetags/mumble_extras.py @@ -27,7 +27,7 @@ def trunc( string, maxlen = 50 ): """ converts "a very very extaordinary long text" to "a very very extra... """ if len(string) < maxlen: return string; - return string[:(maxlen - 3)] + "..."; + return string[:(maxlen - 3)] + "…"; @register.filter