TestingView put
This commit is contained in:
1 parent
bcd6c839e9
commit
cceb365563
1 file changed
+7
-7
@@ -295,14 +295,14 @@ class TestingView(generics.ListCreateAPIView):
|
||||
|
||||
def put(self, request):
|
||||
"""when removing testing from an employee"""
|
||||
testing_id = request.data.get("id")
|
||||
try:
|
||||
testing = Testing.objects.get(id=testing_id)
|
||||
testing.is_active = False
|
||||
testing.save()
|
||||
if testing.news is not None:
|
||||
Testing.objects.filter(news=testing.news).delete()
|
||||
testing.news.delete()
|
||||
testing_ids = request.data.get("id", [])
|
||||
Testing.objects.filter(id__in=testing_ids).update(is_active=False)
|
||||
news_ids = Testing.objects.filter(id__in=testing_ids
|
||||
).values_list('news_id', flat=True).distinct()
|
||||
news_ids_list = [nid for nid in news_ids if nid is not None]
|
||||
Testing.objects.filter(id__in=testing_ids).update(news=None)
|
||||
News.objects.filter(id__in=news_ids_list).delete()
|
||||
return Response({"status": "success", "message": "Testing is not active."},
|
||||
status=200)
|
||||
except DatabaseError as e:
|
||||
|
||||
Reference in new issue
Block a user