From 88544c3289b7e255617f59c9c12b6af533a5c601 Mon Sep 17 00:00:00 2001 From: Bryon Lewis Date: Wed, 21 Feb 2024 15:15:38 -0500 Subject: [PATCH] filter from public files without spectrograms --- bats_ai/core/views/recording.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bats_ai/core/views/recording.py b/bats_ai/core/views/recording.py index 2dda201..39202c2 100644 --- a/bats_ai/core/views/recording.py +++ b/bats_ai/core/views/recording.py @@ -5,6 +5,7 @@ from django.contrib.auth.models import User from django.contrib.gis.geos import Point from django.core.files.storage import default_storage +from django.db.models import Q from django.http import HttpRequest from ninja import File, Form, Schema from ninja.files import UploadedFile @@ -166,7 +167,11 @@ def delete_recording( def get_recordings(request: HttpRequest, public: bool | None = None): # Filter recordings based on the owner's id or public=True if public is not None and public: - recordings = Recording.objects.filter(public=True).exclude(owner=request.user).values() + recordings = ( + Recording.objects.filter(public=True) + .exclude(Q(owner=request.user) | Q(spectrogram__isnull=True)) + .values() + ) else: recordings = Recording.objects.filter(owner=request.user).values()