Limit Resumes per student (#136)

This commit is contained in:
Gowtham Sai 2022-08-05 10:50:07 +05:30 committed by GitHub
parent 3115efa9eb
commit 761849297e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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")