From 595461f33b4f48d79a04721a13a7d3ede485968a Mon Sep 17 00:00:00 2001 From: uttamthummala Date: Thu, 30 Nov 2023 11:37:12 +0530 Subject: [PATCH] removed-automated deadline --- CDC_Backend/APIs/adminViews.py | 11 +++-------- CDC_Backend/APIs/tests/test_adminView.py | 21 +-------------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/CDC_Backend/APIs/adminViews.py b/CDC_Backend/APIs/adminViews.py index 794d580..1edc0f0 100644 --- a/CDC_Backend/APIs/adminViews.py +++ b/CDC_Backend/APIs/adminViews.py @@ -124,7 +124,8 @@ def updateDeadline(request, id, email, user_type): opening.deadline_datetime = datetime.datetime.strptime(data[DEADLINE_DATETIME], '%Y-%m-%d %H:%M:%S %z') opening.changed_by = get_object_or_404(User, id=id) opening.save() - send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=data[DEADLINE_DATETIME],role=opening.designation,opening_type=opening_type) + if opening.offer_accepted: + send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=data[DEADLINE_DATETIME],role=opening.designation,opening_type=opening_type) return Response({'action': "Update Deadline", 'message': "Deadline Updated"}, status=status.HTTP_200_OK) except Http404: @@ -147,22 +148,16 @@ def updateOfferAccepted(request, id, email, user_type): opening_type= data[OPENING_TYPE] else: opening_type= "Placement" - if DEADLINE_DATETIME in data: - deadline_datetime = datetime.datetime.strptime(data[DEADLINE_DATETIME], '%Y-%m-%d %H:%M:%S %z') - else: - deadline_datetime = timezone.localtime(timezone.now()).replace(hour=0, minute=0, second=0, microsecond=0) + datetime.timedelta(days=2) if opening_type == "Internship": opening = get_object_or_404(Internship, pk=data[OPENING_ID]) else: opening = get_object_or_404(Placement, pk=data[OPENING_ID]) if opening.offer_accepted is None: opening.offer_accepted = offer_accepted == "true" - opening.deadline_datetime = deadline_datetime opening.changed_by = get_object_or_404(User, id=id) opening.save() if opening.offer_accepted: - deadline=deadline_datetime.strftime('%Y-%m-%d %H:%M:%S %z') - send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=deadline,role=opening.designation,opening_type=opening_type) + send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=opening.deadline_datetime,role=opening.designation,opening_type=opening_type) send_opening_notifications(opening.id,opening_type) else: raise ValueError("Offer Status already updated") diff --git a/CDC_Backend/APIs/tests/test_adminView.py b/CDC_Backend/APIs/tests/test_adminView.py index 68764e2..9826ae7 100644 --- a/CDC_Backend/APIs/tests/test_adminView.py +++ b/CDC_Backend/APIs/tests/test_adminView.py @@ -720,27 +720,8 @@ class AdminView(APITestCase): self.assertEqual(response.data['message'], 'Offer Accepted Updated') self.assertEqual(Placement.objects.get( id=self.placement1.id).offer_accepted, True) - self.assertEqual(Placement.objects.get( - id=self.placement1.id).deadline_datetime, timezone.localtime(timezone.now()).replace(hour=0, minute=0, second=0, microsecond=0)+timezone.timedelta(days=2)) + - def test_offerAccepted_withDeadline(self): - url = reverse("Update Offer Accepted") - data = { - "opening_type": "Placement", - "opening_id": self.placement3.id, - "offer_accepted": "true", - "deadline_datetime": (timezone.localtime(timezone.now()).replace( - hour=0, minute=0, second=0, microsecond=0)+timezone.timedelta(days=1)).strftime('%Y-%m-%d %H:%M:%S %z') - } - self.admin.user_type = ["s_admin"] - self.admin.save() - self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + self.token) - response = self.client.post(url, data=json.dumps( - data), content_type='application/json') - self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(Placement.objects.get( - id=self.placement3.id).deadline_datetime, timezone.localtime(timezone.now()).replace(hour=0, minute=0, second=0, microsecond=0)+timezone.timedelta(days=1)) - self.assertEqual(response.data['message'], 'Offer Accepted Updated') def test_offerAccepted_wrongOpening(self): url = reverse("Update Offer Accepted")