Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding template tag

  • Loading branch information...
commit fde03f5d5ffb709b0da8e2ff7a4553de6d1b9832 1 parent 67a0a8a
Charles DeTar authored
View
0  afg/templatetags/__init__.py
No changes.
View
18 afg/templatetags/afg.py
@@ -0,0 +1,18 @@
+from django import template
+
+register = template.Library()
+
+@register.filter
+def casualty_summary(entry):
+ parts = []
+ for attr in ('civilian', 'host_nation', 'friendly', 'enemy'):
+ k = getattr(entry, attr + '_kia')
+ w = getattr(entry, attr + '_wia')
+ if k or w:
+ counts = []
+ if k:
+ counts.append("%i killed" % k)
+ if w:
+ counts.append("%i wounded" % w)
+ parts.append("%s: %s" % (attr.title().replace("_", " "), ", ".join(counts)))
+ return "; ".join(parts)
Please sign in to comment.
Something went wrong with that request. Please try again.