rename mabras -> marbas, fix not condition in search, allow page_size for pagination

This commit was merged in pull request #4.
This commit is contained in:
2023-10-29 22:01:38 +01:00
parent ffbf548c7a
commit 20c5aa9ee5
12 changed files with 36 additions and 32 deletions

View File

@@ -42,24 +42,21 @@ def custom_types_search(request):
items = []
for q in request.data:
condition = Q()
conditions = Q()
for k in q.keys():
value = q[k]
token = k.split('___')
key, mods = token[0], token[1:]
if "i" in mods:
condition = condition & Q(**{key + '__icontains': value})
elif "in" in mods:
condition = condition & Q(**{key + '__in': value})
else:
condition = condition & Q(**{key: value})
cond = Q(**{key: value})
if "not" in mods:
condition = ~condition
cond = ~cond
items.extend(sde_models.SDEType.objects.filter(condition))
conditions = conditions & cond
items.extend(sde_models.SDEType.objects.filter(conditions))
paginator = settings.api_settings.DEFAULT_PAGINATION_CLASS()
result_page = paginator.paginate_queryset(items, request)