fixed optional companydescription field

This commit is contained in:
karthikmurakonda 2023-07-26 22:32:15 +05:30
parent 8d12fafc52
commit 7baa25f152
1 changed files with 12 additions and 13 deletions

View File

@ -233,13 +233,15 @@ def addPlacement(request):
except ValueError as e: except ValueError as e:
store_all_files(request) store_all_files(request)
exception_email(data) exception_email(data)
logger.info("ValueError in addPlacement: " + str(e)) logger.warning("ValueError in addPlacement: " + str(e))
logger.warning(traceback.format_exc())
return Response({'action': "Add Placement", 'message': str(e)}, return Response({'action': "Add Placement", 'message': str(e)},
status=status.HTTP_400_BAD_REQUEST) status=status.HTTP_400_BAD_REQUEST)
except: except:
store_all_files(request) store_all_files(request)
exception_email(data) exception_email(data)
logger.warning("Add New Placement: " + str(sys.exc_info())) logger.warning("Add New Placement: " + str(sys.exc_info()))
logger.warning(traceback.format_exc())
return Response({'action': "Add Placement", 'message': "Something went wrong"}, return Response({'action': "Add Placement", 'message': "Something went wrong"},
status=status.HTTP_400_BAD_REQUEST) status=status.HTTP_400_BAD_REQUEST)
@ -407,7 +409,7 @@ def addInternship(request):
internship.is_work_from_home = True internship.is_work_from_home = True
else: else:
internship.is_work_from_home = False internship.is_work_from_home = False
if data[ALLOWED_BRANCH] is None: if data[ALLOWED_BRANCH] is None or json.loads(data[ALLOWED_BRANCH]) == "":
raise ValueError('Allowed Branch cannot be empty') raise ValueError('Allowed Branch cannot be empty')
elif set(json.loads(data[ALLOWED_BRANCH])).issubset(BRANCHES): elif set(json.loads(data[ALLOWED_BRANCH])).issubset(BRANCHES):
internship.allowed_branch = json.loads(data[ALLOWED_BRANCH]) internship.allowed_branch = json.loads(data[ALLOWED_BRANCH])
@ -443,14 +445,16 @@ def addInternship(request):
internship.stipend = int(data[STIPEND]) internship.stipend = int(data[STIPEND])
else: else:
raise ValueError('Stipend must be an integer') raise ValueError('Stipend must be an integer')
if data[FACILITIES] != "" :
if data[FACILITIES] != "": if json.loads(data[FACILITIES]) == "":
if set(json.loads(data[FACILITIES])).issubset(FACILITIES_CHOICES): internship.facilities_provided = []
elif set(json.loads(data[FACILITIES])).issubset(FACILITIES_CHOICES):
internship.facilities_provided = json.loads(data[FACILITIES]) internship.facilities_provided = json.loads(data[FACILITIES])
else: else:
raise ValueError('Facilities must be a subset of ' + str(FACILITIES_CHOICES)) raise ValueError('Facilities must be a subset of ' + str(FACILITIES_CHOICES))
else: else:
internship.facilities = [] internship.facilities_provided = []
internship.other_facilities = data[OTHER_FACILITIES] internship.other_facilities = data[OTHER_FACILITIES]
if data[SELECTION_PROCEDURE_ROUNDS] is None: if data[SELECTION_PROCEDURE_ROUNDS] is None:
@ -501,18 +505,13 @@ def addInternship(request):
store_all_files(request) store_all_files(request)
# exception_email(data) # exception_email(data)
logger.warning("ValueError in addInternship: " + str(e)) logger.warning("ValueError in addInternship: " + str(e))
logger.warning(traceback.format_exc())
return Response({'action': "Add Internship", 'message': str(e)}, return Response({'action': "Add Internship", 'message': str(e)},
status=status.HTTP_400_BAD_REQUEST) status=status.HTTP_400_BAD_REQUEST)
except: except:
store_all_files(request) store_all_files(request)
print(traceback.format_exc())
# exception_email(data) # exception_email(data)
logger.warning("Add New Internship: " + str(sys.exc_info())) logger.warning("Add New Internship: " + str(sys.exc_info()))
logger.warning(traceback.format_exc())
return Response({'action': "Add Internship", 'message': "Something went wrong"}, return Response({'action': "Add Internship", 'message': "Something went wrong"},
status=status.HTTP_400_BAD_REQUEST) status=status.HTTP_400_BAD_REQUEST)