Browse Source

add drafts for the mumpytz interface that is in planning

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
1aa360cf6c
  1. 40
      pyweb/mumble/mmobjects.py
  2. 17
      pyweb/mumble/models.py

40
pyweb/mumble/mmobjects.py

@ -23,7 +23,6 @@ from os.path import join
from django.utils.http import urlquote
from django.conf import settings
def cmp_names( a, b ):
return cmp( a.name, b.name );
@ -144,6 +143,23 @@ class mmChannel( object ):
doc="True if this channel is the server's default channel."
);
def as_dict( self ):
if self.parent:
parentid = self.parent.chanid;
else:
parentid = None;
return { 'chanid': self.chanid,
'description': self.description,
'linked': [],
'linkedIDs': [],
'name': self.name,
'parent': parentid,
'players': [ pl.as_dict() for pl in self.players ],
'subchans': [ sc.as_dict() for sc in self.subchans ]
};
class mmPlayer( object ):
@ -208,6 +224,28 @@ class mmPlayer( object ):
""" Call callback on myself. """
callback( self, lvl );
def as_dict( self ):
comment = None;
texture = None;
if self.mumbleuser:
comment = self.mumbleuser.comment;
if self.mumbleuser.hasTexture():
texture = self.mumbleuser.textureUrl;
return { 'bytesPerSec': self.bytesPerSec,
'dbaseid': self.dbaseid,
'deafened': self.deafened,
'muted': self.muted,
'name': self.name,
'onlinesince': self.onlinesince,
'selfdeafened': self.selfdeafened,
'selfmuted': self.selfmuted,
'suppressed': self.suppressed,
'userid': self.userid,
'comment': comment,
'texture': texture,
};
class mmACL:

17
pyweb/mumble/models.py

@ -26,6 +26,7 @@ from mmobjects import *
from mctl import *
class Mumble( models.Model ):
""" Represents a Murmur server instance.
@ -365,6 +366,12 @@ class Mumble( models.Model ):
version = property( lambda self: self.ctl.getVersion(), doc="The version of Murmur." );
def as_dict( self ):
return { 'name': self.name,
'id': self.id,
'root': self.rootchan.as_dict()
};
class MumbleUser( models.Model ):
@ -508,6 +515,8 @@ class MumbleUser( models.Model ):
"""Read an image from the infile and install it as the user's texture."""
self.server.ctl.setTexture(self.server.srvid, self.mumbleid, infile)
texture = property( getTexture, setTexture, doc="Get the texture as a PIL Image or read from a file (pass the path)." );
def hasTexture( self ):
try:
self.getTexture();
@ -516,6 +525,14 @@ class MumbleUser( models.Model ):
else:
return True;
def getTextureUrl( self ):
""" Get a URL under which the texture can be retrieved. """
from views import showTexture
from django.core.urlresolvers import reverse
return reverse( showTexture, kwargs={ 'server': self.server.id, 'userid': self.id } );
textureUrl = property( getTextureUrl, doc=getTextureUrl.__doc__ );
# Deletion handler
@staticmethod

Loading…
Cancel
Save