Created MarkStatus API
This commit is contained in:
parent
587662a154
commit
1b20454f35
|
@ -1,7 +1,8 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from . import companyViews
|
from . import adminViews
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path('markStatus/', adminViews.markStatus, name="Mark Status"),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
from .utils import *
|
||||||
|
from rest_framework.decorators import api_view
|
||||||
|
|
||||||
|
|
||||||
|
@api_view(['POST'])
|
||||||
|
@isAuthorized([ADMIN])
|
||||||
|
@precheck([OPENING_ID, STUDENT_LIST])
|
||||||
|
def markStatus(request, id, email, user_type):
|
||||||
|
try:
|
||||||
|
data = request.data
|
||||||
|
applications = PlacementApplication.objects.filter(placement_id=data[OPENING_ID]) # Getting All
|
||||||
|
# application form db for this opening
|
||||||
|
for i in data[STUDENT_LIST]:
|
||||||
|
application = applications.filter(student_id=i[STUDENT_ID]) # Filtering student's application
|
||||||
|
if len(application) > 0:
|
||||||
|
application = application[0]
|
||||||
|
application.selected = i[STUDENT_STATUS]
|
||||||
|
application.save()
|
||||||
|
email = application.student.roll_no + "@iitdh.ac.in" # Only allowing for IITDh emails
|
||||||
|
subject = STUDENT_APPLICATION_STATUS_TEMPLATE_SUBJECT.format(company_name=application.placement.name,
|
||||||
|
id=application.id)
|
||||||
|
data = {
|
||||||
|
"company_name": application.placement.name,
|
||||||
|
"designation": application.placement.designation,
|
||||||
|
"student_name": application.student.name
|
||||||
|
}
|
||||||
|
if application.selected: # Sending corresponding email to students
|
||||||
|
sendEmail(email, subject, data, STUDENT_APPLICATION_STATUS_SELECTED_TEMPLATE)
|
||||||
|
# This one needs to be created
|
||||||
|
else:
|
||||||
|
sendEmail(email, subject, data, STUDENT_APPLICATION_STATUS_NOT_SELECTED_TEMPLATE)
|
||||||
|
# This one needs to be created
|
||||||
|
else:
|
||||||
|
raise ValueError("Student - " + i[STUDENT_ID] + " didn't apply for this opening")
|
||||||
|
except ValueError as e:
|
||||||
|
return Response({'action': "Mark Selected", 'message': str(e)},
|
||||||
|
status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
except:
|
||||||
|
logger.warning("Mark Status: " + str(sys.exc_info()))
|
||||||
|
return Response({'action': "Mark Stauts", 'message': "Error Occurred!"},
|
||||||
|
status=status.HTTP_400_BAD_REQUEST)
|
|
@ -26,7 +26,6 @@ TIERS = [
|
||||||
['6', 'Tier 6']
|
['6', 'Tier 6']
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
TOTAL_BRANCHES = 3 # Total No of Branches
|
TOTAL_BRANCHES = 3 # Total No of Branches
|
||||||
TOTAL_BATCHES = 4 # Total No of Batches
|
TOTAL_BATCHES = 4 # Total No of Batches
|
||||||
|
|
||||||
|
@ -38,15 +37,16 @@ EMAIL = "email"
|
||||||
STUDENT = 'student'
|
STUDENT = 'student'
|
||||||
ADMIN = 'Admin'
|
ADMIN = 'Admin'
|
||||||
COMPANY = ''
|
COMPANY = ''
|
||||||
|
|
||||||
STORAGE_DESTINATION = "./Storage/Resumes/"
|
STORAGE_DESTINATION = "./Storage/Resumes/"
|
||||||
STORAGE_DESTINATION_COMPANY_ATTACHMENTS = './Storage/Company_Attachments/'
|
STORAGE_DESTINATION_COMPANY_ATTACHMENTS = './Storage/Company_Attachments/'
|
||||||
|
|
||||||
RESUME_FILE_NAME = 'resume_file_name'
|
RESUME_FILE_NAME = 'resume_file_name'
|
||||||
|
|
||||||
APPLICATION_ID = "application_id"
|
APPLICATION_ID = "application_id"
|
||||||
APPLICATION_OPENING_TYPE = "opening_type"
|
OPENING_ID = "opening_id"
|
||||||
APPLICATION_OPENING_ID = "opening_id"
|
STUDENT_ID = "student_id"
|
||||||
APPLICATION_ADDITIONAL_INFO = "additional_info"
|
ADDITIONAL_INFO = "additional_info"
|
||||||
|
|
||||||
STATUS_ACCEPTING_APPLICATIONS = "Accepting Applications"
|
STATUS_ACCEPTING_APPLICATIONS = "Accepting Applications"
|
||||||
|
|
||||||
|
@ -54,25 +54,27 @@ PLACEMENT = "Placement"
|
||||||
|
|
||||||
COMPANY_WEBSITE = 'website'
|
COMPANY_WEBSITE = 'website'
|
||||||
COMPANY_ADDRESS = 'address'
|
COMPANY_ADDRESS = 'address'
|
||||||
COMPANY_PHONE_NUMBER = 'phone_number'
|
PHONE_NUMBER = 'phone_number'
|
||||||
COMPANY_CONTACT_PERSON_NAME = 'contact_person_name'
|
CONTACT_PERSON_NAME = 'contact_person_name'
|
||||||
|
|
||||||
OPENING_DESIGNATION = 'designation'
|
DESIGNATION = 'designation'
|
||||||
OPENING_DESCRIPTION = 'description'
|
DESCRIPTION = 'description'
|
||||||
OPENING_TYPE = 'opening_type'
|
OPENING_TYPE = 'opening_type'
|
||||||
OPENING_CITY = 'city'
|
CITY = 'city'
|
||||||
OPENING_CITY_TYPE = 'city_type'
|
CITY_TYPE = 'city_type'
|
||||||
OPENING_COMPENSATION = 'compensation'
|
COMPENSATION = 'compensation'
|
||||||
OPENING_COMPENSATION_DETAILS = 'compensation_details'
|
COMPENSATION_DETAILS = 'compensation_details'
|
||||||
OPENING_ALLOWED_BATCH = 'allowed_batch'
|
ALLOWED_BATCH = 'allowed_batch'
|
||||||
OPENING_ALLOWED_BRANCH = 'allowed_branch'
|
ALLOWED_BRANCH = 'allowed_branch'
|
||||||
OPENING_ATTACHMENTS = 'attachments'
|
ATTACHMENTS = 'attachments'
|
||||||
OPENING_ROUNDS = 'rounds'
|
ROUNDS = 'rounds'
|
||||||
OPENING_ADDITIONAL_INFO = 'additional_info'
|
ROUND_DETAILS = 'round_details'
|
||||||
OPENING_ROUND_DETAILS = 'round_details'
|
DURATION = 'duration'
|
||||||
OPENING_DURATION = 'duration'
|
CO_OP = 'co_op'
|
||||||
OPENING_CO_OP = 'co_op'
|
START_DATE = "start_date"
|
||||||
OPENING_START_DATE = 'start_date'
|
|
||||||
|
STUDENT_LIST = "student_list"
|
||||||
|
STUDENT_STATUS = "student_status"
|
||||||
|
|
||||||
BRANCHES = [
|
BRANCHES = [
|
||||||
"CSE",
|
"CSE",
|
||||||
|
@ -87,6 +89,13 @@ BATCHES = [
|
||||||
]
|
]
|
||||||
|
|
||||||
COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT = "Notification Submitted - {id} - CDC IIT Dharwad"
|
COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT = "Notification Submitted - {id} - CDC IIT Dharwad"
|
||||||
|
STUDENT_APPLICATION_STATUS_TEMPLATE_SUBJECT = 'Application Status : {company_name} - {id}'
|
||||||
|
STUDENT_APPLICATION_SUBMITTED_TEMPLATE_SUBJECT = 'CDC - Application Submitted - {company_name}'
|
||||||
|
|
||||||
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'
|
||||||
|
STUDENT_APPLICATION_STATUS_SELECTED_TEMPLATE = 'student_application_status_selected.html'
|
||||||
|
STUDENT_APPLICATION_STATUS_NOT_SELECTED_TEMPLATE = 'student_application_status_not_selected.html'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -90,12 +90,13 @@ class PlacementApplication(models.Model):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name_plural = "Placement Applications"
|
verbose_name_plural = "Placement Applications"
|
||||||
|
unique_together = ('placement_id', 'student_id')
|
||||||
|
|
||||||
|
|
||||||
class PrePlacementOffer(models.Model):
|
class PrePlacementOffer(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
student = models.ForeignKey(Student, on_delete=models.CASCADE, blank=False)
|
student = models.ForeignKey(Student, on_delete=models.CASCADE, blank=False)
|
||||||
company = models.CharField(max_length=50, blank=False)
|
company = models.CharField(max_length=50, blank=False, default="")
|
||||||
compensation = models.IntegerField(blank=False) # Job - Per Year
|
compensation = models.IntegerField(blank=False) # Job - Per Year
|
||||||
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)
|
||||||
|
|
|
@ -132,18 +132,18 @@ def deleteResume(request, id, email, user_type):
|
||||||
|
|
||||||
@api_view(['POST'])
|
@api_view(['POST'])
|
||||||
@isAuthorized(allowed_users=[STUDENT])
|
@isAuthorized(allowed_users=[STUDENT])
|
||||||
@precheck(required_data=[APPLICATION_OPENING_TYPE, APPLICATION_OPENING_ID, RESUME_FILE_NAME,
|
@precheck(required_data=[OPENING_TYPE, OPENING_ID, RESUME_FILE_NAME,
|
||||||
APPLICATION_ADDITIONAL_INFO])
|
ADDITIONAL_INFO])
|
||||||
def submitApplication(request, id, email, user_type):
|
def submitApplication(request, id, email, user_type):
|
||||||
try:
|
try:
|
||||||
data = request.data
|
data = request.data
|
||||||
student = get_object_or_404(Student, id=id)
|
student = get_object_or_404(Student, id=id)
|
||||||
|
|
||||||
if data[APPLICATION_OPENING_TYPE] == PLACEMENT:
|
if data[OPENING_TYPE] == PLACEMENT:
|
||||||
if not len(PlacementApplication.objects.filter(
|
if not len(PlacementApplication.objects.filter(
|
||||||
student_id=id, placement_id=data[APPLICATION_OPENING_ID])):
|
student_id=id, placement_id=data[OPENING_ID])):
|
||||||
application = PlacementApplication()
|
application = PlacementApplication()
|
||||||
opening = get_object_or_404(Placement, id=data[APPLICATION_OPENING_ID],
|
opening = get_object_or_404(Placement, id=data[OPENING_ID],
|
||||||
status=STATUS_ACCEPTING_APPLICATIONS)
|
status=STATUS_ACCEPTING_APPLICATIONS)
|
||||||
cond_stat, cond_msg = PlacementApplicationConditions(student, opening)
|
cond_stat, cond_msg = PlacementApplicationConditions(student, opening)
|
||||||
print(cond_stat, cond_msg)
|
print(cond_stat, cond_msg)
|
||||||
|
@ -153,7 +153,7 @@ def submitApplication(request, id, email, user_type):
|
||||||
else:
|
else:
|
||||||
raise PermissionError("Application is already Submitted")
|
raise PermissionError("Application is already Submitted")
|
||||||
else:
|
else:
|
||||||
raise ValueError(APPLICATION_OPENING_TYPE + " is Invalid")
|
raise ValueError(OPENING_TYPE + " is Invalid")
|
||||||
|
|
||||||
if data[RESUME_FILE_NAME] in student.resumes:
|
if data[RESUME_FILE_NAME] in student.resumes:
|
||||||
application.resume = data[RESUME_FILE_NAME]
|
application.resume = data[RESUME_FILE_NAME]
|
||||||
|
@ -163,15 +163,19 @@ def submitApplication(request, id, email, user_type):
|
||||||
application.student = student
|
application.student = student
|
||||||
application.id = generateRandomString()
|
application.id = generateRandomString()
|
||||||
for i in opening.additional_info:
|
for i in opening.additional_info:
|
||||||
if i not in data[APPLICATION_ADDITIONAL_INFO]:
|
if i not in data[ADDITIONAL_INFO]:
|
||||||
print(i)
|
print(i)
|
||||||
raise AttributeError(i + " not found in Additional Info")
|
raise AttributeError(i + " not found in Additional Info")
|
||||||
|
|
||||||
application.additional_info = data[APPLICATION_ADDITIONAL_INFO]
|
application.additional_info = data[ADDITIONAL_INFO]
|
||||||
if not sendApplicationEmail(email, student.name, opening.company.name, data[APPLICATION_OPENING_TYPE],
|
data = {
|
||||||
data[APPLICATION_ADDITIONAL_INFO]):
|
"name": student.name,
|
||||||
logger.error("Submit Application: Unable to Send Email")
|
"company_name": opening.company.name,
|
||||||
# raise RuntimeError("Unable to Send Email")
|
"application_type": data[OPENING_TYPE],
|
||||||
|
"additional_info": data[ADDITIONAL_INFO]
|
||||||
|
}
|
||||||
|
subject = STUDENT_APPLICATION_SUBMITTED_TEMPLATE_SUBJECT.format(company_name=opening.company.name)
|
||||||
|
sendEmail(email, subject, data, STUDENT_APPLICATION_SUBMITTED_TEMPLATE)
|
||||||
|
|
||||||
application.save()
|
application.save()
|
||||||
return Response({'action': "Submit Application", 'message': "Application Submitted"},
|
return Response({'action': "Submit Application", 'message': "Application Submitted"},
|
||||||
|
|
|
@ -15,6 +15,7 @@ from google.auth.transport import requests
|
||||||
from google.oauth2 import id_token
|
from google.oauth2 import id_token
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
import background_task
|
||||||
|
|
||||||
from .models import *
|
from .models import *
|
||||||
|
|
||||||
|
@ -108,30 +109,6 @@ def generateRandomString():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def sendApplicationEmail(email, name, company_name, applicaton_type, additional_info):
|
|
||||||
try:
|
|
||||||
subject = 'CDC - Application Submitted - ' + str(company_name)
|
|
||||||
data = {
|
|
||||||
"name": name,
|
|
||||||
"company_name": company_name,
|
|
||||||
"applicaton_type": applicaton_type,
|
|
||||||
"additional_info": additional_info
|
|
||||||
}
|
|
||||||
|
|
||||||
html_content = render_to_string('student_application_submited.html', data) # render with dynamic value
|
|
||||||
text_content = strip_tags(html_content)
|
|
||||||
|
|
||||||
email_from = settings.EMAIL_HOST_USER
|
|
||||||
recipient_list = [str(email), ]
|
|
||||||
|
|
||||||
msg = EmailMultiAlternatives(subject, text_content, email_from, recipient_list)
|
|
||||||
msg.attach_alternative(html_content, "text/html")
|
|
||||||
msg.send()
|
|
||||||
return True
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def saveFile(file, location):
|
def saveFile(file, location):
|
||||||
prefix = generateRandomString()
|
prefix = generateRandomString()
|
||||||
file_name = prefix + "_" + file.name
|
file_name = prefix + "_" + file.name
|
||||||
|
@ -149,7 +126,7 @@ def saveFile(file, location):
|
||||||
|
|
||||||
return file_name
|
return file_name
|
||||||
|
|
||||||
|
@background_task.background(schedule=10)
|
||||||
def sendEmail(email_to, subject, data, template):
|
def sendEmail(email_to, subject, data, template):
|
||||||
try:
|
try:
|
||||||
html_content = render_to_string(template, data) # render with dynamic value
|
html_content = render_to_string(template, data) # render with dynamic value
|
||||||
|
@ -163,8 +140,9 @@ def sendEmail(email_to, subject, data, template):
|
||||||
msg.send()
|
msg.send()
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
|
logger.error("Send Email: " + str(sys.exc_info()))
|
||||||
print(str(sys.exc_info()[1]))
|
print(str(sys.exc_info()[1]))
|
||||||
return str(sys.exc_info()[1])
|
return False
|
||||||
|
|
||||||
|
|
||||||
def PlacementApplicationConditions(student, placement):
|
def PlacementApplicationConditions(student, placement):
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta name="x-apple-disable-message-reformatting">
|
||||||
|
<title></title>
|
||||||
|
<!--[if mso]>
|
||||||
|
<noscript>
|
||||||
|
<xml>
|
||||||
|
<o:OfficeDocumentSettings>
|
||||||
|
<o:PixelsPerInch>96</o:PixelsPerInch>
|
||||||
|
</o:OfficeDocumentSettings>
|
||||||
|
</xml>
|
||||||
|
</noscript>
|
||||||
|
<![endif]-->
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||||
|
<link rel="shortcut icon" href="favicon.ico"/>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@500&display=swap" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
table, td, div, h1, p {
|
||||||
|
font-family: 'Roboto', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body style="margin:0;padding:0;">
|
||||||
|
<table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#ffffff;">
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:0;">
|
||||||
|
<table role="presentation"
|
||||||
|
style="width:602px;border-collapse:collapse;border:1px solid #334878;border-spacing:0;text-align:left;">
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:40px 0 30px 0;background:#334878;">
|
||||||
|
<img src="./image.png" alt="" width="200" style="height:auto;display:block;"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding:36px 30px 42px 30px;">
|
||||||
|
<table role="presentation"
|
||||||
|
style="width:100%;border-collapse:collapse;border:0;border-spacing:0;">
|
||||||
|
<tr>
|
||||||
|
<td style="padding:0 0 36px 0;color:#153643;">
|
||||||
|
<h1 style="font-size:24px;margin:0 0 20px 0;font-family: 'Roboto', sans-serif;
|
||||||
|
">Thank You for filling the form</h1>
|
||||||
|
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family: 'Roboto', sans-serif;">
|
||||||
|
We have received your <b>{{ opening_type }}</b> notification for a <b>{{ designation }}</b> offer at <b>
|
||||||
|
{{ company_name }}</b>. Click <a href="{{ opening_link }}">here</a> to view your notification.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family: 'Roboto', sans-serif;">
|
||||||
|
We will keep you informed with the updates. If you have any queries, please
|
||||||
|
feel to
|
||||||
|
write to
|
||||||
|
<nobr><u>cdc@iitdh.ac.in</u></nobr>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding:30px;background:#334878;">
|
||||||
|
<table role="presentation"
|
||||||
|
style="width:100%;border-collapse:collapse;border:0;border-spacing:0;font-size:9px;font-family: 'Roboto', sans-serif;">
|
||||||
|
<tr>
|
||||||
|
<td style="padding:0;width:50%;" align="left">
|
||||||
|
<p style="margin:0;font-size:14px;line-height:16px;font-family: 'Roboto', sans-serif;color:#ffffff;">
|
||||||
|
® CDC,IIT Dharwad,2021<br/>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue