Merge pull request #23 from CDC-IITDH/small-changes

Small changes
This commit is contained in:
CDC-IITDH 2021-10-23 16:52:55 +05:30 committed by GitHub
commit 0269d439f1
5 changed files with 79 additions and 75 deletions

View File

@ -10,10 +10,10 @@ logger = logging.getLogger('db')
@api_view(['POST'])
@precheck([OPENING_DESIGNATION, OPENING_DESCRIPTION, OPENING_TYPE, OPENING_CITY, OPENING_CITY_TYPE,
OPENING_COMPENSATION, OPENING_COMPENSATION_DETAILS, OPENING_ALLOWED_BATCH, OPENING_ALLOWED_BRANCH,
OPENING_ROUNDS, OPENING_CO_OP, OPENING_START_DATE, OPENING_ADDITIONAL_INFO,
OPENING_DURATION, OPENING_ROUND_DETAILS])
@precheck([DESIGNATION, DESCRIPTION, OPENING_TYPE, CITY, CITY_TYPE,
COMPENSATION, COMPENSATION_DETAILS, ALLOWED_BATCH, ALLOWED_BRANCH,
ROUNDS, CO_OP, START_DATE, ADDITIONAL_INFO,
DURATION, ROUND_DETAILS])
def addOpening(request):
try:
data = request.data
@ -28,61 +28,61 @@ def addOpening(request):
# Some new code above
if data[OPENING_DESIGNATION] != "":
opening.designation = data[OPENING_DESIGNATION]
if data[DESIGNATION] != "":
opening.designation = data[DESIGNATION]
else:
raise ValueError(OPENING_DESIGNATION + " Not Found")
raise ValueError(DESIGNATION + " Not Found")
opening.description = data[OPENING_DESCRIPTION]
opening.description = data[DESCRIPTION]
if data[OPENING_START_DATE] != "":
opening.description = data[OPENING_START_DATE]
if data[START_DATE] != "":
opening.description = data[START_DATE]
else:
raise ValueError(OPENING_START_DATE + " Not Found")
if data[OPENING_START_DATE] != "":
opening.start_date = datetime.strptime(data[OPENING_START_DATE], '%d-%m-%Y')
raise ValueError(START_DATE + " Not Found")
if data[START_DATE] != "":
opening.start_date = datetime.strptime(data[START_DATE], '%d-%m-%Y')
else:
raise ValueError(OPENING_START_DATE + " Not Found")
if data[OPENING_CITY] != "":
opening.city = data[OPENING_CITY]
raise ValueError(START_DATE + " Not Found")
if data[CITY] != "":
opening.city = data[CITY]
else:
raise ValueError(OPENING_CITY + " Not Found")
if data[OPENING_CITY_TYPE] != "":
opening.city_type = data[OPENING_CITY_TYPE]
raise ValueError(CITY + " Not Found")
if data[CITY_TYPE] != "":
opening.city_type = data[CITY_TYPE]
else:
raise ValueError(OPENING_CITY_TYPE + " Not Found")
if data[OPENING_COMPENSATION] != "":
opening.compensation = data[OPENING_COMPENSATION]
raise ValueError(CITY_TYPE + " Not Found")
if data[COMPENSATION] != "":
opening.compensation = data[COMPENSATION]
else:
raise ValueError(OPENING_COMPENSATION + " Not Found")
raise ValueError(COMPENSATION + " Not Found")
opening.compensation_details = data[OPENING_COMPENSATION_DETAILS]
opening.compensation_details = data[COMPENSATION_DETAILS]
if data[OPENING_ALLOWED_BATCH] != "":
if set(json.loads(data[OPENING_ALLOWED_BATCH])).issubset(BATCHES):
opening.allowed_batch = json.loads(data[OPENING_ALLOWED_BATCH])
if data[ALLOWED_BATCH] != "":
if set(json.loads(data[ALLOWED_BATCH])).issubset(BATCHES):
opening.allowed_batch = json.loads(data[ALLOWED_BATCH])
else:
raise ValueError(OPENING_ALLOWED_BATCH + " is Invalid")
raise ValueError(ALLOWED_BATCH + " is Invalid")
else:
raise ValueError(OPENING_ALLOWED_BATCH + " Not Found")
if data[OPENING_ALLOWED_BRANCH] != "":
if set(json.loads(data[OPENING_ALLOWED_BRANCH])).issubset(BRANCHES):
opening.allowed_branch = json.loads(data[OPENING_ALLOWED_BRANCH])
raise ValueError(ALLOWED_BATCH + " Not Found")
if data[ALLOWED_BRANCH] != "":
if set(json.loads(data[ALLOWED_BRANCH])).issubset(BRANCHES):
opening.allowed_branch = json.loads(data[ALLOWED_BRANCH])
else:
raise ValueError(OPENING_ALLOWED_BATCH + " is Invalid")
raise ValueError(ALLOWED_BATCH + " is Invalid")
else:
raise ValueError(OPENING_ALLOWED_BRANCH + " Not Found")
raise ValueError(ALLOWED_BRANCH + " Not Found")
opening.rounds = json.loads(data[OPENING_ROUNDS])
opening.rounds = json.loads(data[ROUNDS])
opening.additional_info = json.loads(data[OPENING_ADDITIONAL_INFO])
opening.additional_info = json.loads(data[ADDITIONAL_INFO])
opening.status = STATUS_ACCEPTING_APPLICATIONS
opening.rounds_details = json.loads(data[OPENING_ROUND_DETAILS])
opening.rounds_details = json.loads(data[ROUND_DETAILS])
opening.created_at = make_aware(datetime.now())
files = request.FILES.getlist(OPENING_ATTACHMENTS)
files = request.FILES.getlist(ATTACHMENTS)
attachments = []
for file in files:
attachments.append(saveFile(file, STORAGE_DESTINATION_COMPANY_ATTACHMENTS))

