Limit Resumes per student
This commit is contained in:
parent
3115efa9eb
commit
02b6c10cc3
|
@ -54,6 +54,7 @@ TIER = 'tier'
|
|||
# To be Configured Properly
|
||||
FOURTH_YEAR = '2019'
|
||||
MAX_OFFERS_PER_STUDENT = 2
|
||||
MAX_RESUMES_PER_STUDENT =3
|
||||
EMAIL_VERIFICATION_TOKEN_TTL = 48 # in hours
|
||||
JNF_TEXT_MAX_CHARACTER_COUNT = 100
|
||||
JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT = 200
|
||||
|
|
|
@ -40,6 +40,9 @@ def addResume(request, id, email, user_type):
|
|||
student = get_object_or_404(Student, id=id)
|
||||
files = request.FILES
|
||||
|
||||
if len(student.resumes) >= MAX_RESUMES_PER_STUDENT:
|
||||
raise PermissionError('Max Number of Resumes limit reached')
|
||||
|
||||
file = files['file']
|
||||
destination_path = STORAGE_DESTINATION_RESUMES + str(student.roll_no) + "/"
|
||||
file_name = saveFile(file, destination_path)
|
||||
|
@ -51,6 +54,9 @@ def addResume(request, id, email, user_type):
|
|||
except Http404:
|
||||
return Response({'action': "Upload Resume", 'message': 'Student Not Found'},
|
||||
status=status.HTTP_404_NOT_FOUND)
|
||||
except PermissionError:
|
||||
return Response({'action': "Upload Resume", 'message': 'Max Number of Resumes limit reached'},
|
||||
status=status.HTTP_400_BAD_REQUEST)
|
||||
except:
|
||||
if path.exists(destination_path):
|
||||
logger.error("Upload Resume: Error in Saving Resume")
|
||||
|
|
Loading…
Reference in New Issue