Skip to content

Commit

Permalink
filter from public files without spectrograms
Browse files Browse the repository at this point in the history
  • Loading branch information
BryonLewis committed Feb 21, 2024
1 parent ebca4c5 commit 88544c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bats_ai/core/views/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 88544c3

Please sign in to comment.