search: reduce user index size

This commit is contained in:
tleb 2020-04-21 16:12:29 +02:00 committed by Skia
parent 12493cffca
commit 6382e631b6
2 changed files with 9 additions and 4 deletions

View File

@ -1,13 +1,13 @@
{% load replace %}
{% load search_helpers %}
{% with first=object.first_name|safe|slugify last=object.last_name|safe|slugify nick=object.nick_name|default_if_none:""|safe|slugify %}
{{ first|replace:"|-| " }}
{{ last|replace:"|-| " }}
{{ nick|replace:"|-| " }}
{{ first|cut:"-" }}
{{ last|cut:"-" }}
{{ nick|cut:"-" }}
{% if first|count:"-" != 0 %}{{ first|cut:"-" }}{% endif %}
{% if last|count:"-" != 0 %}{{ last|cut:"-" }}{% endif %}
{% if nick|count:"-" != 0 %}{{ nick|cut:"-" }}{% endif %}
{{ first|cut:"-" }}{{ last|cut:"-" }}
{% endwith %}

View File

@ -20,3 +20,8 @@ def replace(value, arg):
raise TemplateSyntaxError("badly formatted argument")
return value.replace(arg[1], arg[2])
@register.filter
def count(value, arg):
return value.count(arg)