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):
|
def put(self, request):
|
||||||
"""when removing testing from an employee"""
|
"""when removing testing from an employee"""
|
||||||
testing_id = request.data.get("id")
|
|
||||||
try:
|
try:
|
||||||
testing = Testing.objects.get(id=testing_id)
|
testing_ids = request.data.get("id", [])
|
||||||
testing.is_active = False
|
Testing.objects.filter(id__in=testing_ids).update(is_active=False)
|
||||||
testing.save()
|
news_ids = Testing.objects.filter(id__in=testing_ids
|
||||||
if testing.news is not None:
|
).values_list('news_id', flat=True).distinct()
|
||||||
Testing.objects.filter(news=testing.news).delete()
|
news_ids_list = [nid for nid in news_ids if nid is not None]
|
||||||
testing.news.delete()
|
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."},
|
return Response({"status": "success", "message": "Testing is not active."},
|
||||||
status=200)
|
status=200)
|
||||||
except DatabaseError as e:
|
except DatabaseError as e:
|
||||||
|
|||||||
Reference in new issue
Block a user