From 3acc8bca7512d15051bf79cec44b5fbe65aa1e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 15 Mar 2017 19:11:38 +0000 Subject: [PATCH] s/username/clipper in highlight_clipper There was typo, the `Clipper` object has no `username` attribute. We want to use the `clipper` attribute --- kfet/templatetags/kfet_tags.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kfet/templatetags/kfet_tags.py b/kfet/templatetags/kfet_tags.py index f27f590e..b3976326 100644 --- a/kfet/templatetags/kfet_tags.py +++ b/kfet/templatetags/kfet_tags.py @@ -1,23 +1,21 @@ # -*- coding: utf-8 -*- -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * - from django import template from django.utils.html import escape from django.utils.safestring import mark_safe -from django.core.cache import cache from kfet.models import Settings from math import floor import re register = template.Library() + def highlight_text(text, q): q2 = "|".join(q.split()) pattern = re.compile(r"(?P%s)" % q2, re.IGNORECASE) - return mark_safe(re.sub(pattern, r"\g", text)) + regex = r"\g" + return mark_safe(re.sub(pattern, regex, text)) + @register.filter(is_safe=True) def highlight_user(user, q): @@ -27,14 +25,16 @@ def highlight_user(user, q): text = user.username return highlight_text(escape(text), q) + @register.filter(is_safe=True) def highlight_clipper(clipper, q): if clipper.fullname: - text = "%s (%s)" % (clipper.fullname, clipper.username) + text = "%s (%s)" % (clipper.fullname, clipper.clipper) else: - text = clipper.username + text = clipper.clipper return highlight_text(escape(text), q) + @register.filter() def ukf(balance, is_cof): grant = is_cof and (1 + Settings.SUBVENTION_COF() / 100) or 1