parent
af2948827d
commit
bf5db35e57
@ -9,6 +9,7 @@ from colorfield.fields import ColorField
|
||||
from django_ckeditor_5.fields import CKEditor5Field
|
||||
from urllib.parse import urlparse
|
||||
from django.core.cache import cache
|
||||
import emoji
|
||||
|
||||
import hashlib
|
||||
import urllib.request
|
||||
@ -247,9 +248,9 @@ class Tag(models.Model):
|
||||
tags.sort(key=lambda x: -x["count"])
|
||||
|
||||
tags1 = tags[0:nb_suggestions]
|
||||
tags1.sort(key=lambda x: remove_accents(x["tag"]).lower())
|
||||
tags1.sort(key=lambda x: emoji.demojize(remove_accents(x["tag"]).lower(), delimiters=('000', '')))
|
||||
tags2 = tags[nb_suggestions:]
|
||||
tags2.sort(key=lambda x: remove_accents(x["tag"]).lower())
|
||||
tags2.sort(key=lambda x: emoji.demojize(remove_accents(x["tag"]).lower(), delimiters=('000', '')))
|
||||
|
||||
result = ((_('Suggestions'), [(t["tag"], t["tag"]) for t in tags1]),
|
||||
(_('Others'), [(t["tag"], t["tag"]) for t in tags2]))
|
||||
@ -697,7 +698,7 @@ class Event(models.Model):
|
||||
cursor.execute(raw_query)
|
||||
result = [{"tag": row[0], "count": row[1]} for row in cursor]
|
||||
if sort:
|
||||
result.sort(key=lambda x: remove_accents(x["tag"].lower()))
|
||||
result.sort(key=lambda x: emoji.demojize(remove_accents(x["tag"].lower()), delimiters=('000', '')))
|
||||
return result
|
||||
|
||||
def is_draft(self):
|
||||
|
@ -199,6 +199,8 @@ details[role="list"] summary + ul li.selected>a:hover {
|
||||
font-size: 90%;
|
||||
padding: 0.15em 0.4em 0.3em 0.4em;
|
||||
overflow: hidden;
|
||||
float: left;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.suggested-tags .small-cat {
|
||||
|
@ -17,6 +17,7 @@ from django.contrib.gis.measure import D
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
from django.urls import reverse
|
||||
from collections import Counter
|
||||
import emoji
|
||||
|
||||
from django.forms import formset_factory
|
||||
|
||||
@ -928,7 +929,7 @@ def event_search(request, full=False):
|
||||
categories = Category.objects.filter(name__icontains=request.GET['q'])
|
||||
s_q = remove_accents(request.GET['q'].lower())
|
||||
tags = Event.objects.extra(where=['%s ILIKE ANY (tags)'], params=[request.GET['q']]).annotate(arr_tags=Func(F('tags'), function='unnest')).values_list('arr_tags', flat=True).distinct()
|
||||
tags = [(t, remove_accents(t).lower()) for t in tags]
|
||||
tags = [(t, emoji.demojize(remove_accents(t).lower(), delimiters=('000', ''))) for t in tags]
|
||||
tags = [t for t in tags if s_q == t[1]]
|
||||
tags.sort(key=lambda x: x[1])
|
||||
tags = [t[0] for t in tags]
|
||||
@ -1886,7 +1887,7 @@ def tag_list(request):
|
||||
|
||||
tags = [t | {'obj': d_objects[t["tag"]]} if t["tag"] in d_objects else t for t in tags]
|
||||
|
||||
context = {"tags": sorted(tags, key=lambda x: remove_accents(x["tag"]).lower())}
|
||||
context = {"tags": sorted(tags, key=lambda x: emoji.demojize(remove_accents(x["tag"]).lower(), delimiters=('000', '')))}
|
||||
return render(request, "agenda_culturel/tags.html", context)
|
||||
|
||||
@login_required(login_url="/accounts/login/")
|
||||
|
@ -41,4 +41,5 @@ json5==0.9.25
|
||||
django-location-field==2.7.3
|
||||
django-robots==6.1
|
||||
django-debug-toolbar==4.4.6
|
||||
django-cache-cleaner==0.1.0
|
||||
django-cache-cleaner==0.1.0
|
||||
emoji==2.14.0
|
Loading…
Reference in New Issue
Block a user