Merge branch 'main' into track-object-changes-new

This commit is contained in:
karthik mv 2022-06-30 00:52:36 +05:30 committed by GitHub
commit a3e4077723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 16 deletions

View File

@ -8,7 +8,8 @@ urlpatterns = [
path('updateDeadline/', adminViews.updateDeadline, name="Update Deadline"), path('updateDeadline/', adminViews.updateDeadline, name="Update Deadline"),
path('updateOfferAccepted/', adminViews.updateOfferAccepted, name="Update Offer Accepted"), path('updateOfferAccepted/', adminViews.updateOfferAccepted, name="Update Offer Accepted"),
path('updateEmailVerified', adminViews.updateEmailVerified, name="Update Email Verified"), path('updateEmailVerified', adminViews.updateEmailVerified, name="Update Email Verified"),
path('updateAdditionalInfo/', adminViews.updateAdditionalInfo, name="Update Additional Info"), path('deleteAdditionalInfo/', adminViews.deleteAdditionalInfo, name="Delete Additional Info"),
path('addAdditionalInfo/', adminViews.addAdditionalInfo, name="Add Additional Info"),
path('getApplications/', adminViews.getApplications, name="Get Applications"), path('getApplications/', adminViews.getApplications, name="Get Applications"),
path("submitApplication/", adminViews.submitApplication, name="Submit Application"), path("submitApplication/", adminViews.submitApplication, name="Submit Application"),
path('generateCSV/', adminViews.generateCSV, name="Generate CSV"), path('generateCSV/', adminViews.generateCSV, name="Generate CSV"),

View File

@ -149,33 +149,58 @@ def updateEmailVerified(request, id, email, user_type):
@api_view(['POST']) @api_view(['POST'])
@isAuthorized([ADMIN]) @isAuthorized([ADMIN])
@precheck([OPENING_ID, ADDITIONAL_INFO]) @precheck([OPENING_ID, FIELD])
def updateAdditionalInfo(request, id, email, user_type): def deleteAdditionalInfo(request, id, email, user_type):
try: try:
data = request.data data = request.data
opening = get_object_or_404(Placement, pk=data[OPENING_ID]) opening = get_object_or_404(Placement, pk=data[OPENING_ID])
if data[ADDITIONAL_INFO] == "": if data[FIELD] in opening.additional_info:
opening.additional_info = [] opening.additional_info.remove(data[FIELD])
elif isinstance(data[ADDITIONAL_INFO], list):
opening.additional_info = data[ADDITIONAL_INFO]
else:
raise ValueError("Additional Info must be a list")
opening.changed_by = get_object_or_404(User, id=id) opening.changed_by = get_object_or_404(User, id=id)
opening.save() opening.save()
return Response({'action': "Update Additional Info", 'message': "Additional Info Updated"}, return Response({'action': "Delete Additional Info", 'message': "Additional Info Deleted"},
status=status.HTTP_200_OK) status=status.HTTP_200_OK)
else:
raise ValueError("Additional Info Not Found")
except Http404: except Http404:
return Response({'action': "Update Additional Info", 'message': 'Opening Not Found'}, return Response({'action': "Delete Additional Info", 'message': 'Opening Not Found'},
status=status.HTTP_404_NOT_FOUND) status=status.HTTP_404_NOT_FOUND)
except ValueError: except ValueError:
return Response({'action': "Update Additional Info", 'message': "Additional Info must be a list"}, return Response({'action': "Delete Additional Info", 'message': "Additional Info not found"},
status=status.HTTP_404_NOT_FOUND)
except Exception as e:
logger.warning("Delete Additional Info: " + str(e))
return Response({'action': "Delete Additional Info", 'message': "Something went wrong"},
status=status.HTTP_400_BAD_REQUEST)
@api_view(['POST'])
@isAuthorized([ADMIN])
@precheck([OPENING_ID, FIELD])
def addAdditionalInfo(request, id, email, user_type):
try:
data = request.data
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
if data[FIELD] not in opening.additional_info:
opening.additional_info.append(data[FIELD])
opening.save()
return Response({'action': "Add Additional Info", 'message': "Additional Info Added"},
status=status.HTTP_200_OK)
else:
raise ValueError("Additional Info Found")
except Http404:
return Response({'action': "Add Additional Info", 'message': 'Opening Not Found'},
status=status.HTTP_404_NOT_FOUND)
except ValueError:
return Response({'action': "Add Additional Info", 'message': "Additional Info already found"},
status=status.HTTP_400_BAD_REQUEST) status=status.HTTP_400_BAD_REQUEST)
except Exception as e: except Exception as e:
logger.warning("Update Additional Info: " + str(e)) logger.warning("Add Additional Info: " + str(e))
return Response({'action': "Update Additional Info", 'message': "Something went wrong"}, return Response({'action': "Add Additional Info", 'message': "Something went wrong"},
status=status.HTTP_400_BAD_REQUEST) status=status.HTTP_400_BAD_REQUEST)
@api_view(['GET']) @api_view(['GET'])
@isAuthorized([ADMIN]) @isAuthorized([ADMIN])
@precheck([OPENING_ID]) @precheck([OPENING_ID])

View File

@ -70,6 +70,7 @@ RESUME_FILE_NAME = 'resume_file_name'
APPLICATION_ID = "application_id" APPLICATION_ID = "application_id"
OPENING_ID = "opening_id" OPENING_ID = "opening_id"
ADDITIONAL_INFO = "additional_info" ADDITIONAL_INFO = "additional_info"
FIELD = "field"
STATUS_ACCEPTING_APPLICATIONS = "Accepting Applications" STATUS_ACCEPTING_APPLICATIONS = "Accepting Applications"