Added AddPrePlacements API
This commit is contained in:
parent
d3183db59f
commit
21bee24197
|
@ -12,4 +12,6 @@ urlpatterns = [
|
||||||
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"),
|
||||||
|
path('addPPO/', adminViews.addPPO, name="Add PPO"),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -303,3 +303,47 @@ def generateCSV(request, id, email, user_type):
|
||||||
print(sys.exc_info())
|
print(sys.exc_info())
|
||||||
return Response({'action': "Create csv", 'message': "Error Occurred"},
|
return Response({'action': "Create csv", 'message': "Error Occurred"},
|
||||||
status=status.HTTP_400_BAD_REQUEST)
|
status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
@api_view(['POST'])
|
||||||
|
@isAuthorized(allowed_users=[ADMIN])
|
||||||
|
@precheck(required_data=[STUDENT_ID, COMPANY_NAME,COMPENSATION_GROSS, COMPENSATION_DETAILS, DESIGNATION, OFFER_ACCEPTED])
|
||||||
|
def addPPO(request, id, email, user_type):
|
||||||
|
try:
|
||||||
|
data = request.data
|
||||||
|
if data[STUDENT_ID].isdigit():
|
||||||
|
student = get_object_or_404(Student, roll_no=int(data[STUDENT_ID]))
|
||||||
|
else:
|
||||||
|
raise ValueError("Student ID should be a number")
|
||||||
|
ppo = PrePlacementOffer()
|
||||||
|
ppo.student = student
|
||||||
|
ppo.company_name = data[COMPANY_NAME]
|
||||||
|
if data[COMPENSATION_GROSS].isdigit():
|
||||||
|
ppo.compensation_gross = int(data[COMPENSATION_GROSS])
|
||||||
|
else:
|
||||||
|
raise ValueError("Compensation Gross should be a number")
|
||||||
|
ppo.compensation_details = data[COMPENSATION_DETAILS]
|
||||||
|
ppo.designation = data[DESIGNATION]
|
||||||
|
print(data[OFFER_ACCEPTED], type(data[OFFER_ACCEPTED]))
|
||||||
|
if data[OFFER_ACCEPTED] == "true":
|
||||||
|
ppo.offer_accepted = True
|
||||||
|
elif data[OFFER_ACCEPTED] == "false":
|
||||||
|
ppo.offer_accepted = False
|
||||||
|
else:
|
||||||
|
ppo.offer_accepted = None
|
||||||
|
stat, tier = getTier(int(ppo.compensation_gross))
|
||||||
|
if stat:
|
||||||
|
ppo.tier = tier
|
||||||
|
else:
|
||||||
|
raise Exception("Invalid Compensation")
|
||||||
|
ppo.save()
|
||||||
|
return Response({'action': "Add PPO", 'message': "PPO added"},
|
||||||
|
status=status.HTTP_200_OK)
|
||||||
|
except Http404:
|
||||||
|
return Response({'action': "Add PPO", 'message': "Student not found"},
|
||||||
|
status=status.HTTP_404_NOT_FOUND)
|
||||||
|
except:
|
||||||
|
logger.warning("Add PPO: " + str(sys.exc_info()))
|
||||||
|
return Response({'action': "Add PPO", 'message': "Something Went Wrong"},
|
||||||
|
status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -129,9 +129,9 @@ class PlacementApplication(models.Model):
|
||||||
class PrePlacementOffer(models.Model):
|
class PrePlacementOffer(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
student = models.ForeignKey(Student, on_delete=models.CASCADE, blank=False)
|
student = models.ForeignKey(Student, on_delete=models.CASCADE, blank=False)
|
||||||
company = models.CharField(max_length=50, blank=False, default="")
|
company_name = models.CharField(max_length=50, blank=False, default="")
|
||||||
compensation = models.IntegerField(blank=False) # Job - Per Year
|
compensation_gross = models.IntegerField(blank=False) # Job - Per Year
|
||||||
compensation_details = models.CharField(blank=True, max_length=200)
|
compensation_details = models.CharField(blank=True, max_length=200)
|
||||||
tier = models.CharField(blank=False, choices=TIERS, max_length=10)
|
tier = models.CharField(blank=False, choices=TIERS, max_length=10)
|
||||||
designation = models.CharField(blank=False, max_length=25, default=None, null=True)
|
designation = models.CharField(blank=False, max_length=25, default=None, null=True)
|
||||||
accepted = models.BooleanField(default=None, null=True)
|
offer_accepted = models.BooleanField(default=None, null=True)
|
||||||
|
|
Loading…
Reference in New Issue