Fixed Bugs

This commit is contained in:
Gowtham Sai 2021-12-17 19:23:32 +05:30
parent 364a66be30
commit d3183db59f
3 changed files with 29 additions and 26 deletions

View File

@ -1,10 +1,10 @@
import json
from datetime import datetime
from .utils import *
from rest_framework.decorators import api_view
import csv
import json
from rest_framework.decorators import api_view
from .serializers import *
from .utils import *
@api_view(['POST'])
@ -22,7 +22,8 @@ def markStatus(request, id, email, user_type):
application.selected = True if i[STUDENT_SELECTED] == "true" else False
email = str(application.student.roll_no) + "@iitdh.ac.in" # Only allowing for IITDh emails
subject = STUDENT_APPLICATION_STATUS_TEMPLATE_SUBJECT.format(company_name=application.placement.company_name,
subject = STUDENT_APPLICATION_STATUS_TEMPLATE_SUBJECT.format(
company_name=application.placement.company_name,
id=application.id)
data = {
"company_name": application.placement.company_name,
@ -53,15 +54,17 @@ def markStatus(request, id, email, user_type):
def getDashboard(request, id, email, user_type):
try:
placements = Placement.objects.all().order_by('-created_at')
ongoing = placements.filter(deadline_datetime__gt=datetime.now(), offer_accepted__isnull=False)
previous = placements.exclude(deadline_datetime__gt=datetime.now()).filter(offer_accepted__isnull=False)
ongoing = placements.filter(deadline_datetime__gt=datetime.datetime.now(), offer_accepted__isnull=False)
previous = placements.exclude(deadline_datetime__gt=datetime.datetime.now()).filter(
offer_accepted__isnull=False)
new = placements.filter(offer_accepted__isnull=True)
ongoing = PlacementSerializerForAdmin(ongoing, many=True).data
previous = PlacementSerializerForAdmin(previous, many=True).data
new = PlacementSerializerForAdmin(new, many=True).data
return Response(
{'action': "Get Dashboard - Admin", 'message': "Data Found", "ongoing": ongoing, "previous": previous, "new": new},
{'action': "Get Dashboard - Admin", 'message': "Data Found", "ongoing": ongoing, "previous": previous,
"new": new},
status=status.HTTP_200_OK)
except Http404:
return Response({'action': "Get Dashboard - Admin", 'message': 'Student Not Found'},
@ -80,7 +83,7 @@ def updateDeadline(request, id, email, user_type):
data = request.data
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
# Updating deadline date with correct format in datetime field
opening.deadline_datetime = datetime.strptime(data[DEADLINE_DATETIME], '%Y-%m-%d %H:%M:%S %z')
opening.deadline_datetime = datetime.datetime.strptime(data[DEADLINE_DATETIME], '%Y-%m-%d %H:%M:%S %z')
opening.save()
return Response({'action': "Update Deadline", 'message': "Deadline Updated"},
status=status.HTTP_200_OK)
@ -92,6 +95,7 @@ def updateDeadline(request, id, email, user_type):
return Response({'action': "Update Deadline", 'message': "Something went wrong"},
status=status.HTTP_400_BAD_REQUEST)
@api_view(['POST'])
@isAuthorized([ADMIN])
@precheck([OPENING_ID, OFFER_ACCEPTED])
@ -111,6 +115,7 @@ def updateOfferAccepted(request, id, email, user_type):
return Response({'action': "Update Offer Accepted", 'message': "Something went wrong"},
status=status.HTTP_400_BAD_REQUEST)
@api_view(['POST'])
@isAuthorized([ADMIN])
@precheck([OPENING_ID, EMAIL_VERIFIED])
@ -130,6 +135,7 @@ def updateEmailVerified(request, id, email, user_type):
return Response({'action': "Update Email Verified", 'message': "Something went wrong"},
status=status.HTTP_400_BAD_REQUEST)
@api_view(['POST'])
@isAuthorized([ADMIN])
@precheck([OPENING_ID, ADDITIONAL_INFO])
@ -178,7 +184,6 @@ def getApplications(request, id, email, user_type):
status=status.HTTP_400_BAD_REQUEST)
@api_view(['POST'])
@isAuthorized(allowed_users=[ADMIN])
@precheck(required_data=[OPENING_TYPE, OPENING_ID, RESUME_FILE_NAME,
@ -195,7 +200,7 @@ def submitApplication(request, id, email, user_type):
opening = get_object_or_404(Placement, id=data[OPENING_ID],
allowed_batch__contains=[student.batch],
allowed_branch__contains=[student.branch],
deadline_datetime__gte=datetime.now().date()
deadline_datetime__gte=datetime.datetime.now().date()
)
if not opening.offer_accepted or not opening.email_verified:
raise PermissionError("Placement Not Approved")
@ -252,7 +257,6 @@ def submitApplication(request, id, email, user_type):
status=status.HTTP_400_BAD_REQUEST)
@api_view(['POST'])
@isAuthorized(allowed_users=[ADMIN])
@precheck(required_data=[OPENING_ID])

View File

@ -1,5 +1,4 @@
import json
import datetime
from rest_framework.decorators import api_view
@ -178,7 +177,8 @@ def addPlacement(request):
else:
raise ValueError('Invalid compensation gross')
# Convert to date object
opening.tentative_date_of_joining = datetime.datetime.strptime(data[TENTATIVE_DATE_OF_JOINING], '%d-%m-%Y').date()
opening.tentative_date_of_joining = datetime.datetime.strptime(data[TENTATIVE_DATE_OF_JOINING],
'%d-%m-%Y').date()
# Only Allowing Fourth Year for Placement
opening.allowed_batch = [FOURTH_YEAR, ]
@ -202,8 +202,6 @@ def addPlacement(request):
opening.save()
stat, link = generateOneTimeVerificationLink(opening.email, opening.id, "Placement")
if not stat:
raise RuntimeError("Error in generating one time verification link for placement")
@ -226,6 +224,7 @@ def addPlacement(request):
return Response({'action': "Add Placement", 'message': "Something went wrong"},
status=status.HTTP_400_BAD_REQUEST)
@api_view(['POST'])
@precheck([TOKEN])
def verifyEmail(request):

View File

@ -5,10 +5,10 @@ import random
import re
import string
import sys
import jwt
from os import path, remove
import background_task
import jwt
from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.http import Http404