TestingView get

This commit is contained in:
cja committed 2025-05-29 14:25:25 +03:00
1 parent 755b5d98ce
commit 94a7485f42
1 file changed
+7 -3
+7 -3
View File
@@ -227,13 +227,17 @@ class TestingView(generics.ListCreateAPIView):
)
def get(self, request):
"""Get all testing records for a test"""
user = request.user
test_id = request.query_params.get('test_id')
try:
if test_id:
testings = Testing.objects.filter(test_id=test_id).select_related('user__user')
testings = Testing.objects.filter(test_id=test_id,
is_active=True,
user=user).select_related('user__user')
else:
testings = Testing.objects.all().select_related('user__user')
testings = Testing.objects.filter(is_active=True,
user=user).select_related('user__user')
serializer = self.get_serializer(testings, many=True)
return Response(serializer.data)
except DatabaseError as e: