removed-automated deadline
This commit is contained in:
parent
b3f9e2835d
commit
595461f33b
|
@ -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.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.changed_by = get_object_or_404(User, id=id)
|
||||||
opening.save()
|
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"},
|
return Response({'action': "Update Deadline", 'message': "Deadline Updated"},
|
||||||
status=status.HTTP_200_OK)
|
status=status.HTTP_200_OK)
|
||||||
except Http404:
|
except Http404:
|
||||||
|
@ -147,22 +148,16 @@ def updateOfferAccepted(request, id, email, user_type):
|
||||||
opening_type= data[OPENING_TYPE]
|
opening_type= data[OPENING_TYPE]
|
||||||
else:
|
else:
|
||||||
opening_type= "Placement"
|
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":
|
if opening_type == "Internship":
|
||||||
opening = get_object_or_404(Internship, pk=data[OPENING_ID])
|
opening = get_object_or_404(Internship, pk=data[OPENING_ID])
|
||||||
else:
|
else:
|
||||||
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
||||||
if opening.offer_accepted is None:
|
if opening.offer_accepted is None:
|
||||||
opening.offer_accepted = offer_accepted == "true"
|
opening.offer_accepted = offer_accepted == "true"
|
||||||
opening.deadline_datetime = deadline_datetime
|
|
||||||
opening.changed_by = get_object_or_404(User, id=id)
|
opening.changed_by = get_object_or_404(User, id=id)
|
||||||
opening.save()
|
opening.save()
|
||||||
if opening.offer_accepted:
|
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=opening.deadline_datetime,role=opening.designation,opening_type=opening_type)
|
||||||
send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=deadline,role=opening.designation,opening_type=opening_type)
|
|
||||||
send_opening_notifications(opening.id,opening_type)
|
send_opening_notifications(opening.id,opening_type)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Offer Status already updated")
|
raise ValueError("Offer Status already updated")
|
||||||
|
|
|
@ -720,27 +720,8 @@ class AdminView(APITestCase):
|
||||||
self.assertEqual(response.data['message'], 'Offer Accepted Updated')
|
self.assertEqual(response.data['message'], 'Offer Accepted Updated')
|
||||||
self.assertEqual(Placement.objects.get(
|
self.assertEqual(Placement.objects.get(
|
||||||
id=self.placement1.id).offer_accepted, True)
|
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):
|
def test_offerAccepted_wrongOpening(self):
|
||||||
url = reverse("Update Offer Accepted")
|
url = reverse("Update Offer Accepted")
|
||||||
|
|
Loading…
Reference in New Issue