made refractorings

This commit is contained in:
karthik murakonda 2022-05-24 01:23:29 +05:30
parent b19ea638cc
commit f04c867329
3 changed files with 23 additions and 11 deletions

View File

@ -13,5 +13,5 @@ urlpatterns = [
path("submitApplication/", adminViews.submitApplication, name="Submit Application"),
path('generateCSV/', adminViews.generateCSV, name="Generate CSV"),
path('addPPO/', adminViews.addPPO, name="Add PPO"),
path('getstudentapplication/', adminViews.getstudentapplication, name="Get student application"),
path('getStudentApplication/', adminViews.getStudentApplication, name="Get student application"),
]

View File

@ -338,25 +338,37 @@ def addPPO(request, id, email, user_type):
@api_view(['POST'])
@isAuthorized(allowed_users=[ADMIN])
@precheck(required_data=[STUDENT_ID, OPENING_ID])
def getstudentapplication(request, id, email, user_type):
def getStudentApplication(request, id, email, user_type):
try:
data = request.data
student = get_object_or_404(Student, id=data[STUDENT_ID])
student_serializer = StudentSerializer(student)
student_details = {
"name": student_serializer.data['name'],
"batch": student.batch,
"branch": student.branch,
"resume_list": student_serializer.data['resume_list'],
}
# search for the application if there or not
application = PlacementApplication.objects.filter(student=student, placement=get_object_or_404(Placement, id=data[OPENING_ID]))
logger.info("Get Student Application: " + str(application))
if application:
serializer = PlacementApplicationSerializer(application[0])
return Response({'action': "Get Student Application", 'found': "true",'application_id': serializer.data["id"] ,
'application_additionalInfo': serializer.data[ADDITIONAL_INFO],"available_resumes": student_serializer.data["resume_list"],
"student_name":student.name, "student_branch":student.branch, "student_batch":student.batch, "resume":serializer.data["resume_link"]},
status=status.HTTP_200_OK)
application_info = {
"id": serializer.data['id'],
"additional_info": serializer.data['additional_info'],
"resume": serializer.data['resume'],
}
return Response({'action': "Get Student Application", 'application_found': "true", "application_info": application_info,
"student_details":student_details }, status=status.HTTP_200_OK)
else:
return Response({'action': "Get Student Application", 'found': "false", "available_resumes": student_serializer.data["resume_list"],
"student_name":student.name, "student_branch":student.branch, "student_batch":student.batch},
status=status.HTTP_200_OK)
except:
return Response({'action': "Get Student Application", 'application_found': "false", "student_details": student_details},
status=status.HTTP_404_NOT_FOUND)
except Http404:
logger.warning("Get Student Application: " + str(sys.exc_info()))
print(sys.exc_info())
return Response({'action': "Get Student Application", 'message': "Student with given roll number not found."}, status.HTTP_400_BAD_REQUEST)
except:
logger.warning("Get Student Application: " + str(sys.exc_info()))
print(sys.exc_info())
return Response({'action': "Get Student Application", 'message': "Some error Occurred"}, status.HTTP_500_INTERNAL_SERVER_ERROR)

View File

@ -132,7 +132,7 @@ class Placement(models.Model):
self.selection_procedure_details = self.selection_procedure_details.strip()[:JNF_TEXTAREA_MAX_CHARACTER_COUNT]
self.bond_details = self.bond_details.strip()[:JNF_TEXTAREA_MAX_CHARACTER_COUNT]
self.other_requirements = self.other_requirements.strip()[:JNF_TEXTAREA_MAX_CHARACTER_COUNT]
self.additinal_info = [info.strip()[:JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT] for info in self.additional_info]
self.additional_info = [info.strip()[:JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT] for info in self.additional_info]
def save(self, *args, **kwargs):
''' On save, add timestamps '''