Browse Source

reindent mumble.html; implement avatar updating

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

13
pyweb/mumble/templates/mumble/mumble.html

@ -1,6 +1,6 @@
{% extends "index.html" %} {% extends "index.html" %}
{% comment %} {% comment %}
<!-- kate: space-indent on; indent-width 2; replace-tabs on; -->
<!-- kate: space-indent on; indent-width 4; replace-tabs on; -->
{% endcomment %} {% endcomment %}
{% load mumble_extras %} {% load mumble_extras %}
{% load i18n %} {% load i18n %}
@ -16,7 +16,6 @@
<script type="text/javascript" src="/mumble/forms/api.js"></script> <script type="text/javascript" src="/mumble/forms/api.js"></script>
<script type="text/javascript" src="/mumble/forms/{{ RegForm|lower }}.js"></script> <script type="text/javascript" src="/mumble/forms/{{ RegForm|lower }}.js"></script>
<script type="text/javascript" src="/mumble/forms/mumbleform.js"></script> <script type="text/javascript" src="/mumble/forms/mumbleform.js"></script>
<script type="text/javascript" src="/mumble/forms/mumbletextureform.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}/js/channelviewer.js"></script> <script type="text/javascript" src="{{ MEDIA_URL }}/js/channelviewer.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}/js/usereditor.js"></script> <script type="text/javascript" src="{{ MEDIA_URL }}/js/usereditor.js"></script>
<script type="text/javascript"> <script type="text/javascript">
@ -54,7 +53,7 @@
items: [{ items: [{
region: "north", region: "north",
layout: "hbox", layout: "hbox",
height: 220,
height: 200,
items: [{ items: [{
flex: 1, flex: 1,
height: 200, height: 200,
@ -70,16 +69,22 @@
}, { }, {
region: "center", region: "center",
xtype: "form", xtype: "form",
fileUpload: true,
url: "{% url mumble.views.update_avatar MumbleAccount.id %}",
items: [{ items: [{
name: "usegravatar", name: "usegravatar",
fieldLabel: gettext("Use Gravatar"), fieldLabel: gettext("Use Gravatar"),
xtype: "checkbox", xtype: "checkbox",
}, { }, {
name: "uploadpic",
name: "texturefile",
fieldLabel: gettext("Upload Avatar"), fieldLabel: gettext("Upload Avatar"),
xtype: "textfield", xtype: "textfield",
inputType: "file", inputType: "file",
}], }],
buttons: [{
text: 'Submit',
handler: function(){ this.ownerCt.ownerCt.getForm().submit(); },
}],
}], }],
}, { }, {
xtype: "userEditorPanel", xtype: "userEditorPanel",

1
pyweb/mumble/urls.py

@ -28,6 +28,7 @@ urlpatterns = patterns(
( r'forms/', include(EXT_FORMS_PROVIDER.urls) ), ( r'forms/', include(EXT_FORMS_PROVIDER.urls) ),
( r'(?P<server>\d+)/(?P<userid>\d+)/texture.png', 'showTexture' ), ( r'(?P<server>\d+)/(?P<userid>\d+)/texture.png', 'showTexture' ),
( r'(?P<userid>\d+)/update_avatar', 'update_avatar' ),
( r'murmur/tree/(?P<server>\d+)', 'mmng_tree' ), ( r'murmur/tree/(?P<server>\d+)', 'mmng_tree' ),
( r'mumbleviewer/(?P<server>\d+).xml', 'mumbleviewer_tree_xml' ), ( r'mumbleviewer/(?P<server>\d+).xml', 'mumbleviewer_tree_xml' ),

20
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.models import User
from django.contrib.auth import views as auth_views from django.contrib.auth import views as auth_views
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.views.decorators.csrf import csrf_exempt
from models import Mumble, MumbleUser from models import Mumble, MumbleUser
from forms import MumbleForm, MumbleUserForm, MumbleUserPasswordForm from forms import MumbleForm, MumbleUserForm, MumbleUserPasswordForm
@ -230,6 +231,25 @@ def djangousers( request ):
return users 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 ): def mmng_tree( request, server ):
""" Return a JSON representation of the channel tree suitable for """ Return a JSON representation of the channel tree suitable for
Murmur Manager: Murmur Manager:

Loading…
Cancel
Save