Aditional Info complete

This commit is contained in:
gowtham 2022-06-06 11:55:56 +05:30
parent 32395e17f6
commit 8b7d78a67f
2 changed files with 31 additions and 4 deletions

View File

@ -9,6 +9,7 @@ urlpatterns = [
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('deleteAdditionalInfo/', adminViews.deleteAdditionalInfo, name="Delete 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

@ -158,17 +158,43 @@ def deleteAdditionalInfo(request, id, email, user_type):
else: else:
raise ValueError("Additional Info Not Found") 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])