s/username/clipper in highlight_clipper
There was typo, the `Clipper` object has no `username` attribute. We want to use the `clipper` attribute
This commit is contained in:
parent
e98a407982
commit
3acc8bca75
1 changed files with 8 additions and 8 deletions
|
@ -1,23 +1,21 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from __future__ import (absolute_import, division,
|
|
||||||
print_function, unicode_literals)
|
|
||||||
from builtins import *
|
|
||||||
|
|
||||||
from django import template
|
from django import template
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.core.cache import cache
|
|
||||||
from kfet.models import Settings
|
from kfet.models import Settings
|
||||||
from math import floor
|
from math import floor
|
||||||
import re
|
import re
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
def highlight_text(text, q):
|
def highlight_text(text, q):
|
||||||
q2 = "|".join(q.split())
|
q2 = "|".join(q.split())
|
||||||
pattern = re.compile(r"(?P<filter>%s)" % q2, re.IGNORECASE)
|
pattern = re.compile(r"(?P<filter>%s)" % q2, re.IGNORECASE)
|
||||||
return mark_safe(re.sub(pattern, r"<span class='highlight_autocomplete'>\g<filter></span>", text))
|
regex = r"<span class='highlight_autocomplete'>\g<filter></span>"
|
||||||
|
return mark_safe(re.sub(pattern, regex, text))
|
||||||
|
|
||||||
|
|
||||||
@register.filter(is_safe=True)
|
@register.filter(is_safe=True)
|
||||||
def highlight_user(user, q):
|
def highlight_user(user, q):
|
||||||
|
@ -27,14 +25,16 @@ def highlight_user(user, q):
|
||||||
text = user.username
|
text = user.username
|
||||||
return highlight_text(escape(text), q)
|
return highlight_text(escape(text), q)
|
||||||
|
|
||||||
|
|
||||||
@register.filter(is_safe=True)
|
@register.filter(is_safe=True)
|
||||||
def highlight_clipper(clipper, q):
|
def highlight_clipper(clipper, q):
|
||||||
if clipper.fullname:
|
if clipper.fullname:
|
||||||
text = "%s (%s)" % (clipper.fullname, clipper.username)
|
text = "%s (%s)" % (clipper.fullname, clipper.clipper)
|
||||||
else:
|
else:
|
||||||
text = clipper.username
|
text = clipper.clipper
|
||||||
return highlight_text(escape(text), q)
|
return highlight_text(escape(text), q)
|
||||||
|
|
||||||
|
|
||||||
@register.filter()
|
@register.filter()
|
||||||
def ukf(balance, is_cof):
|
def ukf(balance, is_cof):
|
||||||
grant = is_cof and (1 + Settings.SUBVENTION_COF() / 100) or 1
|
grant = is_cof and (1 + Settings.SUBVENTION_COF() / 100) or 1
|
||||||
|
|
Loading…
Reference in a new issue