From da77a5f09a8fab7d00f32c275957050fad24c715 Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Tue, 22 Feb 2011 13:40:51 +0100 Subject: beautify acl display a bit --- coip/extensions/templatetags/permdisplay.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'coip/extensions') diff --git a/coip/extensions/templatetags/permdisplay.py b/coip/extensions/templatetags/permdisplay.py index a2b347d..364544e 100644 --- a/coip/extensions/templatetags/permdisplay.py +++ b/coip/extensions/templatetags/permdisplay.py @@ -1,4 +1,7 @@ from django import template +from coip.extensions.templatetags.userdisplay import userdisplay +from string import split +from django.contrib.auth.models import User register = template.Library() @@ -8,14 +11,29 @@ MOMENT = 120 # duration in seconds within which the time difference perms = {'r':'read', 'w':'write', 'd':'delete', - 'i':'insert', - 'l':'list'} + 'i':'manage members', + 'l':'list members'} def permdisplay(perm): if perm: - return "can %s" % (' '.join([perms[p] for p in perm])) + return "can %s" % (', '.join([perms[p] for p in perm])) else: return "can do nothing" - + permdisplay.is_safe = True -register.filter(permdisplay) \ No newline at end of file +register.filter(permdisplay) + +def acldstdisplay(dst): + if dst.display.startswith("user:"): + (pfx,username) = split(dst.display,":",1) + user = User.objects.get(username=username) + if user: + return userdisplay(user) + else: + return "Unknown user \"%s\"" % username + else: + return "Members of %s" % (dst.display,dst.id,dst.short) + + +acldstdisplay.is_safe = True +register.filter(acldstdisplay) \ No newline at end of file -- cgit v1.1