Merge branch 'kgodey'
authorJoseph Spiros <joseph.spiros@ithinksw.com>
Thu, 8 Jul 2010 00:34:45 +0000 (20:34 -0400)
committerJoseph Spiros <joseph.spiros@ithinksw.com>
Thu, 8 Jul 2010 00:34:45 +0000 (20:34 -0400)
* kgodey:
  Fixing a double declaration of the monthname filter, and renaming ap_monthname to apmonthname (matches apnumber from django.contrib.humanize).
  Added templatetags "monthname" and "ap_monthname" to Penfield, which turn month numbers into month names.

contrib/penfield/templatetags/__init__.py [new file with mode: 0644]
contrib/penfield/templatetags/penfield.py [new file with mode: 0644]

diff --git a/contrib/penfield/templatetags/__init__.py b/contrib/penfield/templatetags/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/contrib/penfield/templatetags/penfield.py b/contrib/penfield/templatetags/penfield.py
new file mode 100644 (file)
index 0000000..99e358c
--- /dev/null
@@ -0,0 +1,22 @@
+from django import template
+from django.utils.dates import MONTHS, MONTHS_AP
+
+register = template.Library()
+
+def monthname(value):
+       monthnum = int(value)
+       if 1 <= monthnum <= 12:
+               return MONTHS[monthnum]
+       else:
+               return value
+
+register.filter('monthname', monthname)
+
+def apmonthname(value):
+       monthnum = int(value)
+       if 1 <= monthnum <= 12:
+               return MONTHS_AP[monthnum]
+       else:
+               return value
+
+register.filter('apmonthname', apmonthname)