Merge remote-tracking branch 'origin/main'

This commit is contained in:
Alexander Karpov 2022-10-22 22:30:06 +03:00
commit f823bcff62

View File

@ -1,6 +1,6 @@
from typing import List, Dict
from search.models import Product, Category, Characteristic
from search.models import Product, Category, Characteristic, UnitCharacteristic
def autocomplete_schema(val: str, exclude: List[Dict]):
@ -46,4 +46,15 @@ def autocomplete_schema(val: str, exclude: List[Dict]):
].values("name", "value")
]
)
schema.extend(
[
{
"coordinate": char["value"].lower().index(val.lower()),
"value": {
"type": char["name"] + "_numeric",
"value": char["value"]
}
} for char in UnitCharacteristic.objects.filter(value__unaccent__icontains=val)[:20].values("name", "value")
]
)
return schema