TestingView post
This commit is contained in:
1 parent
b41bc76176
commit
8163de2c3a
1 file changed
+13
-9
+13
-9
@@ -272,15 +272,19 @@ class TestingView(generics.ListCreateAPIView):
|
||||
def post(self, request):
|
||||
"""create testing"""
|
||||
try:
|
||||
testing = Testing.objects.create(
|
||||
user=User.objects.get(user=DictEmployee.objects.get(id=request.data["user_id"])),
|
||||
test=Test.objects.get(id=request.data["test_id"]),
|
||||
datestart=request.data["datestart"],
|
||||
completion_date=request.data["completion_date"],
|
||||
test_passed=False,
|
||||
)
|
||||
if request.data.get("news"):
|
||||
self.create_news(request, testing)
|
||||
dictemployees = DictEmployee.objects.filter(id__in=request.data["user_id"])
|
||||
users = User.objects.filter(user__in=dictemployees).distinct()
|
||||
test = Test.objects.get(id=request.data["test_id"])
|
||||
for user in users:
|
||||
testing = Testing.objects.create(
|
||||
user=user,
|
||||
test=test,
|
||||
datestart=request.data["datestart"],
|
||||
completion_date=request.data["completion_date"],
|
||||
test_passed=False,
|
||||
)
|
||||
if request.data.get("news"):
|
||||
self.create_news(request, testing)
|
||||
return Response(
|
||||
{"status": "success", "message": "Testing created successfully."},
|
||||
status=200,
|
||||
|
||||
Reference in new issue
Block a user