diff --git a/pyweb/mumble/forms.py b/pyweb/mumble/forms.py index fda158c..86583a1 100644 --- a/pyweb/mumble/forms.py +++ b/pyweb/mumble/forms.py @@ -125,6 +125,21 @@ class MumbleUserLinkForm( MumbleUserForm ): 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 ): """ The form used to upload a new image to be set as texture. """ diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index c047fab..570714f 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -90,7 +90,7 @@ def show( request, server ): unregged_user_form = MumbleUserPasswordForm; # Unregistered users may or may not want to link an existing account elif settings.ALLOW_ACCOUNT_LINKING: - unregged_user_form = MumbleLinkForm; + unregged_user_form = MumbleUserLinkForm; else: unregged_user_form = MumbleUserForm; @@ -107,8 +107,6 @@ def show( request, server ): # find MumbleUser with mumbleid=regform.mumbleid, # if not exists create, save(). model = regform.save( commit=False ); - model.isAdmin = False; - model.server = srv; model.owner = request.user; model.save(); return HttpResponseRedirect( reverse( show, kwargs={ 'server': int(server), } ) );