manager: search role with unaccent lookup (#87906)
gitea/authentic/pipeline/head This commit looks good Details

This commit is contained in:
Thomas NOËL 2024-03-08 12:02:35 +01:00
parent a03e111bab
commit cdf52169c9
2 changed files with 7 additions and 2 deletions

View File

@ -405,7 +405,7 @@ class ServiceRoleSearchForm(CssClass, PrefixFormMixin, FormWithRequest):
for word in (w.strip() for w in self.cleaned_data.get('text').split(' ')):
if not word:
continue
qs = qs.filter(name__icontains=word)
qs = qs.filter(name__unaccent__icontains=word)
if not app_settings.SHOW_INTERNAL_ROLES and not self.cleaned_data.get('internals'):
qs = qs.exclude(slug__startswith='_')
return qs

View File

@ -390,7 +390,7 @@ def test_manager_role_csv_import(app, admin, ou1, ou2):
'role_names,search_text,expt_found',
[
(
['A random test role', 'Random test stuff', 'Some test role', 'Something else', 'SomeTest'],
['A random test rôle', 'Random test stuff', 'Some test role', 'Something else', 'SomeTest'],
' rand role',
[0],
),
@ -419,6 +419,11 @@ def test_manager_role_csv_import(app, admin, ou1, ou2):
' ',
[0, 1, 2, 3, 4],
),
(
['A random test role', 'Random test stuff', 'Some test role', 'Something else', 'SomeTest'],
'rôle',
[0, 2],
),
],
)
def test_manager_role_search(app, admin, role_names, search_text, expt_found):