Vue d'autocomplétion générique dans shared.views
pour factoriser les 3 autocomplétions (COF + BDS + K-Fêt) #730
3 changed files with 0 additions and 90 deletions
|
@ -1,50 +0,0 @@
|
|||
{% load kfet_tags %}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{% url "kfet.account.create.empty" %}">
|
||||
Créer un compte
|
||||
</a>
|
||||
</li>
|
||||
{% if kfet %}
|
||||
<li class="user_category"><span class="text">Comptes existants</span></li>
|
||||
{% for user in kfet %}
|
||||
<li><span class="text">{{ user.account_kfet.account }} [{{ user|highlight_user:q }}]</span></li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if users_cof %}
|
||||
<li class="user_category"><span class="text">Membres du COF</span></li>
|
||||
{% for user in users_cof %}
|
||||
<li>
|
||||
<a href="{% url "kfet.account.create.fromuser" user.username %}">
|
||||
{{ user|highlight_user:q }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if users_notcof %}
|
||||
<li class="user_category"><span class="text">Non-membres du COF</span></li>
|
||||
{% for user in users_notcof %}
|
||||
<li>
|
||||
<a href="{% url "kfet.account.create.fromuser" user.username %}">
|
||||
{{ user|highlight_user:q }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if clippers %}
|
||||
<li class="user_category"><span class="text">Utilisateurs clipper</span></li>
|
||||
{% for clipper in clippers %}
|
||||
<li>
|
||||
<a href="{% url "kfet.account.create.fromclipper" clipper.clipper clipper.fullname%}">
|
||||
{{ clipper|highlight_clipper:q }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if not q %}
|
||||
<li class="user_category"><span class="text">Pas de recherche, pas de résultats !</span></li>
|
||||
{% elif not options %}
|
||||
<li class="user_category"><span class="text">Aucune correspondance trouvée :-(</span></li>
|
||||
{% endif %}
|
||||
</ul>
|
|
@ -1,14 +0,0 @@
|
|||
{% load kfet_tags %}
|
||||
|
||||
<ul>
|
||||
{% if accounts %}
|
||||
{% for trigramme, user in accounts %}
|
||||
<li class='choice'>{{ user|highlight_text:q }} (<span class="trigramme">{{ trigramme }}</span>)</li>
|
||||
{% endfor %}
|
||||
{% elif not q %}
|
||||
<li class="user_category"><span class="text">Pas de recherche, pas de résultats !</span></li>
|
||||
{% else %}
|
||||
<li class="user_category"><span class="text">Aucune correspondance trouvée :-(</span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
@ -11,32 +11,6 @@ register = template.Library()
|
|||
register.filter("ukf", to_ukf)
|
||||
|
||||
|
||||
@register.filter()
|
||||
def highlight_text(text, q):
|
||||
q2 = "|".join(re.escape(word) for word in q.split())
|
||||
pattern = re.compile(r"(?P<filter>%s)" % q2, re.IGNORECASE)
|
||||
regex = r"<span class='highlight_autocomplete'>\g<filter></span>"
|
||||
return mark_safe(re.sub(pattern, regex, escape(text)))
|
||||
|
||||
|
||||
@register.filter(is_safe=True)
|
||||
def highlight_user(user, q):
|
||||
if user.first_name and user.last_name:
|
||||
text = "%s %s (%s)" % (user.first_name, user.last_name, user.username)
|
||||
else:
|
||||
text = user.username
|
||||
return highlight_text(text, q)
|
||||
|
||||
|
||||
@register.filter(is_safe=True)
|
||||
def highlight_clipper(clipper, q):
|
||||
if clipper.fullname:
|
||||
text = "%s (%s)" % (clipper.fullname, clipper.clipper)
|
||||
else:
|
||||
text = clipper.clipper
|
||||
return highlight_text(text, q)
|
||||
|
||||
|
||||
@register.filter()
|
||||
def widget_type(field):
|
||||
return field.field.widget.__class__.__name__
|
||||
|
|
Loading…
Reference in a new issue