Merge pull request #194 from CDC-IITDH/removed-automated-deadline

removed-automated deadline
This commit is contained in:
karthik mv 2023-12-07 03:24:27 +05:30 committed by GitHub
commit 9447654979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 51 deletions

View File

@ -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,17 @@ 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)
deadline_datetime = datetime.datetime.strftime(opening.deadline_datetime, '%Y-%m-%d %H:%M:%S %z')
send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=deadline_datetime,role=opening.designation,opening_type=opening_type)
send_opening_notifications(opening.id,opening_type)
else:
raise ValueError("Offer Status already updated")

View File

@ -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")
@ -1199,28 +1180,7 @@ class AdminView(APITestCase):
self.assertEqual(Internship.objects.get(
id=self.internship1.id).offer_accepted, True)
self.internship1.refresh_from_db()
self.assertEqual(self.internship1.deadline_datetime, timezone.localtime(timezone.now()).replace(
hour=0, minute=0, second=0, microsecond=0)+timezone.timedelta(days=2))
def test_updateofferAccepted_withDeadline_internship(self):
url = reverse("Update Offer Accepted")
data = {
"opening_type": "Internship",
"opening_id": self.internship3.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.internship3.refresh_from_db()
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(Internship.objects.get(
id=self.internship3.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_updateofferAccepted_wrongOpening_internship(self):
url = reverse("Update Offer Accepted")