created api for student application in csv
Signed-off-by: Saloni Singh <ymss1601@gmail.com>
This commit is contained in:
parent
41c5b0e934
commit
1a6a31cc5b
|
@ -3,10 +3,6 @@ from .models import *
|
||||||
|
|
||||||
admin.site.register(User)
|
admin.site.register(User)
|
||||||
admin.site.register(Student)
|
admin.site.register(Student)
|
||||||
admin.site.register(PR)
|
|
||||||
admin.site.register(Company)
|
|
||||||
admin.site.register(Placement)
|
admin.site.register(Placement)
|
||||||
admin.site.register(Internship)
|
|
||||||
admin.site.register(PlacementApplication)
|
admin.site.register(PlacementApplication)
|
||||||
admin.site.register(InternshipApplication)
|
|
||||||
admin.site.register(PrePlacementOffer)
|
admin.site.register(PrePlacementOffer)
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
from django.shortcuts import render,redirect
|
||||||
|
from .models import PlacementApplication
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from .utils import *
|
||||||
|
|
||||||
|
import csv
|
||||||
|
|
||||||
|
@api_view(['POST'])
|
||||||
|
@isAuthorized(allowed_users=[ADMIN])
|
||||||
|
@precheck(required_data=[COL_NAMES, OPENING_ID])
|
||||||
|
def generateCSV(request, id, email, user_type):
|
||||||
|
try:
|
||||||
|
data = request.data
|
||||||
|
applications=PlacementApplication.objects.filter(placement_id = data[OPENING_ID])
|
||||||
|
f = open('../Storage/', 'w')
|
||||||
|
writer = csv.writer(f)
|
||||||
|
writer.writerow(COL_NAMES)
|
||||||
|
for apl in applications:
|
||||||
|
row_details=[]
|
||||||
|
for col in COL_NAMES:
|
||||||
|
if col== ROLL_NO:
|
||||||
|
row_details.append(apl.student.roll_no)
|
||||||
|
if col== NAME:
|
||||||
|
row_details.append(apl.student.name)
|
||||||
|
if col== BATCH:
|
||||||
|
row_details.append(apl.student.batch)
|
||||||
|
if col== BRANCH:
|
||||||
|
row_details.append(apl.student.branch)
|
||||||
|
if col== PHONE_NUMBER:
|
||||||
|
row_details.append(apl.student.phone_number)
|
||||||
|
if col== CPI:
|
||||||
|
row_details.append(apl.student.cpi)
|
||||||
|
if col== RESUME:
|
||||||
|
row_details.append(apl.student.resume)
|
||||||
|
writer.writerow(apl)
|
||||||
|
except:
|
||||||
|
logger.warning("Delete Resume: " + str(sys.exc_info()))
|
||||||
|
return Response({'action': "Delete Resume", 'message': "Error Occurred {0}".format(
|
||||||
|
str(sys.exc_info()))},
|
||||||
|
status=status.HTTP_400_BAD_REQUEST)
|
|
@ -41,6 +41,7 @@ COMPANY = ''
|
||||||
|
|
||||||
STORAGE_DESTINATION = "./Storage/Resumes/"
|
STORAGE_DESTINATION = "./Storage/Resumes/"
|
||||||
STORAGE_DESTINATION_COMPANY_ATTACHMENTS = './Storage/Company_Attachments/'
|
STORAGE_DESTINATION_COMPANY_ATTACHMENTS = './Storage/Company_Attachments/'
|
||||||
|
STORAGE_DESTINATION_APPLICATION_CSV = './Storage/Application_CSV'
|
||||||
|
|
||||||
RESUME_FILE_NAME = 'resume_file_name'
|
RESUME_FILE_NAME = 'resume_file_name'
|
||||||
|
|
||||||
|
@ -93,3 +94,11 @@ COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT = "Notification Submitted - {id} - CD
|
||||||
|
|
||||||
STUDENT_APPLICATION_SUBMITTED_TEMPLATE = 'student_application_submitted.html'
|
STUDENT_APPLICATION_SUBMITTED_TEMPLATE = 'student_application_submitted.html'
|
||||||
COMPANY_OPENING_SUBMITTED_TEMPLATE = 'company_opening_submitted.html'
|
COMPANY_OPENING_SUBMITTED_TEMPLATE = 'company_opening_submitted.html'
|
||||||
|
|
||||||
|
COL_NAMES = "col_names"
|
||||||
|
ROLL_NO = "roll_no"
|
||||||
|
NAME = 'name'
|
||||||
|
BATCH = "batch"
|
||||||
|
BRANCH = "branch"
|
||||||
|
CPI = "cpi"
|
||||||
|
RESUME = "resume"
|
||||||
|
|
|
@ -101,4 +101,4 @@ class PrePlacementOffer(models.Model):
|
||||||
compensation_details = models.CharField(blank=True, max_length=200)
|
compensation_details = models.CharField(blank=True, max_length=200)
|
||||||
tier = models.CharField(blank=False, choices=TIERS, max_length=10)
|
tier = models.CharField(blank=False, choices=TIERS, max_length=10)
|
||||||
designation = models.CharField(blank=False, max_length=25, default=None, null=True)
|
designation = models.CharField(blank=False, max_length=25, default=None, null=True)
|
||||||
accepted = models.BooleanField(default=None, null=True)
|
accepted = models.BooleanField(default=None, null=True)
|
|
@ -89,7 +89,7 @@ DATABASES = {
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
'NAME': 'cdc',
|
'NAME': 'cdc',
|
||||||
'USER': 'postgres',
|
'USER': 'postgres',
|
||||||
'PASSWORD': 'root',
|
'PASSWORD': 'postgres',
|
||||||
'HOST': 'localhost',
|
'HOST': 'localhost',
|
||||||
'PORT': '5432',
|
'PORT': '5432',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue