From fe7f32103a72ddffb40cbb943591a5ac58299f22 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Sat, 20 Feb 2010 15:54:15 +0100 Subject: [PATCH] add properties for new Murmur configuration fields --- pyweb/mumble/forms.py | 10 ++++++---- pyweb/mumble/models.py | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pyweb/mumble/forms.py b/pyweb/mumble/forms.py index b12ba67..48759b2 100644 --- a/pyweb/mumble/forms.py +++ b/pyweb/mumble/forms.py @@ -86,9 +86,11 @@ class MumbleForm( PropertyModelForm ): "If on, IP adresses of the clients are not logged.") ) player = forms.CharField( required=False ) channel = forms.CharField( required=False ) - defchan = forms.TypedChoiceField( choices=(), coerce=int, required=False, help_text=_( - "Enter the ID of the default channel here. The Channel viewer displays the ID to " - "server admins on the channel detail page.") ) + defchan = forms.TypedChoiceField( choices=(), coerce=int, required=False ) + timeout = forms.IntegerField( required=False ) + certreq = forms.BooleanField( required=False ) + textlen = forms.IntegerField( required=False ) + html = forms.BooleanField( required=False ) def __init__( self, *args, **kwargs ): PropertyModelForm.__init__( self, *args, **kwargs ) @@ -118,7 +120,7 @@ class MumbleAdminForm( MumbleForm ): sslcrt = forms.CharField( required=False, widget=forms.Textarea ) sslkey = forms.CharField( required=False, widget=forms.Textarea ) booted = forms.BooleanField( required=False ) - + bonjour = forms.BooleanField( required=False ) class Meta: fields = None diff --git a/pyweb/mumble/models.py b/pyweb/mumble/models.py index 3c5b586..6432d4e 100644 --- a/pyweb/mumble/models.py +++ b/pyweb/mumble/models.py @@ -49,6 +49,12 @@ def mk_config_property( field, doc="", get_coerce=None, get_none=None, set_coerc return property( get_field, set_field, doc=doc ) +def mk_config_bool_property( field, doc="" ): + return mk_config_property( field, doc=doc, + get_coerce = lambda value: value == "true", + set_coerce = lambda value: str(value).lower() + ); + class MumbleServer( models.Model ): """ Represents a Murmur server installation. """ @@ -124,12 +130,13 @@ class Mumble( models.Model ): player = mk_config_property( "username", "Player name regex" ) channel = mk_config_property( "channelname", "Channel name regex" ) defchan = mk_config_property( "defaultchannel", "Default channel", get_coerce=int ) + timeout = mk_config_property( "timeout", "Timeout", get_coerce=int ) - obfsc = property( - lambda self: ( self.getConf( "obfuscate" ) == "true" ) if self.id is not None else None, - lambda self, value: self.setConf( "obfuscate", str(value).lower() ), - doc="IP Obfuscation" - ) + obfsc = mk_config_bool_property( "obfuscate", "IP Obfuscation" ) + certreq = mk_config_bool_property( "certrequired", "Require Certificate" ) + textlen = mk_config_bool_property( "textmessagelength", "Maximum length of text messages" ) + html = mk_config_bool_property( "allowhtml", "Allow HTML to be used in messages" ) + bonjour = mk_config_bool_property( "bonjour", "Publish this server via Bonjour" ) def getBooted( self ): if self.id is not None: