summaryrefslogtreecommitdiff
path: root/coip/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'coip/extensions')
-rw-r--r--coip/extensions/templatetags/permdisplay.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/coip/extensions/templatetags/permdisplay.py b/coip/extensions/templatetags/permdisplay.py
new file mode 100644
index 0000000..a2b347d
--- /dev/null
+++ b/coip/extensions/templatetags/permdisplay.py
@@ -0,0 +1,21 @@
+from django import template
+
+register = template.Library()
+
+MOMENT = 120 # duration in seconds within which the time difference
+ # will be rendered as 'a moment ago'
+
+perms = {'r':'read',
+ 'w':'write',
+ 'd':'delete',
+ 'i':'insert',
+ 'l':'list'}
+
+def permdisplay(perm):
+ if 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