Fixed error in timezone
This commit is contained in:
parent
4734834ad5
commit
9e95da5e03
|
@ -4,6 +4,7 @@ from rest_framework.decorators import api_view
|
|||
|
||||
from .serializers import *
|
||||
from .utils import *
|
||||
import pytz
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
|
@ -124,7 +125,10 @@ 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()
|
||||
deadline=opening.deadline_datetime.strftime('%Y-%m-%d %H:%M:%S')
|
||||
deadline=opening.deadline_datetime
|
||||
itz=pytz.timezone('Asia/Kolkata')
|
||||
deadline=deadline.astimezone(itz)
|
||||
deadline=deadline.strftime('%Y-%m-%d %H:%M:%S')
|
||||
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"},
|
||||
status=status.HTTP_200_OK)
|
||||
|
@ -151,7 +155,7 @@ def updateOfferAccepted(request, id, email, user_type):
|
|||
if DEADLINE_DATETIME in data:
|
||||
deadline_datetime = datetime.datetime.strptime(data[DEADLINE_DATETIME], '%Y-%m-%d %H:%M:%S %z')
|
||||
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":
|
||||
opening = get_object_or_404(Internship, pk=data[OPENING_ID])
|
||||
else:
|
||||
|
|
|
@ -109,7 +109,7 @@ def getDashboard(request, id, email, user_type):
|
|||
|
||||
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
|
||||
internships = Internship.objects.filter(allowed_batch__contains=[studentDetails.batch],
|
||||
allowed_branch__contains=[studentDetails.branch],
|
||||
|
@ -119,7 +119,7 @@ def getDashboard(request, id, email, user_type):
|
|||
filtered_internships = internship_eligibility_filters(studentDetails, internships)
|
||||
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
|
||||
return Response(
|
||||
{'action': "Get Dashboard - Student", 'message': "Data Found", "placements": placementsdata,
|
||||
|
|
|
@ -721,7 +721,7 @@ class AdminView(APITestCase):
|
|||
self.assertEqual(Placement.objects.get(
|
||||
id=self.placement1.id).offer_accepted, True)
|
||||
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):
|
||||
url = reverse("Update Offer Accepted")
|
||||
|
@ -729,7 +729,7 @@ class AdminView(APITestCase):
|
|||
"opening_type": "Placement",
|
||||
"opening_id": self.placement3.id,
|
||||
"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')
|
||||
}
|
||||
self.admin.user_type = ["s_admin"]
|
||||
|
@ -739,7 +739,7 @@ class AdminView(APITestCase):
|
|||
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.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')
|
||||
|
||||
def test_offerAccepted_wrongOpening(self):
|
||||
|
|
|
@ -481,11 +481,11 @@ def get_eligible_emails(opening_id, opening_type=PLACEMENT):
|
|||
emails.append(student_user.email)
|
||||
except Exception as e:
|
||||
logger.warning('Utils - send_opening_notifications: For Loop' + str(e))
|
||||
return False
|
||||
return False, []
|
||||
return True, emails
|
||||
except:
|
||||
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
|
||||
return False
|
||||
return False, []
|
||||
|
||||
def exception_email(opening):
|
||||
opening = opening.dict()
|
||||
|
|
Loading…
Reference in New Issue