From 0b6c76b00855f3eb7035c69d8d183f2f0e866277 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Fri, 4 Apr 2014 14:28:07 +0100 Subject: [PATCH] move fieldtype filter to wagtailadmin_tags --- .../templates/wagtailadmin/shared/field_as_li.html | 2 +- wagtail/wagtailadmin/templatetags/fieldtype.py | 13 ------------- .../wagtailadmin/templatetags/wagtailadmin_tags.py | 9 +++++++++ 3 files changed, 10 insertions(+), 14 deletions(-) delete mode 100644 wagtail/wagtailadmin/templatetags/fieldtype.py diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/shared/field_as_li.html b/wagtail/wagtailadmin/templates/wagtailadmin/shared/field_as_li.html index 10000bb981..af4ba73a3b 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/shared/field_as_li.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/shared/field_as_li.html @@ -1,4 +1,4 @@ -{% load fieldtype %} +{% load wagtailadmin_tags %}
  • {% if field|fieldtype != "boolean_field" %}{{ field.label_tag }}{% endif %} diff --git a/wagtail/wagtailadmin/templatetags/fieldtype.py b/wagtail/wagtailadmin/templatetags/fieldtype.py deleted file mode 100644 index fc27d75117..0000000000 --- a/wagtail/wagtailadmin/templatetags/fieldtype.py +++ /dev/null @@ -1,13 +0,0 @@ -from django import template - -from wagtail.wagtailcore.util import camelcase_to_underscore - -register = template.Library() - - -@register.filter -def fieldtype(bound_field): - try: - return camelcase_to_underscore(bound_field.field.__class__.__name__) - except AttributeError: - return "" diff --git a/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py b/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py index 8fd2544f73..3fbd1c406c 100644 --- a/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py +++ b/wagtail/wagtailadmin/templatetags/wagtailadmin_tags.py @@ -6,6 +6,7 @@ from wagtail.wagtailadmin import hooks from wagtail.wagtailadmin.menu import MenuItem from wagtail.wagtailcore.models import get_navigation_menu_items +from wagtail.wagtailcore.util import camelcase_to_underscore from wagtail.wagtailsnippets.permissions import user_can_edit_snippets # TODO: reorganise into pluggable architecture so that wagtailsnippets registers its own menu item @@ -83,3 +84,11 @@ def ellipsistrim(value, max_length): truncd_val = truncd_val[:truncd_val.rfind(" ")] return truncd_val + "..." return value + + +@register.filter +def fieldtype(bound_field): + try: + return camelcase_to_underscore(bound_field.field.__class__.__name__) + except AttributeError: + return ""