Compare commits

...

17 Commits

Author SHA1 Message Date
Challenger 1b1543d2af
Merge f0a02ec2d0 into 90f028651d 2024-11-30 23:38:21 +00:00
Jaya Surya P 90f028651d
Merge pull request #207 from CDC-IITDH/nitin
fixed add/edit application & markstatus issue in intenship
2024-10-25 22:55:13 +05:30
NitinVangipuram 3d42366e50 fixed export csv error 2024-10-25 22:54:22 +05:30
NitinVangipuram 95d7689a4c fixed add/edit application & markstatus issue in intenship 2024-10-24 20:10:02 +05:30
Jaya Surya P 642ad8e326
Merge pull request #206 from CDC-IITDH/nitin
fixed submit application error
2024-10-08 19:03:48 +05:30
NitinVangipuram 8aa7246ec9 fixed submit application error 2024-10-08 19:01:34 +05:30
Jaya Surya P e184d2af53
Merge pull request #205 from CDC-IITDH/nitin
fixed submit application error for Mtech ,Ms
2024-10-05 09:34:53 +05:30
NitinVangipuram e717cbc6e6 Merge branch 'main' of https://github.com/CDC-IITDH/cdc-placement-website-backend into nitin 2024-10-02 17:11:13 +05:30
NitinVangipuram e242fff9a7 fixed submit application error 2024-10-02 17:10:27 +05:30
Jaya Surya P 4c248be3a5
Merge pull request #204 from CDC-IITDH/nitin
fixed stats
2024-09-26 17:00:02 +05:30
Jaya Surya P 7eee78177c
Merge branch 'main' into nitin 2024-09-26 16:59:55 +05:30
NitinVangipuram ce97fc8342 fixed stats 2024-09-26 12:18:55 +05:30
Challenger f0a02ec2d0 Updated checks for script arguments 2023-06-09 18:55:55 +05:30
Challenger 35391e6173 Merge branch 'sample_data' of https://github.com/CDC-IITDH/cdc-placement-website-backend into sample_data 2023-06-09 18:46:48 +05:30
Challenger 1da13d787f Changed the format to get input 2023-06-09 18:38:01 +05:30
Challenger 70711888ea Using constants from APIs/constants.py now 2023-06-09 00:14:56 +05:30
Challenger 609eb1a159 Added add_students script to add sample students 2023-06-08 23:58:11 +05:30
3 changed files with 112 additions and 24 deletions

View File

@ -310,13 +310,17 @@ def submitApplication(request, id, email, user_type):
try: try:
data = request.data data = request.data
if OPENING_TYPE in data: if OPENING_TYPE in data:
opening_type= data[OPENING_TYPE] if data[OPENING_TYPE] == "Internship":
opening_type= "Internship"
elif data[OPENING_TYPE] == "placements":
opening_type= "Placement"
else: else:
opening_type= "Placement" opening_type= "Placement"
if opening_type == "Internship": if opening_type == "Internship":
opening = get_object_or_404(Internship, pk=data[OPENING_ID]) opening = get_object_or_404(Internship, pk=data[OPENING_ID])
else: else:
opening = get_object_or_404(Placement, pk=data[OPENING_ID]) opening = get_object_or_404(Placement, pk=data[OPENING_ID])
# print(opening);
student = get_object_or_404(Student, pk=data[STUDENT_ID]) student = get_object_or_404(Student, pk=data[STUDENT_ID])
# opening = get_object_or_404(Placement, pk=data[OPENING_ID]) # opening = get_object_or_404(Placement, pk=data[OPENING_ID])
student_user = get_object_or_404(User, id=student.id) student_user = get_object_or_404(User, id=student.id)
@ -446,8 +450,7 @@ def generateCSV(request, id, email, user_type):
row_details.append(apl.selected) row_details.append(apl.selected)
for i in opening.additional_info: for i in opening.additional_info:
row_details.append(json.loads(apl.additional_info)[i]) row_details.append(json.loads(apl.additional_info).get(i, ''))
writer.writerow(row_details) writer.writerow(row_details)
f.close() f.close()
file_path = LINK_TO_APPLICATIONS_CSV + urllib.parse.quote_plus(filename + ".csv") file_path = LINK_TO_APPLICATIONS_CSV + urllib.parse.quote_plus(filename + ".csv")
@ -623,6 +626,17 @@ def getStats(request, id, email, user_type):
"psu":0, "psu":0,
}, },
"EP":{
"1":0,
"2":0,
"3":0,
"4":0,
"5":0,
"6":0,
"7":0,
"8":0,
"psu":0,
},
"Total": { "Total": {
"1":0, "1":0,
"2":0, "2":0,
@ -639,6 +653,7 @@ def getStats(request, id, email, user_type):
"CSE": 0, "CSE": 0,
"EE": 0, "EE": 0,
"MMAE": 0, "MMAE": 0,
"EP": 0,
"Total": 0, "Total": 0,
} }
number_of_students_with_multiple_offers = 0 number_of_students_with_multiple_offers = 0
@ -646,22 +661,26 @@ def getStats(request, id, email, user_type):
"CSE": 0, "CSE": 0,
"EE": 0, "EE": 0,
"MMAE": 0, "MMAE": 0,
"EP": 0,
"Total": 0, "Total": 0,
} }
max_CTC = { max_CTC = {
"CSE": 0, "CSE": 0,
"EE": 0, "EE": 0,
"MMAE": 0 "MMAE": 0,
"EP": 0,
} }
average_CTC = { average_CTC = {
"CSE": 0, "CSE": 0,
"EE": 0, "EE": 0,
"MMAE": 0 "MMAE": 0,
"EP": 0,
} }
count = { count = {
"CSE": 0, "CSE": 0,
"EE": 0, "EE": 0,
"MMAE": 0 "MMAE": 0,
"EP": 0,
} }

