From 7979ea0f6604673e5ae5a72a02a0971a540e740d Mon Sep 17 00:00:00 2001 From: U039b Date: Mon, 8 Jan 2024 17:21:52 +0100 Subject: [PATCH] Fix error occurring when there is no collection attached to a team --- video_downloading_platform/core/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/video_downloading_platform/core/models.py b/video_downloading_platform/core/models.py index 1912e8e..03054af 100644 --- a/video_downloading_platform/core/models.py +++ b/video_downloading_platform/core/models.py @@ -249,7 +249,8 @@ def get_users_open_batches(user): teams = BatchTeam.get_my_teams_as_contrib(user).all() for team in teams: batch = team.batch.first() - _batches.append(batch.id) + if batch: + _batches.append(batch.id) _batches.extend([b.id for b in Batch._get_users_batches(user, Batch.OPEN).all()]) return Batch.objects.filter(id__in=_batches) @@ -275,7 +276,7 @@ def _get_users_batches(user, status): teams = BatchTeam.get_my_teams_as_contrib(user).all() for team in teams: batch = team.batch.first() - if batch.status == status: + if batch and batch.status == status: _batches.append(batch.id) _batches.extend([b.id for b in Batch.objects.filter(owner=user, status=status).all()]) _batches = list(set(_batches))