|
|
@ -22,17 +22,17 @@ from django.conf import settings |
|
|
|
register = template.Library(); |
|
|
|
|
|
|
|
|
|
|
|
### FILTER: trunc -- converts "a very very extaordinary long text" to "a very very extra..." |
|
|
|
@register.filter |
|
|
|
def trunc( string, maxlen = 50 ): |
|
|
|
""" converts "a very very extaordinary long text" to "a very very extra... """ |
|
|
|
if len(string) < maxlen: |
|
|
|
return string; |
|
|
|
return string[:(maxlen - 3)] + "..."; |
|
|
|
|
|
|
|
|
|
|
|
### FILTER: chanview -- renders an mmChannel / mmPlayer object with the correct template. |
|
|
|
@register.filter |
|
|
|
def chanview( obj, user = None ): |
|
|
|
""" renders an mmChannel / mmPlayer object with the correct template """ |
|
|
|
if obj.is_server: |
|
|
|
return render_to_string( 'mumble/server.html', { 'Server': obj, 'MumbleAccount': user, 'MEDIA_URL': settings.MEDIA_URL } ); |
|
|
|
elif obj.is_channel: |
|
|
@ -41,7 +41,22 @@ def chanview( obj, user = None ): |
|
|
|
return render_to_string( 'mumble/player.html', { 'Player': obj, 'MumbleAccount': user, 'MEDIA_URL': settings.MEDIA_URL } ); |
|
|
|
|
|
|
|
|
|
|
|
### FILTER: chanurl -- creates a connection URL and takes the user's login into account |
|
|
|
@register.filter |
|
|
|
def chanurl( obj, user ): |
|
|
|
""" create a connection URL and takes the user's login into account """ |
|
|
|
return obj.getURL( user ); |
|
|
|
|
|
|
|
@register.filter |
|
|
|
def mmversion_lt( obj, version ): |
|
|
|
""" return True if the given Server's version is less than the given version. """ |
|
|
|
return tuple(obj.version[:3]) < tuple([int(v) for v in version.split('.')]) |
|
|
|
|
|
|
|
@register.filter |
|
|
|
def mmversion_eq( obj, version ): |
|
|
|
""" return True if the given Server's version equals the given version. """ |
|
|
|
return tuple(obj.version[:3]) == tuple([int(v) for v in version.split('.')]) |
|
|
|
|
|
|
|
@register.filter |
|
|
|
def mmversion_gt( obj, version ): |
|
|
|
""" return True if the given Server's version is greater than the given version. """ |
|
|
|
return tuple(obj.version[:3]) > tuple([int(v) for v in version.split('.')]) |