Browse Source

show user textures in the detail pages

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

1
pyweb/mumble/urls.py

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

14
pyweb/mumble/views.py

@ -152,11 +152,18 @@ 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."""
srv = get_object_or_404( Mumble, id=int(server) );
if userid is None:
if request.user.is_authenticated(): if request.user.is_authenticated():
srv = Mumble.objects.get( id=int(server) );
user = MumbleUser.objects.get( server=srv, owner=request.user );
user = get_object_or_404( MumbleUser, server=srv, owner=request.user );
else:
raise Http404();
else:
user = get_object_or_404( MumbleUser, server=srv, id=int(userid) );
try: try:
img = user.getTexture(); img = user.getTexture();
except ValueError: except ValueError:
@ -165,7 +172,6 @@ def showTexture( request, server ):
buffer = StringIO(); buffer = StringIO();
img.save( buffer, "PNG" ); img.save( buffer, "PNG" );
return HttpResponse( buffer.getvalue(), "image/png" ); return HttpResponse( buffer.getvalue(), "image/png" );
raise Http404();

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