View File

@ -116,7 +116,6 @@ def getDashboard(request, id, email, user_type):
placements = Placement.objects.filter(filters).order_by('deadline_datetime') placements = Placement.objects.filter(filters).order_by('deadline_datetime')
filtered_placements = placement_eligibility_filters(studentDetails, placements) filtered_placements = placement_eligibility_filters(studentDetails, placements)
placementsdata = PlacementSerializerForStudent(filtered_placements, many=True).data placementsdata = PlacementSerializerForStudent(filtered_placements, many=True).data
placementApplications = PlacementApplication.objects.filter(student_id=id).order_by('-updated_at') placementApplications = PlacementApplication.objects.filter(student_id=id).order_by('-updated_at')
@ -129,13 +128,7 @@ def getDashboard(request, id, email, user_type):
email_verified=True email_verified=True
).order_by('deadline_datetime') ).order_by('deadline_datetime')
else: else:
internships = Internship.objects.filter( internships = Internship.objects.filter(filters).order_by('deadline_datetime')
allowed_batch__contains=[studentDetails.batch],
allowed_branch__contains=[studentDetails.branch],
deadline_datetime__gte=datetime.datetime.now(),
offer_accepted=True,
email_verified=True
).order_by('deadline_datetime')
filtered_internships = internship_eligibility_filters(studentDetails, internships) filtered_internships = internship_eligibility_filters(studentDetails, internships)
@ -207,11 +200,14 @@ def submitApplication(request, id, email, user_type):
if not len(PlacementApplication.objects.filter( if not len(PlacementApplication.objects.filter(
student_id=id, placement_id=data[OPENING_ID])): student_id=id, placement_id=data[OPENING_ID])):
application = PlacementApplication() application = PlacementApplication()
opening = get_object_or_404(Placement, id=data[OPENING_ID], application_filters = Q(
allowed_batch__contains=[student.batch], id=data[OPENING_ID],
allowed_branch__contains=[student.branch], allowed_branch__contains=[student.branch],
deadline_datetime__gte=timezone.now() deadline_datetime__gte=timezone.now()
) )
if student.degree == "Btech":
application_filters &= Q(allowed_batch__contains=[student.batch])
opening = get_object_or_404(Placement.objects.filter(application_filters))
if not opening.offer_accepted or not opening.email_verified: if not opening.offer_accepted or not opening.email_verified:
raise PermissionError("Placement Not Approved") raise PermissionError("Placement Not Approved")
@ -228,11 +224,14 @@ def submitApplication(request, id, email, user_type):
if not len(InternshipApplication.objects.filter( if not len(InternshipApplication.objects.filter(
student_id=id, internship_id=data[OPENING_ID])): student_id=id, internship_id=data[OPENING_ID])):
application = InternshipApplication() application = InternshipApplication()
opening = get_object_or_404(Internship, id=data[OPENING_ID], application_filters = Q(
allowed_batch__contains=[student.batch], id=data[OPENING_ID],
allowed_branch__contains=[student.branch], allowed_branch__contains=[student.branch],
deadline_datetime__gte=timezone.now() deadline_datetime__gte=timezone.now()
) )
if student.degree == "Btech":
application_filters &= Q(allowed_batch__contains=[student.batch])
opening = get_object_or_404(Internship.objects.filter(application_filters))
if not opening.offer_accepted or not opening.email_verified: if not opening.offer_accepted or not opening.email_verified:
raise PermissionError("Internship Not Approved") raise PermissionError("Internship Not Approved")

View File

@ -0,0 +1,70 @@
import random
from django.db.utils import IntegrityError
from APIs.models import Student
from APIs.constants import BRANCHES, BATCH_CHOICES, DEGREE_CHOICES
# To run this script run the following command:
# python manage.py runscript add_students --script-args <add_type> <num_of_stundents_to_add>
def run(*args):
# Throw error if invalid number of arguments passed
if not args:
raise ValueError("Invalid number of arguments passed")
if args[0] in ("manual", "man") :
if len(args) != 2 or not args[1].isdigit() or int(args[1]) < 1:
raise ValueError("Invalid number of arguments passed")
print("id\troll_no\tname\tbranch\tphone_number\tcpi\tdegree\tbatch")
for i in range(1, int(args[1])+1):
details = input()
details = details.split(",")
details = [i.strip() for i in details]
details = [int(details[0]), int(details[1]), details[2], details[3],
int(details[4]), float(details[5]), details[6], details[7]]
student = Student.objects.create(
id = details[0],
roll_no = details[1],
name = details[2],
branch = details[3],
phone_number = details[4],
cpi = details[5],
degree = details[6],
batch = details[7],
)
student.save()
elif args[0] in ("auto", "automatic"):
if len(args) != 2 or not args[1].isdigit() or int(args[1]) < 1:
raise ValueError("Invalid number of arguments passed")
for i in range(1, int(args[1])+1):
try:
student = Student.objects.create(
id = i-1,
roll_no = 220010000 + i,
name = "Student " + str(i),
branch = random.choice(BRANCHES),
phone_number = random.randint(1000000000, 9999999999),
cpi = random.random()*10,
degree = random.choice(DEGREE_CHOICES)[0],
batch = random.choice(BATCH_CHOICES)[0],
)
student.save()
except IntegrityError:
pass
elif args[0] in ("del", "delete"):
# delete students with name starting with Student
s = Student.objects.filter(name__startswith="Stundent")
s.delete()
else:
raise ValueError("Invalid argument passed")