|
@ -21,6 +21,7 @@ from django.template import RequestContext |
|
|
from django.http import Http404, HttpResponse, HttpResponseRedirect |
|
|
from django.http import Http404, HttpResponse, HttpResponseRedirect |
|
|
from django.core.urlresolvers import reverse |
|
|
from django.core.urlresolvers import reverse |
|
|
from django.contrib.auth.decorators import login_required |
|
|
from django.contrib.auth.decorators import login_required |
|
|
|
|
|
from django.conf import settings |
|
|
|
|
|
|
|
|
from models import Mumble, MumbleUser |
|
|
from models import Mumble, MumbleUser |
|
|
from forms import * |
|
|
from forms import * |
|
@ -61,12 +62,11 @@ def show( request, server ): |
|
|
if isAdmin: |
|
|
if isAdmin: |
|
|
if request.method == 'POST' and "mode" in request.POST and request.POST['mode'] == 'admin': |
|
|
if request.method == 'POST' and "mode" in request.POST and request.POST['mode'] == 'admin': |
|
|
adminform = MumbleForm( request.POST, instance=srv ); |
|
|
adminform = MumbleForm( request.POST, instance=srv ); |
|
|
# In case we redisplay the page, it was displayed with errors on the admin form, so tell |
|
|
|
|
|
# Ext to show the admin form tab first. |
|
|
|
|
|
displayTab = 1; |
|
|
|
|
|
if adminform.is_valid(): |
|
|
if adminform.is_valid(): |
|
|
adminform.save(); |
|
|
adminform.save(); |
|
|
return HttpResponseRedirect( '/mumble/%d' % int(server) ); |
|
|
return HttpResponseRedirect( '/mumble/%d' % int(server) ); |
|
|
|
|
|
else: |
|
|
|
|
|
displayTab = 2; |
|
|
else: |
|
|
else: |
|
|
adminform = MumbleForm( instance=srv ); |
|
|
adminform = MumbleForm( instance=srv ); |
|
|
else: |
|
|
else: |
|
@ -76,11 +76,18 @@ def show( request, server ): |
|
|
user = None; |
|
|
user = None; |
|
|
|
|
|
|
|
|
if request.user.is_authenticated(): |
|
|
if request.user.is_authenticated(): |
|
|
|
|
|
# Unregistered users may or may not need a password to register. |
|
|
|
|
|
if settings.PROTECTED_MODE and srv.passwd: |
|
|
|
|
|
unregged_user_form = MumbleUserPasswordForm; |
|
|
|
|
|
else: |
|
|
|
|
|
unregged_user_form = MumbleUserForm; |
|
|
|
|
|
|
|
|
if request.method == 'POST' and 'mode' in request.POST and request.POST['mode'] == 'reg': |
|
|
if request.method == 'POST' and 'mode' in request.POST and request.POST['mode'] == 'reg': |
|
|
try: |
|
|
try: |
|
|
user = MumbleUser.objects.get( server=srv, owner=request.user ); |
|
|
user = MumbleUser.objects.get( server=srv, owner=request.user ); |
|
|
except MumbleUser.DoesNotExist: |
|
|
except MumbleUser.DoesNotExist: |
|
|
regform = MumbleUserForm( request.POST ); |
|
|
|
|
|
|
|
|
regform = unregged_user_form( request.POST ); |
|
|
|
|
|
regform.server = srv; |
|
|
if regform.is_valid(): |
|
|
if regform.is_valid(): |
|
|
model = regform.save( commit=False ); |
|
|
model = regform.save( commit=False ); |
|
|
model.isAdmin = False; |
|
|
model.isAdmin = False; |
|
@ -88,16 +95,20 @@ def show( request, server ): |
|
|
model.owner = request.user; |
|
|
model.owner = request.user; |
|
|
model.save(); |
|
|
model.save(); |
|
|
return HttpResponseRedirect( '/mumble/%d' % int(server) ); |
|
|
return HttpResponseRedirect( '/mumble/%d' % int(server) ); |
|
|
|
|
|
else: |
|
|
|
|
|
displayTab = 1; |
|
|
else: |
|
|
else: |
|
|
regform = MumbleUserForm( request.POST, instance=user ); |
|
|
regform = MumbleUserForm( request.POST, instance=user ); |
|
|
if regform.is_valid(): |
|
|
if regform.is_valid(): |
|
|
regform.save(); |
|
|
regform.save(); |
|
|
return HttpResponseRedirect( '/mumble/%d' % int(server) ); |
|
|
return HttpResponseRedirect( '/mumble/%d' % int(server) ); |
|
|
|
|
|
else: |
|
|
|
|
|
displayTab = 1; |
|
|
else: |
|
|
else: |
|
|
try: |
|
|
try: |
|
|
user = MumbleUser.objects.get( server=srv, owner=request.user ); |
|
|
user = MumbleUser.objects.get( server=srv, owner=request.user ); |
|
|
except MumbleUser.DoesNotExist: |
|
|
except MumbleUser.DoesNotExist: |
|
|
regform = MumbleUserForm(); |
|
|
|
|
|
|
|
|
regform = unregged_user_form(); |
|
|
else: |
|
|
else: |
|
|
regform = MumbleUserForm( instance=user ); |
|
|
regform = MumbleUserForm( instance=user ); |
|
|
registered = True; |
|
|
registered = True; |
|
|