Browse Source

show user textures in the detail pages

Natenom/support-murmur-13-1446181288462
Michael Ziegler 16 years ago
parent
commit
44580b161a
  1. 7
      pyweb/mumble/urls.py
  2. 30
      pyweb/mumble/views.py
  3. 2
      template/mumble/mumble.htm

7
pyweb/mumble/urls.py

@ -18,7 +18,8 @@ from django.conf.urls.defaults import *
urlpatterns = patterns( urlpatterns = patterns(
'mumble.views', 'mumble.views',
( r'(?P<server>\d+)/texture.png', 'showTexture' ),
( r'(?P<server>\d+)', 'show' ),
( r'$', 'mumbles' ),
( r'(?P<server>\d+)/(?P<userid>\d+)texture.png', 'showTexture' ),
( r'(?P<server>\d+)/texture.png', 'showTexture' ),
( r'(?P<server>\d+)', 'show' ),
( r'$', 'mumbles' ),
) )

30
pyweb/mumble/views.py

@ -152,20 +152,26 @@ def show( request, server ):
); );
def showTexture( request, server ):
def showTexture( request, server, userid = None ):
"""Pack the currently logged in user's texture (if any) into an HttpResponse.""" """Pack the currently logged in user's texture (if any) into an HttpResponse."""
if request.user.is_authenticated():
srv = Mumble.objects.get( id=int(server) );
user = MumbleUser.objects.get( server=srv, owner=request.user );
try:
img = user.getTexture();
except ValueError:
raise Http404();
srv = get_object_or_404( Mumble, id=int(server) );
if userid is None:
if request.user.is_authenticated():
user = get_object_or_404( MumbleUser, server=srv, owner=request.user );
else: else:
buffer = StringIO();
img.save( buffer, "PNG" );
return HttpResponse( buffer.getvalue(), "image/png" );
raise Http404();
raise Http404();
else:
user = get_object_or_404( MumbleUser, server=srv, id=int(userid) );
try:
img = user.getTexture();
except ValueError:
raise Http404();
else:
buffer = StringIO();
img.save( buffer, "PNG" );
return HttpResponse( buffer.getvalue(), "image/png" );

2
template/mumble/mumble.htm

@ -112,6 +112,8 @@
<li>{% trans "Sign-up date" %}: {{ item.mumbleuser.owner.date_joined }}</li> <li>{% trans "Sign-up date" %}: {{ item.mumbleuser.owner.date_joined }}</li>
</ul> </ul>
{% endif %} {% endif %}
<h2>{% trans "User Texture" %}</h2>
<img src="/mumble/{{ DBaseObject.id }}/{{ item.mumbleuser.id }}/texture.png" alt="user texture" />
</div> </div>
{% else %} {% else %}
<div id="mumble_{{ item.id }}" class="mumble-ext x-hide-display"> <div id="mumble_{{ item.id }}" class="mumble-ext x-hide-display">

Loading…
Cancel
Save