Skip to content

Commit

Permalink
fix backend lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrieuclp committed Dec 23, 2024
1 parent 98dc948 commit 6751cc1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backend/geonature/core/gn_meta/models/aframework.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,20 @@ def filter_by_params(cls, params={}, *, _ds_search=True, query=None):

search = params.get("search")
if search:
#si uniquement des chiffres (chercher dans ID ou name)
# si uniquement des chiffres (chercher dans ID ou name)
if search.isdigit():
ors = [
func.unaccent(TAcquisitionFramework.acquisition_framework_name).ilike(func.unaccent(f"%{search}%")),
sa.cast(TAcquisitionFramework.id_acquisition_framework, sa.String) == search,
]
else:
#sinon découpe sur les espaces pour rechercher dans le nom
# sinon découpe sur les espaces pour rechercher dans le nom
ands = [];
for term in search.split(" "):
if len(term) > 0:
ands.append(func.unaccent(TAcquisitionFramework.acquisition_framework_name).ilike(func.unaccent(f"%{term}%")))
ands.append(
func.unaccent(TAcquisitionFramework.acquisition_framework_name).ilike(func.unaccent(f"%{term}%"))
)
ors = [sa.and_(*ands)]
# enable uuid search only with at least 5 characters
if len(search) >= 5:
Expand Down

0 comments on commit 6751cc1

Please sign in to comment.