mirror of
https://github.com/narrrl/holy-flavor-rater.git
synced 2026-11-03 16:41:27 +01:00
Merge branch 'main' into narl.io
This commit is contained in:
commit
1976f9e1c2
2 files changed
+6
-3
No files matched your search
@@ -18,12 +18,12 @@ class FlavorViewSet(viewsets.ModelViewSet):
|
||||
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
|
||||
|
||||
def get_queryset(self):
|
||||
return Flavor.objects.select_related('category').annotate(average_rating=Avg('ratings__score')).order_by('-average_rating')
|
||||
return Flavor.objects.select_related('category').annotate(average_rating=Avg('ratings__score')).order_by('-average_rating').distinct()
|
||||
|
||||
@action(detail=False, methods=['get'], permission_classes=[permissions.AllowAny])
|
||||
def search(self, request):
|
||||
# Unpaginated list of all flavors for the search autocomplete
|
||||
flavors = Flavor.objects.select_related('category').order_by('name')
|
||||
flavors = Flavor.objects.select_related('category').order_by('name').distinct()
|
||||
data = [
|
||||
{
|
||||
'id': f.id,
|
||||
|
||||
@@ -88,7 +88,10 @@ const GlobalSearch = () => {
|
||||
freeSolo
|
||||
size="small"
|
||||
options={options}
|
||||
getOptionLabel={(option) => typeof option === 'string' ? option : (option.name || '')}
|
||||
getOptionLabel={(option) => {
|
||||
if (typeof option === 'string') return option;
|
||||
return option.category_name ? `${option.name} (${option.category_name})` : (option.name || '');
|
||||
}}
|
||||
inputValue={query}
|
||||
onInputChange={(_, newValue) => setQuery(typeof newValue === 'string' ? newValue : '')}
|
||||
onChange={(_, newValue) => {
|
||||
|
||||
Reference in new issue
Block a user