From d50460da5be3db56f03b7af320f57c7030a223e4 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Fri, 23 Jul 2010 13:39:14 +0200 Subject: [PATCH] reindent mumble.html; implement avatar updating --- pyweb/mumble/templates/mumble/mumble.html | 165 +++++++++++----------- pyweb/mumble/urls.py | 1 + pyweb/mumble/views.py | 20 +++ 3 files changed, 106 insertions(+), 80 deletions(-) diff --git a/pyweb/mumble/templates/mumble/mumble.html b/pyweb/mumble/templates/mumble/mumble.html index 44ce1af..6a1d039 100644 --- a/pyweb/mumble/templates/mumble/mumble.html +++ b/pyweb/mumble/templates/mumble/mumble.html @@ -1,91 +1,96 @@ {% extends "index.html" %} {% comment %} - + {% endcomment %} {% load mumble_extras %} {% load i18n %} {% block Headline %} - {{ MumbleServer.name }} + {{ MumbleServer.name }} {% endblock %} {% block ContentMaster %} -
+
{% endblock %} {% block HeadTag %} - - - - - - - - - + + + + + + + + {% endblock %} diff --git a/pyweb/mumble/urls.py b/pyweb/mumble/urls.py index e8af967..7093d09 100644 --- a/pyweb/mumble/urls.py +++ b/pyweb/mumble/urls.py @@ -28,6 +28,7 @@ urlpatterns = patterns( ( r'forms/', include(EXT_FORMS_PROVIDER.urls) ), ( r'(?P\d+)/(?P\d+)/texture.png', 'showTexture' ), + ( r'(?P\d+)/update_avatar', 'update_avatar' ), ( r'murmur/tree/(?P\d+)', 'mmng_tree' ), ( r'mumbleviewer/(?P\d+).xml', 'mumbleviewer_tree_xml' ), diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index 80f5370..26f9ff3 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -27,6 +27,7 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from django.contrib.auth import views as auth_views from django.core.urlresolvers import reverse +from django.views.decorators.csrf import csrf_exempt from models import Mumble, MumbleUser from forms import MumbleForm, MumbleUserForm, MumbleUserPasswordForm @@ -230,6 +231,25 @@ def djangousers( request ): return users +@login_required +@csrf_exempt +def update_avatar( request, userid ): + try: + user = MumbleUser.objects.get( id=userid ) + except MumbleUser.DoesNotExist: + return HttpResponse( "false", mimetype="text/html" ) + + textureform = MumbleTextureForm( request.POST, request.FILES ) + if textureform.is_valid(): + if 'usegravatar' in textureform.cleaned_data and user.gravatar: + user.setTextureFromUrl( user.gravatar ) + elif 'texturefile' in request.FILES: + user.setTexture( Image.open( request.FILES['texturefile'] ) ) + return HttpResponse( "true", mimetype="text/html" ) + + return HttpResponse( "false", mimetype="text/html" ) + + def mmng_tree( request, server ): """ Return a JSON representation of the channel tree suitable for Murmur Manager: