Browse Source

reindent mumble.html; implement avatar updating

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

163
pyweb/mumble/templates/mumble/mumble.html

@ -1,91 +1,96 @@
{% 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 %}
{% block Headline %} {% block Headline %}
{{ MumbleServer.name }}
{{ MumbleServer.name }}
{% endblock %} {% endblock %}
{% block ContentMaster %} {% block ContentMaster %}
<div id="ext_container"></div>
<div id="ext_container"></div>
{% endblock %} {% endblock %}
{% block HeadTag %} {% block HeadTag %}
<script type="text/javascript" src="/jsi18n/"></script>
<script type="text/javascript" src="/mumble/api/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/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/usereditor.js"></script>
<script type="text/javascript">
Ext.onReady( function(){
Ext.QuickTips.init();
<script type="text/javascript" src="/jsi18n/"></script>
<script type="text/javascript" src="/mumble/api/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/mumbleform.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">
Ext.onReady( function(){
Ext.QuickTips.init();
var mainpanel = new Ext.Panel({
renderTo: "ext_container",
height: 600,
layout: "border",
items: [{
xtype: "mumblechannelviewer",
region: "west",
width: 350,
split: true,
source_url: "{% url mumble.views.cvp_json MumbleServer.id %}",
}, {
xtype: "tabpanel",
region: "center",
activeTab: 0,
items: [{
title: gettext("Registration"),
xtype: "{{ RegForm|lower }}",
pk: {{ MumbleAccount.id }},
submit: function(){
this.getForm().submit({ params: {serverid: {{MumbleServer.id}}, pk: this.pk } });
},
}, {
title: gettext("Administration"),
pk: {{ MumbleServer.id }},
xtype: 'mumbleform',
}, {
title: gettext("User texture"),
layout: "border",
items: [{
region: "north",
layout: "hbox",
height: 220,
items: [{
flex: 1,
height: 200,
title: gettext("Texture"),
html: String.format('<img src="{0}" alt="Avatar" />',
"{% url mumble.views.showTexture MumbleServer.id MumbleAccount.id %}"),
}, {
flex: 1,
height: 200,
title: gettext("Gravatar"),
html: String.format('<img src="{0}" alt="grAvatar" />', "{{ MumbleAccount.gravatar }}"),
}],
}, {
region: "center",
xtype: "form",
items: [{
name: "usegravatar",
fieldLabel: gettext("Use Gravatar"),
xtype: "checkbox",
}, {
name: "uploadpic",
fieldLabel: gettext("Upload Avatar"),
xtype: "textfield",
inputType: "file",
}],
}],
}, {
xtype: "userEditorPanel",
} ],
}],
});
} );
</script>
var mainpanel = new Ext.Panel({
renderTo: "ext_container",
height: 600,
layout: "border",
items: [{
xtype: "mumblechannelviewer",
region: "west",
width: 350,
split: true,
source_url: "{% url mumble.views.cvp_json MumbleServer.id %}",
}, {
xtype: "tabpanel",
region: "center",
activeTab: 0,
items: [{
title: gettext("Registration"),
xtype: "{{ RegForm|lower }}",
pk: {{ MumbleAccount.id }},
submit: function(){
this.getForm().submit({ params: {serverid: {{MumbleServer.id}}, pk: this.pk } });
},
}, {
title: gettext("Administration"),
pk: {{ MumbleServer.id }},
xtype: 'mumbleform',
}, {
title: gettext("User texture"),
layout: "border",
items: [{
region: "north",
layout: "hbox",
height: 200,
items: [{
flex: 1,
height: 200,
title: gettext("Texture"),
html: String.format('<img src="{0}" alt="Avatar" />',
"{% url mumble.views.showTexture MumbleServer.id MumbleAccount.id %}"),
}, {
flex: 1,
height: 200,
title: gettext("Gravatar"),
html: String.format('<img src="{0}" alt="grAvatar" />', "{{ MumbleAccount.gravatar }}"),
}],
}, {
region: "center",
xtype: "form",
fileUpload: true,
url: "{% url mumble.views.update_avatar MumbleAccount.id %}",
items: [{
name: "usegravatar",
fieldLabel: gettext("Use Gravatar"),
xtype: "checkbox",
}, {
name: "texturefile",
fieldLabel: gettext("Upload Avatar"),
xtype: "textfield",
inputType: "file",
}],
buttons: [{
text: 'Submit',
handler: function(){ this.ownerCt.ownerCt.getForm().submit(); },
}],
}],
}, {
xtype: "userEditorPanel",
} ],
}],
});
} );
</script>
{% endblock %} {% endblock %}

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