kopia lustrzana https://github.com/wagtail/wagtail
move fieldtype filter to wagtailadmin_tags
rodzic
1d092eb1da
commit
0b6c76b008
|
@ -1,4 +1,4 @@
|
|||
{% load fieldtype %}
|
||||
{% load wagtailadmin_tags %}
|
||||
<li class="{{ field.css_classes }} {{ field|fieldtype }} {% if field.errors %}error{% endif %}">
|
||||
<div class="field">
|
||||
{% if field|fieldtype != "boolean_field" %}{{ field.label_tag }}{% endif %}
|
||||
|
|
|
@ -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 ""
|
|
@ -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 ""
|
||||
|
|
Ładowanie…
Reference in New Issue