Browse Source

fixed auto-hiding of empty channels

Natenom/support-murmur-13-1446181288462
Michael Ziegler 16 years ago
parent
commit
7fb8c9ea0f
  1. 5
      pyweb/mumble/mmobjects.py
  2. 10
      pyweb/mumble/templatetags/mumble_extras.py
  3. 10
      template/mumble/channel.htm

5
pyweb/mumble/mmobjects.py

@ -60,7 +60,10 @@ class mmChannel( object ):
lambda self: len( self.players ) + sum( [ chan.playerCount for chan in self.subchans ] ), lambda self: len( self.players ) + sum( [ chan.playerCount for chan in self.subchans ] ),
None None
); );
id = property( lambda self: "channel_%d"%self.chanid, None );
id = property( lambda self: "channel_%d"%self.chanid, None );
show = property( lambda self: self.parent is None or self.playerCount > 0, None );
def __str__( self ): def __str__( self ):
return '<Channel "%s" (%d)>' % ( self.name, self.chanid ); return '<Channel "%s" (%d)>' % ( self.name, self.chanid );

10
pyweb/mumble/templatetags/mumble_extras.py

@ -18,16 +18,6 @@ from django.template.loader import render_to_string
register = template.Library(); register = template.Library();
### FILTER: mrange -- used to render the ||| lines in the channel tree
def mrange( value ):
"If value > 1, returns range( value - 1 ), else returns an empty list."
val = int( value );
if( val > 1 ):
return range( val - 1 );
return list();
register.filter( 'mrange', mrange );
### FILTER: trunc -- converts "a very very extaordinary long text" to "a very very extra..." ### FILTER: trunc -- converts "a very very extaordinary long text" to "a very very extra..."
def trunc( string, maxlen = 50 ): def trunc( string, maxlen = 50 ):

10
template/mumble/channel.htm

@ -9,9 +9,11 @@
<a href="{{ Channel|chanurl:MumbleAccount }}" class="mumble" id="link_{{ Channel.id }}" title="{{ Channel.name }}"> <a href="{{ Channel|chanurl:MumbleAccount }}" class="mumble" id="link_{{ Channel.id }}" title="{{ Channel.name }}">
{{ Channel.name|trunc:30 }} {{ Channel.name|trunc:30 }}
</a> </a>
{% for sub in Channel.subchans %}
{{ sub|chanview:MumbleAccount }}
{% endfor %}
{% for player in Channel.players %}{{ player|chanview }}{% endfor %}
{% if Channel.show %}
{% for sub in Channel.subchans %}
{{ sub|chanview:MumbleAccount }}
{% endfor %}
{% for player in Channel.players %}{{ player|chanview }}{% endfor %}
{% endif %}
</div> </div>
Loading…
Cancel
Save