Skip to content

Commit

Permalink
fixex RegistrationAdmin search collation
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Oct 22, 2024
1 parent 597c960 commit 3ed2ace
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/aurora/registration/admin/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.contrib import messages
from django.core.cache import cache
from django.db.models import JSONField
from django.db.models.functions import Collate
from django.db.models.signals import post_delete, post_save
from django.db.transaction import atomic
from django.http import HttpResponse, HttpResponseRedirect
Expand Down Expand Up @@ -47,7 +48,7 @@ def can_export_data(request, obj, handler=None):


class RegistrationAdmin(ConcurrencyVersionAdmin, AdminAutoCompleteSearchMixin, SyncMixin, SmartModelAdmin):
search_fields = ("name", "title", "slug")
search_fields = ("name_deterministic", "title", "slug")
date_hierarchy = "start"
list_filter = (
"active",
Expand Down Expand Up @@ -102,7 +103,9 @@ class RegistrationAdmin(ConcurrencyVersionAdmin, AdminAutoCompleteSearchMixin, S
protocol_class = AuroraSyncRegistrationProtocol

def get_queryset(self, request):
return super().get_queryset(request).select_related("project", "project__organization")
return super().get_queryset(request).annotate(
name_deterministic=Collate("name", "und-x-icu"),
).select_related("project", "project__organization")

# def get_search_results(self, request, queryset, search_term):
# queryset, may_have_duplicates = super().get_search_results(request, queryset, search_term)
Expand Down Expand Up @@ -143,15 +146,15 @@ def media(self):
extra = "" if settings.DEBUG else ".min"
base = super().media
return (
VersionMedia(
js=[
"admin/js/vendor/jquery/jquery%s.js" % extra,
"admin/js/jquery.init.js",
"jquery.compat%s.js" % extra,
"clipboard%s.js" % extra,
]
)
+ base
VersionMedia(
js=[
"admin/js/vendor/jquery/jquery%s.js" % extra,
"admin/js/jquery.init.js",
"jquery.compat%s.js" % extra,
"clipboard%s.js" % extra,
]
)
+ base
)

@view(permission=can_export_data)
Expand Down

0 comments on commit 3ed2ace

Please sign in to comment.