Browse Source

pre-validate requests using EXT_validate

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
57828bc021
  1. 16
      pyweb/mumble/forms.py

16
pyweb/mumble/forms.py

@ -119,6 +119,10 @@ class MumbleForm( PropertyModelForm ):
model = Mumble
fields = ['name']
def EXT_validate( self, request ):
if not self.instance.isUserAdmin( request.user ):
return False
return True
class MumbleAdminForm( MumbleForm ):
""" A Mumble Server admin form intended to be used by the server hoster. """
@ -153,13 +157,13 @@ class MumbleAdminForm( MumbleForm ):
return None
@EXT_FORMS_PROVIDER.register_form
class MumbleServerForm( ModelForm ):
defaultconf = forms.CharField( label=_("Default config"), required=False, widget=forms.Textarea )
def __init__( self, *args, **kwargs ):
ModelForm.__init__( self, *args, **kwargs )
# self.instance = instance of MumbleServer, NOT a server instance
if self.instance and self.instance.id:
if self.instance.online:
confstr = ""
@ -183,6 +187,16 @@ class MumbleUserForm( ModelForm ):
ModelForm.__init__( self, *args, **kwargs )
self.server = None
def EXT_validate( self, request ):
if "serverid" in request.POST:
try:
self.server = Mumble.objects.get( id=int(request.POST['serverid']) )
except Mumble.DoesNotExist:
return False
else:
return True
return False
def clean_name( self ):
""" Check if the desired name is forbidden or taken. """

Loading…
Cancel
Save