pedagogy: fix search api when searching one letter (case sensitivity)

This commit is contained in:
Antoine Bartuccio 2019-07-07 18:55:23 +02:00
parent 79243aece3
commit 30ccbdc32d
Signed by: klmp200
GPG Key ID: E7245548C53F904B
2 changed files with 5 additions and 1 deletions

View File

@ -616,6 +616,10 @@ class UVSearchTest(TestCase):
response = self.client.get(reverse("pedagogy:guide"), {"search": "P"})
self.assertContains(response, text="PA00")
# Search with first letter of UV code in lowercase
response = self.client.get(reverse("pedagogy:guide"), {"search": "p"})
self.assertContains(response, text="PA00")
# Search with UV manager
response = self.client.get(reverse("pedagogy:guide"), {"search": "HEYBERGER"})
self.assertContains(response, text="PA00")

View File

@ -194,7 +194,7 @@ class UVListView(CanViewMixin, CanCreateUVFunctionMixin, ListView):
if len(search) == 1:
# It's a search with only one letter
# Hastack doesn't work well with only one letter
return queryset.filter(code__startswith=search)
return queryset.filter(code__istartswith=search)
try:
qs = (