added response
Signed-off-by: Saloni Singh <ymss1601@gmail.com>
This commit is contained in:
parent
1a6a31cc5b
commit
bd0e0cce15
|
@ -13,26 +13,29 @@ def generateCSV(request, id, email, user_type):
|
||||||
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')
|
f = open('../Storage/', 'w')
|
||||||
|
filename = generateRandomString()
|
||||||
writer = csv.writer(f)
|
writer = csv.writer(f)
|
||||||
writer.writerow(COL_NAMES)
|
writer.writerow(COL_NAMES)
|
||||||
for apl in applications:
|
for apl in applications:
|
||||||
row_details=[]
|
row_details=[]
|
||||||
for col in COL_NAMES:
|
for col in COL_NAMES:
|
||||||
if col== ROLL_NO:
|
if col == ROLL_NO:
|
||||||
row_details.append(apl.student.roll_no)
|
row_details.append(apl.student.roll_no)
|
||||||
if col== NAME:
|
if col == NAME:
|
||||||
row_details.append(apl.student.name)
|
row_details.append(apl.student.name)
|
||||||
if col== BATCH:
|
if col == BATCH:
|
||||||
row_details.append(apl.student.batch)
|
row_details.append(apl.student.batch)
|
||||||
if col== BRANCH:
|
if col == BRANCH:
|
||||||
row_details.append(apl.student.branch)
|
row_details.append(apl.student.branch)
|
||||||
if col== PHONE_NUMBER:
|
if col == PHONE_NUMBER:
|
||||||
row_details.append(apl.student.phone_number)
|
row_details.append(apl.student.phone_number)
|
||||||
if col== CPI:
|
if col == CPI:
|
||||||
row_details.append(apl.student.cpi)
|
row_details.append(apl.student.cpi)
|
||||||
if col== RESUME:
|
if col == RESUME:
|
||||||
row_details.append(apl.student.resume)
|
row_details.append(apl.student.resume)
|
||||||
writer.writerow(apl)
|
writer.writerow(apl)
|
||||||
|
return Response({'action': "Create csv", 'message': "CSV created", 'file': filename},
|
||||||
|
status=status.HTTP_200_OK)
|
||||||
except:
|
except:
|
||||||
logger.warning("Delete Resume: " + str(sys.exc_info()))
|
logger.warning("Delete Resume: " + str(sys.exc_info()))
|
||||||
return Response({'action': "Delete Resume", 'message': "Error Occurred {0}".format(
|
return Response({'action': "Delete Resume", 'message': "Error Occurred {0}".format(
|
||||||
|
|
Loading…
Reference in New Issue