Browse Source

check that PMF is currently bound to a model instance before trying to access it

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

8
pyweb/mumble/forms.py

@ -33,10 +33,12 @@ class PropertyModelForm( ModelForm ):
def __init__( self, *args, **kwargs ): def __init__( self, *args, **kwargs ):
ModelForm.__init__( self, *args, **kwargs ); ModelForm.__init__( self, *args, **kwargs );
instfields = self.instance._meta.get_all_field_names()
if self.instance:
instfields = self.instance._meta.get_all_field_names()
for fldname in self.fields: for fldname in self.fields:
if fldname not in instfields:
if fldname in instfields:
continue
self.fields[fldname].initial = getattr( self.instance, fldname ) self.fields[fldname].initial = getattr( self.instance, fldname )
docstr = getattr( self.instance.__class__, fldname ).__doc__ docstr = getattr( self.instance.__class__, fldname ).__doc__
if docstr: if docstr:
@ -294,7 +296,7 @@ class MumbleUserLinkForm( MumbleUserForm ):
class MumbleUserAdminForm( PropertyModelForm ): class MumbleUserAdminForm( PropertyModelForm ):
aclAdmin = forms.BooleanField( label=_('Admin on root channel'), required=False );
aclAdmin = forms.BooleanField( required=False );
class Meta: class Meta:
model = Mumble; model = Mumble;

Loading…
Cancel
Save