Browse Source

add setting your own texture to your gravatar

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
24a60fe541
  1. 3
      pyweb/mumble/forms.py
  2. 6
      pyweb/mumble/templates/mumble/mumble.html
  3. 20
      pyweb/mumble/views.py

3
pyweb/mumble/forms.py

@ -319,6 +319,7 @@ class MumbleKickForm( Form ):
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. """
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") );

6
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. You can upload an image that you would like to use as your user texture here.
{% endblocktrans %}<br /> {% endblocktrans %}<br />
<br /> <br />
<div float="right">
{% if MumbleAccount.gravatar %}
Gravatar:
<img src="{{ MumbleAccount.gravatar }}" alt="your gravatar" />
{% endif %}
</div>
{% if MumbleAccount.hasTexture %} {% if MumbleAccount.hasTexture %}
{% trans "Your current texture is" %}:<br /> {% trans "Your current texture is" %}:<br />
<img src="{% url mumble.views.showTexture DBaseObject.id MumbleAccount.id %}" alt="user texture" /><br /> <img src="{% url mumble.views.showTexture DBaseObject.id MumbleAccount.id %}" alt="user texture" /><br />

20
pyweb/mumble/views.py

@ -15,6 +15,7 @@
""" """
import simplejson import simplejson
from urllib import urlopen
from StringIO import StringIO from StringIO import StringIO
from PIL import Image 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: if request.method == 'POST' and 'mode' in request.POST and request.POST['mode'] == 'texture' and registered:
textureform = MumbleTextureForm( request.POST, request.FILES ); textureform = MumbleTextureForm( request.POST, request.FILES );
if textureform.is_valid(): 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), } ) ); return HttpResponseRedirect( reverse( show, kwargs={ 'server': int(server), } ) );
else: else:
textureform = MumbleTextureForm(); textureform = MumbleTextureForm();
@ -175,12 +180,13 @@ def show( request, server ):
textureform = None; textureform = None;
if isAdmin: 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 is a somewhat misleading name, as it actually contains channels and players.
channelTable = []; channelTable = [];

Loading…
Cancel
Save