Limit Resumes per student

This commit is contained in:
Gowtham Sai 2022-08-04 00:54:27 +05:30
parent 3115efa9eb
commit 02b6c10cc3
2 changed files with 7 additions and 0 deletions

View File

@ -54,6 +54,7 @@ TIER = 'tier'
# To be Configured Properly # To be Configured Properly
FOURTH_YEAR = '2019' FOURTH_YEAR = '2019'
MAX_OFFERS_PER_STUDENT = 2 MAX_OFFERS_PER_STUDENT = 2
MAX_RESUMES_PER_STUDENT =3
EMAIL_VERIFICATION_TOKEN_TTL = 48 # in hours EMAIL_VERIFICATION_TOKEN_TTL = 48 # in hours
JNF_TEXT_MAX_CHARACTER_COUNT = 100 JNF_TEXT_MAX_CHARACTER_COUNT = 100
JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT = 200 JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT = 200

View File

@ -40,6 +40,9 @@ def addResume(request, id, email, user_type):
student = get_object_or_404(Student, id=id) student = get_object_or_404(Student, id=id)
files = request.FILES files = request.FILES
if len(student.resumes) >= MAX_RESUMES_PER_STUDENT:
raise PermissionError('Max Number of Resumes limit reached')
file = files['file'] file = files['file']
destination_path = STORAGE_DESTINATION_RESUMES + str(student.roll_no) + "/" destination_path = STORAGE_DESTINATION_RESUMES + str(student.roll_no) + "/"
file_name = saveFile(file, destination_path) file_name = saveFile(file, destination_path)
@ -51,6 +54,9 @@ def addResume(request, id, email, user_type):
except Http404: except Http404:
return Response({'action': "Upload Resume", 'message': 'Student Not Found'}, return Response({'action': "Upload Resume", 'message': 'Student Not Found'},
status=status.HTTP_404_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: except:
if path.exists(destination_path): if path.exists(destination_path):
logger.error("Upload Resume: Error in Saving Resume") logger.error("Upload Resume: Error in Saving Resume")