Browse Source

show user comments in their detail pages

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
72f2fad025
  1. 12
      pyweb/mumble/MumbleCtlIce.py
  2. 29
      pyweb/mumble/models.py
  3. 12
      template/mumble/mumble.htm

12
pyweb/mumble/MumbleCtlIce.py

@ -314,7 +314,17 @@ class MumbleCtlIce_120(MumbleCtlIce_118):
self._getIceServerObject(srvid).unregisterUser(mumbleid) self._getIceServerObject(srvid).unregisterUser(mumbleid)
def getRegistration(self, srvid, mumbleid): def getRegistration(self, srvid, mumbleid):
return self._getIceServerObject( srvid ).getRegistration( mumbleid )
from Murmur import UserInfo
reg = self._getIceServerObject( srvid ).getRegistration( mumbleid )
user = {
'name': reg[UserInfo.UserName],
'email': reg[UserInfo.UserEmail],
};
if UserInfo.UserComment in reg:
user['comment'] = reg[UserInfo.UserComment];
if UserInfo.UserHash in reg:
user['hash'] = reg[UserInfo.UserHash];
return user;
def setRegistration(self, srvid, mumbleid, name, email, password): def setRegistration(self, srvid, mumbleid, name, email, password):
from Murmur import UserInfo from Murmur import UserInfo

29
pyweb/mumble/models.py

@ -396,6 +396,10 @@ class MumbleUser( models.Model ):
is_channel = False; is_channel = False;
is_player = True; is_player = True;
def __init__( self, *args, **kwargs ):
models.Model.__init__( self, *args, **kwargs );
self._registration = None;
def __unicode__( self ): def __unicode__( self ):
return _("Mumble user %(mu)s on %(srv)s owned by Django user %(du)s") % { 'mu': self.name, 'srv': self.server, 'du': self.owner }; return _("Mumble user %(mu)s on %(srv)s owned by Django user %(du)s") % { 'mu': self.name, 'srv': self.server, 'du': self.owner };
@ -468,6 +472,31 @@ class MumbleUser( models.Model ):
ctl.setACL(self.server.srvid, acl); ctl.setACL(self.server.srvid, acl);
return value; return value;
# Registration fetching
def getRegistration( self ):
"""Retrieve a user's registration from Murmur as a dict."""
if not self._registration:
self._registration = self.server.ctl.getRegistration( self.server.srvid, self.mumbleid );
return self._registration;
registration = property( getRegistration, doc=getRegistration.__doc__ );
def getComment( self ):
"""Retrieve a user's comment, if any."""
if "comment" in self.registration:
return self.registration["comment"];
else:
return None;
comment = property( getComment, doc=getComment.__doc__ );
def getHash( self ):
if "hash" in self.registration:
return self.registration["hash"];
else:
return None;
hash = property( getHash, doc=getHash.__doc__ );
# Texture handlers # Texture handlers

12
template/mumble/mumble.htm

@ -120,9 +120,17 @@
<li>{% trans "Sign-up date" %}: {{ item.mumbleuser.owner.date_joined|date }}</li> <li>{% trans "Sign-up date" %}: {{ item.mumbleuser.owner.date_joined|date }}</li>
</ul> </ul>
{% endif %} {% endif %}
{% if item.mumbleuser and item.mumbleuser.comment %}
<fieldset>
<legend>{% trans "User Comment" %}</legend>
{{ item.mumbleuser.comment|safe }}
</fieldset>
{% endif %}
{% if item.mumbleuser and item.mumbleuser.hasTexture %} {% if item.mumbleuser and item.mumbleuser.hasTexture %}
<h2>{% trans "User Texture" %}</h2>
<img src="{% url mumble.views.showTexture DBaseObject.id item.mumbleuser.id %}" alt="user texture" />
<fieldset>
<legend>{% trans "User Texture" %}</legend>
<img src="{% url mumble.views.showTexture DBaseObject.id item.mumbleuser.id %}" alt="user texture" />
</fieldset>
{% endif %} {% endif %}
</div> </div>
{% else %} {% else %}

Loading…
Cancel
Save