Merge branch 'dev-denzel' into cja_new

This commit is contained in:
cja committed 2025-05-28 09:56:10 +03:00
commit 86a44eb5ae
5 files changed
+161 -58

No files matched your search

+14 -1
View File
@@ -67,9 +67,22 @@ class TestSerializer(serializers.ModelSerializer):
class TestingSeriaizer(serializers.ModelSerializer):
user_details = serializers.SerializerMethodField()
def get_user_details(self, obj):
try:
dict_employee = obj.user.user
return {
'id': dict_employee.id,
'fio': dict_employee.fio,
'login': dict_employee.login
}
except:
return None
class Meta:
model = Testing
fields = '__all__'
fields = ['id', 'user', 'test', 'completion_date', 'test_passed', 'user_details']
class TestAttemptSerializer(serializers.ModelSerializer):
+2 -2
View File
@@ -232,9 +232,9 @@ class TestingView(generics.ListCreateAPIView):
test_id = request.query_params.get('test_id')
try:
if test_id:
testings = Testing.objects.filter(test_id=test_id)
testings = Testing.objects.filter(test_id=test_id).select_related('user__user')
else:
testings = Testing.objects.all()
testings = Testing.objects.all().select_related('user__user')
serializer = self.get_serializer(testings, many=True)
return Response(serializer.data)