From 24a60fe541e943c25a678e241e3342ea7b3cdc4c Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Wed, 31 Mar 2010 20:14:42 +0200 Subject: [PATCH] add setting your own texture to your gravatar --- pyweb/mumble/forms.py | 3 ++- pyweb/mumble/templates/mumble/mumble.html | 6 ++++++ pyweb/mumble/views.py | 20 +++++++++++++------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/pyweb/mumble/forms.py b/pyweb/mumble/forms.py index 96ab27d..3de2386 100644 --- a/pyweb/mumble/forms.py +++ b/pyweb/mumble/forms.py @@ -319,6 +319,7 @@ class MumbleKickForm( Form ): class MumbleTextureForm( Form ): """ The form used to upload a new image to be set as texture. """ - texturefile = forms.ImageField( label=_("User Texture") ); + usegravatar = forms.BooleanField( required=False, label=_("Use my Gravatar as my Texture") ); + texturefile = forms.ImageField( required=False, label=_("User Texture") ); diff --git a/pyweb/mumble/templates/mumble/mumble.html b/pyweb/mumble/templates/mumble/mumble.html index 44af18c..20db2b3 100644 --- a/pyweb/mumble/templates/mumble/mumble.html +++ b/pyweb/mumble/templates/mumble/mumble.html @@ -73,6 +73,12 @@ You can upload an image that you would like to use as your user texture here. {% endblocktrans %}

+
+ {% if MumbleAccount.gravatar %} + Gravatar: + your gravatar + {% endif %} +
{% if MumbleAccount.hasTexture %} {% trans "Your current texture is" %}:
user texture
diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index 3574860..05f2f32 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -15,6 +15,7 @@ """ import simplejson +from urllib import urlopen from StringIO import StringIO from PIL import Image @@ -165,7 +166,11 @@ def show( request, server ): if request.method == 'POST' and 'mode' in request.POST and request.POST['mode'] == 'texture' and registered: textureform = MumbleTextureForm( request.POST, request.FILES ); if textureform.is_valid(): - user.setTexture( Image.open( request.FILES['texturefile'] ) ); + if 'usegravatar' in textureform.cleaned_data and textureform.cleaned_data['usegravatar'] and user.gravatar: + gravatar = urlopen( user.gravatar256 ); + user.setTexture( Image.open( gravatar ) ); + elif 'texturefile' in request.FILES: + user.setTexture( Image.open( request.FILES['texturefile'] ) ); return HttpResponseRedirect( reverse( show, kwargs={ 'server': int(server), } ) ); else: textureform = MumbleTextureForm(); @@ -175,12 +180,13 @@ def show( request, server ): textureform = None; if isAdmin: - if request.method == 'POST' and 'mode' in request.POST and request.POST['mode'] == 'kick': - kickform = MumbleKickForm( request.POST ); - if kickform.is_valid(): - if kickform.cleaned_data["ban"]: - srv.banUser( kickform.cleaned_data['session'], kickform.cleaned_data['reason'] ); - srv.kickUser( kickform.cleaned_data['session'], kickform.cleaned_data['reason'] ); + if request.method == 'POST' and 'mode' in request.POST: + if request.POST['mode'] == 'kick': + kickform = MumbleKickForm( request.POST ); + if kickform.is_valid(): + if kickform.cleaned_data["ban"]: + srv.banUser( kickform.cleaned_data['session'], kickform.cleaned_data['reason'] ); + srv.kickUser( kickform.cleaned_data['session'], kickform.cleaned_data['reason'] ); # ChannelTable is a somewhat misleading name, as it actually contains channels and players. channelTable = [];