Browse Source

implement save method with respect to linking, see #56

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
c03b775478
  1. 15
      pyweb/mumble/forms.py
  2. 4
      pyweb/mumble/views.py

15
pyweb/mumble/forms.py

@ -125,6 +125,21 @@ class MumbleUserLinkForm( MumbleUserForm ):
return pw; return pw;
def save( self, *args, **kwargs ):
if not self.cleaned_data['linkacc']:
inst = MumbleUserForm.save( self, *args, **kwargs );
inst.isAdmin = False;
inst.server = this.server;
return inst;
mUser = MumbleUser.objects.get( server=self.server, mumbleid=self.mumbleid );
if mUser.getAdmin() and not settings.ALLOW_ACCOUNT_LINKING_ADMINS:
raise SystemError( "Linking Admin accounts is not allowed." );
self.instance = mUser;
return MumbleUserForm.save( self, *args, **kwargs );
class MumbleTextureForm( Form ): class MumbleTextureForm( Form ):
""" The form used to upload a new image to be set as texture. """ """ The form used to upload a new image to be set as texture. """

4
pyweb/mumble/views.py

@ -90,7 +90,7 @@ def show( request, server ):
unregged_user_form = MumbleUserPasswordForm; unregged_user_form = MumbleUserPasswordForm;
# Unregistered users may or may not want to link an existing account # Unregistered users may or may not want to link an existing account
elif settings.ALLOW_ACCOUNT_LINKING: elif settings.ALLOW_ACCOUNT_LINKING:
unregged_user_form = MumbleLinkForm;
unregged_user_form = MumbleUserLinkForm;
else: else:
unregged_user_form = MumbleUserForm; unregged_user_form = MumbleUserForm;
@ -107,8 +107,6 @@ def show( request, server ):
# find MumbleUser with mumbleid=regform.mumbleid, # find MumbleUser with mumbleid=regform.mumbleid,
# if not exists create, save(). # if not exists create, save().
model = regform.save( commit=False ); model = regform.save( commit=False );
model.isAdmin = False;
model.server = srv;
model.owner = request.user; model.owner = request.user;
model.save(); model.save();
return HttpResponseRedirect( reverse( show, kwargs={ 'server': int(server), } ) ); return HttpResponseRedirect( reverse( show, kwargs={ 'server': int(server), } ) );

Loading…
Cancel
Save