View File

@ -38,15 +38,16 @@ EMAIL = "email"
STUDENT = 'student'
ADMIN = 'Admin'
COMPANY = ''
STORAGE_DESTINATION = "./Storage/Resumes/"
STORAGE_DESTINATION_COMPANY_ATTACHMENTS = './Storage/Company_Attachments/'
RESUME_FILE_NAME = 'resume_file_name'
APPLICATION_ID = "application_id"
APPLICATION_OPENING_TYPE = "opening_type"
APPLICATION_OPENING_ID = "opening_id"
APPLICATION_ADDITIONAL_INFO = "additional_info"
OPENING_ID = "opening_id"
STUDENT_ID = "student_id"
ADDITIONAL_INFO = "additional_info"
STATUS_ACCEPTING_APPLICATIONS = "Accepting Applications"
@ -54,25 +55,27 @@ PLACEMENT = "Placement"
COMPANY_WEBSITE = 'website'
COMPANY_ADDRESS = 'address'
COMPANY_PHONE_NUMBER = 'phone_number'
COMPANY_CONTACT_PERSON_NAME = 'contact_person_name'
PHONE_NUMBER = 'phone_number'
CONTACT_PERSON_NAME = 'contact_person_name'
OPENING_DESIGNATION = 'designation'
OPENING_DESCRIPTION = 'description'
DESIGNATION = 'designation'
DESCRIPTION = 'description'
OPENING_TYPE = 'opening_type'
OPENING_CITY = 'city'
OPENING_CITY_TYPE = 'city_type'
OPENING_COMPENSATION = 'compensation'
OPENING_COMPENSATION_DETAILS = 'compensation_details'
OPENING_ALLOWED_BATCH = 'allowed_batch'
OPENING_ALLOWED_BRANCH = 'allowed_branch'
OPENING_ATTACHMENTS = 'attachments'
OPENING_ROUNDS = 'rounds'
OPENING_ADDITIONAL_INFO = 'additional_info'
OPENING_ROUND_DETAILS = 'round_details'
OPENING_DURATION = 'duration'
OPENING_CO_OP = 'co_op'
OPENING_START_DATE = 'start_date'
CITY = 'city'
CITY_TYPE = 'city_type'
COMPENSATION = 'compensation'
COMPENSATION_DETAILS = 'compensation_details'
ALLOWED_BATCH = 'allowed_batch'
ALLOWED_BRANCH = 'allowed_branch'
ATTACHMENTS = 'attachments'
ROUNDS = 'rounds'
ROUND_DETAILS = 'round_details'
DURATION = 'duration'
CO_OP = 'co_op'
START_DATE = "start_date"
STUDENT_LIST = "student_list"
STUDENT_STATUS = "student_status"
BRANCHES = [
"CSE",

View File

@ -28,12 +28,12 @@ class Admin(models.Model):
class Placement(models.Model):
id = models.CharField(blank=False, primary_key=True, max_length=15)
name = models.CharField(blank=False, max_length=50)
address = models.CharField(blank=False, max_length=150)
companyType = models.CharField(blank=False, max_length=50)
website = models.CharField(blank=True, max_length=50)
contact_person_name = models.CharField(blank=False, max_length=50)
phone_number = models.PositiveBigIntegerField(blank=False)
name = models.CharField(blank=False, max_length=50, default="")
address = models.CharField(blank=False, max_length=150, default="")
companyType = models.CharField(blank=False, max_length=50, default="")
website = models.CharField(blank=True, max_length=50, default="")
contact_person_name = models.CharField(blank=False, max_length=50, default="")
phone_number = models.PositiveBigIntegerField(blank=False, default=0)
designation = models.CharField(blank=False, max_length=25, default=None, null=True)
description = models.CharField(blank=False, max_length=200)
start_date = models.DateField(blank=False, verbose_name="Start Date")
@ -90,12 +90,13 @@ class PlacementApplication(models.Model):
class Meta:
verbose_name_plural = "Placement Applications"
unique_together = ('placement_id', 'student_id')
class PrePlacementOffer(models.Model):
id = models.AutoField(primary_key=True)
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_details = models.CharField(blank=True, max_length=200)
tier = models.CharField(blank=False, choices=TIERS, max_length=10)

View File

@ -132,18 +132,18 @@ def deleteResume(request, id, email, user_type):
@api_view(['POST'])
@isAuthorized(allowed_users=[STUDENT])
@precheck(required_data=[APPLICATION_OPENING_TYPE, APPLICATION_OPENING_ID, RESUME_FILE_NAME,
APPLICATION_ADDITIONAL_INFO])
@precheck(required_data=[OPENING_TYPE, OPENING_ID, RESUME_FILE_NAME,
ADDITIONAL_INFO])
def submitApplication(request, id, email, user_type):
try:
data = request.data
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(
student_id=id, placement_id=data[APPLICATION_OPENING_ID])):
student_id=id, placement_id=data[OPENING_ID])):
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)
cond_stat, cond_msg = PlacementApplicationConditions(student, opening)
print(cond_stat, cond_msg)
@ -153,7 +153,7 @@ def submitApplication(request, id, email, user_type):
else:
raise PermissionError("Application is already Submitted")
else:
raise ValueError(APPLICATION_OPENING_TYPE + " is Invalid")
raise ValueError(OPENING_TYPE + " is Invalid")
if data[RESUME_FILE_NAME] in student.resumes:
application.resume = data[RESUME_FILE_NAME]
@ -163,13 +163,13 @@ def submitApplication(request, id, email, user_type):
application.student = student
application.id = generateRandomString()
for i in opening.additional_info:
if i not in data[APPLICATION_ADDITIONAL_INFO]:
if i not in data[ADDITIONAL_INFO]:
print(i)
raise AttributeError(i + " not found in Additional Info")
application.additional_info = data[APPLICATION_ADDITIONAL_INFO]
if not sendApplicationEmail(email, student.name, opening.company.name, data[APPLICATION_OPENING_TYPE],
data[APPLICATION_ADDITIONAL_INFO]):
application.additional_info = data[ADDITIONAL_INFO]
if not sendApplicationEmail(email, student.name, opening.company.name, data[OPENING_TYPE],
data[ADDITIONAL_INFO]):
logger.error("Submit Application: Unable to Send Email")
# raise RuntimeError("Unable to Send Email")

Binary file not shown.