Merge pull request #181 from CDC-IITDH:Fixed-timezone-errors
Fixed error in timezone
This commit is contained in:
commit
10050cc4e9
|
@ -124,8 +124,7 @@ 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()
|
||||||
deadline=opening.deadline_datetime.strftime('%Y-%m-%d %H:%M:%S')
|
send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=data[DEADLINE_DATETIME],role=opening.designation)
|
||||||
send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=deadline,role=opening.designation)
|
|
||||||
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:
|
||||||
|
@ -151,7 +150,7 @@ def updateOfferAccepted(request, id, email, user_type):
|
||||||
if DEADLINE_DATETIME in data:
|
if DEADLINE_DATETIME in data:
|
||||||
deadline_datetime = datetime.datetime.strptime(data[DEADLINE_DATETIME], '%Y-%m-%d %H:%M:%S %z')
|
deadline_datetime = datetime.datetime.strptime(data[DEADLINE_DATETIME], '%Y-%m-%d %H:%M:%S %z')
|
||||||
else:
|
else:
|
||||||
deadline_datetime = timezone.now().replace(hour=0, minute=0, second=0, microsecond=0) + datetime.timedelta(days=2)
|
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:
|
||||||
|
@ -162,7 +161,7 @@ def updateOfferAccepted(request, id, email, user_type):
|
||||||
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')
|
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)
|
send_opening_to_notifications_service(id=opening.id,name=opening.company_name,deadline=deadline,role=opening.designation)
|
||||||
send_opening_notifications(opening.id,opening_type)
|
send_opening_notifications(opening.id,opening_type)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -109,7 +109,7 @@ def getDashboard(request, id, email, user_type):
|
||||||
|
|
||||||
placementsdata = PlacementSerializerForStudent(filtered_placements, many=True).data
|
placementsdata = PlacementSerializerForStudent(filtered_placements, many=True).data
|
||||||
|
|
||||||
placementApplications = PlacementApplication.objects.filter(student_id=id)
|
placementApplications = PlacementApplication.objects.filter(student_id=id).order_by('-updated_at')
|
||||||
placementApplications = PlacementApplicationSerializer(placementApplications, many=True).data
|
placementApplications = PlacementApplicationSerializer(placementApplications, many=True).data
|
||||||
internships = Internship.objects.filter(allowed_batch__contains=[studentDetails.batch],
|
internships = Internship.objects.filter(allowed_batch__contains=[studentDetails.batch],
|
||||||
allowed_branch__contains=[studentDetails.branch],
|
allowed_branch__contains=[studentDetails.branch],
|
||||||
|
@ -119,7 +119,7 @@ def getDashboard(request, id, email, user_type):
|
||||||
filtered_internships = internship_eligibility_filters(studentDetails, internships)
|
filtered_internships = internship_eligibility_filters(studentDetails, internships)
|
||||||
internshipsdata = InternshipSerializerForStudent(filtered_internships, many=True).data
|
internshipsdata = InternshipSerializerForStudent(filtered_internships, many=True).data
|
||||||
|
|
||||||
internshipApplications = InternshipApplication.objects.filter(student_id=id)
|
internshipApplications = InternshipApplication.objects.filter(student_id=id).order_by('-updated_at')
|
||||||
internshipApplications = InternshipApplicationSerializer(internshipApplications, many=True).data
|
internshipApplications = InternshipApplicationSerializer(internshipApplications, many=True).data
|
||||||
return Response(
|
return Response(
|
||||||
{'action': "Get Dashboard - Student", 'message': "Data Found", "placements": placementsdata,
|
{'action': "Get Dashboard - Student", 'message': "Data Found", "placements": placementsdata,
|
||||||
|
|
|
@ -721,7 +721,7 @@ class AdminView(APITestCase):
|
||||||
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(
|
self.assertEqual(Placement.objects.get(
|
||||||
id=self.placement1.id).deadline_datetime, timezone.now().replace(hour=0, minute=0, second=0, microsecond=0)+timezone.timedelta(days=2))
|
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):
|
def test_offerAccepted_withDeadline(self):
|
||||||
url = reverse("Update Offer Accepted")
|
url = reverse("Update Offer Accepted")
|
||||||
|
@ -729,7 +729,7 @@ class AdminView(APITestCase):
|
||||||
"opening_type": "Placement",
|
"opening_type": "Placement",
|
||||||
"opening_id": self.placement3.id,
|
"opening_id": self.placement3.id,
|
||||||
"offer_accepted": "true",
|
"offer_accepted": "true",
|
||||||
"deadline_datetime": (timezone.now().replace(
|
"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')
|
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.user_type = ["s_admin"]
|
||||||
|
@ -739,7 +739,7 @@ class AdminView(APITestCase):
|
||||||
data), content_type='application/json')
|
data), content_type='application/json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(Placement.objects.get(
|
self.assertEqual(Placement.objects.get(
|
||||||
id=self.placement3.id).deadline_datetime, timezone.now().replace(hour=0, minute=0, second=0, microsecond=0)+timezone.timedelta(days=1))
|
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')
|
self.assertEqual(response.data['message'], 'Offer Accepted Updated')
|
||||||
|
|
||||||
def test_offerAccepted_wrongOpening(self):
|
def test_offerAccepted_wrongOpening(self):
|
||||||
|
@ -1199,7 +1199,7 @@ class AdminView(APITestCase):
|
||||||
self.assertEqual(Internship.objects.get(
|
self.assertEqual(Internship.objects.get(
|
||||||
id=self.internship1.id).offer_accepted, True)
|
id=self.internship1.id).offer_accepted, True)
|
||||||
self.internship1.refresh_from_db()
|
self.internship1.refresh_from_db()
|
||||||
self.assertEqual(self.internship1.deadline_datetime, timezone.now().replace(
|
self.assertEqual(self.internship1.deadline_datetime, timezone.localtime(timezone.now()).replace(
|
||||||
hour=0, minute=0, second=0, microsecond=0)+timezone.timedelta(days=2))
|
hour=0, minute=0, second=0, microsecond=0)+timezone.timedelta(days=2))
|
||||||
|
|
||||||
def test_updateofferAccepted_withDeadline_internship(self):
|
def test_updateofferAccepted_withDeadline_internship(self):
|
||||||
|
@ -1208,7 +1208,7 @@ class AdminView(APITestCase):
|
||||||
"opening_type": "Internship",
|
"opening_type": "Internship",
|
||||||
"opening_id": self.internship3.id,
|
"opening_id": self.internship3.id,
|
||||||
"offer_accepted": "true",
|
"offer_accepted": "true",
|
||||||
"deadline_datetime": (timezone.now().replace(
|
"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')
|
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.user_type = ["s_admin"]
|
||||||
|
@ -1219,7 +1219,7 @@ class AdminView(APITestCase):
|
||||||
self.internship3.refresh_from_db()
|
self.internship3.refresh_from_db()
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(Internship.objects.get(
|
self.assertEqual(Internship.objects.get(
|
||||||
id=self.internship3.id).deadline_datetime, timezone.now().replace(hour=0, minute=0, second=0, microsecond=0)+timezone.timedelta(days=1))
|
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')
|
self.assertEqual(response.data['message'], 'Offer Accepted Updated')
|
||||||
|
|
||||||
def test_updateofferAccepted_wrongOpening_internship(self):
|
def test_updateofferAccepted_wrongOpening_internship(self):
|
||||||
|
|
|
@ -481,11 +481,11 @@ def get_eligible_emails(opening_id, opening_type=PLACEMENT):
|
||||||
emails.append(student_user.email)
|
emails.append(student_user.email)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning('Utils - send_opening_notifications: For Loop' + str(e))
|
logger.warning('Utils - send_opening_notifications: For Loop' + str(e))
|
||||||
return False
|
return False, []
|
||||||
return True, emails
|
return True, emails
|
||||||
except:
|
except:
|
||||||
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
|
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
|
||||||
return False
|
return False, []
|
||||||
|
|
||||||
def exception_email(opening):
|
def exception_email(opening):
|
||||||
opening = opening.dict()
|
opening = opening.dict()
|
||||||
|
|
Loading…
Reference in New Issue