requested changes made

This commit is contained in:
Saloni Singh 2021-10-31 18:50:57 +05:30
parent 83add9883d
commit bec6910c64
1 changed files with 5 additions and 4 deletions

View File

@ -12,8 +12,9 @@ def generateCSV(request, id, email, user_type):
try: try:
data = request.data data = request.data
applications=PlacementApplication.objects.filter(placement_id = data[OPENING_ID]) applications=PlacementApplication.objects.filter(placement_id = data[OPENING_ID])
f = open('../Storage/', 'w')
filename = generateRandomString() filename = generateRandomString()
destination_path = STORAGE_DESTINATION_APPLICATION_CSV + filename
f = open(destination_path, 'w')
writer = csv.writer(f) writer = csv.writer(f)
writer.writerow(COL_NAMES) writer.writerow(COL_NAMES)
for apl in applications: for apl in applications:
@ -34,10 +35,10 @@ def generateCSV(request, id, email, user_type):
if col == RESUME: if col == RESUME:
row_details.append(apl.student.resume) row_details.append(apl.student.resume)
writer.writerow(apl) writer.writerow(apl)
f.close()
return Response({'action': "Create csv", 'message': "CSV created", 'file': filename}, return Response({'action': "Create csv", 'message': "CSV created", 'file': filename},
status=status.HTTP_200_OK) status=status.HTTP_200_OK)
except: except:
logger.warning("Delete Resume: " + str(sys.exc_info())) logger.warning("Create csv: " + str(sys.exc_info()))
return Response({'action': "Delete Resume", 'message': "Error Occurred {0}".format( return Response({'action': "Create csv", 'message': "Error Occurred"},
str(sys.exc_info()))},
status=status.HTTP_400_BAD_REQUEST) status=status.HTTP_400_BAD_REQUEST)