Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest staging #1646

Merged
merged 7 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions FusionIIIT/applications/academic_information/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def check_for_registration_complete (request):
if date>=prd_start_date and date<=prd_end_date:
return JsonResponse({'status':-1 , "message":"registration is under process"})

if course_registration.objects.filter(Q(semester_id__semester_no = sem) & Q(student_id__batch = batch)).exists() :
if FinalRegistration.objects.filter(Q(semester_id__semester_no = sem) & Q(student_id__batch = batch)).exists() :
return JsonResponse({'status':2,"message":"courses already allocated"})

return JsonResponse({"status":1 , "message" : "courses not yet allocated"})
Expand Down Expand Up @@ -78,9 +78,9 @@ def random_algo(batch,sem,year,course_slot) :
course_object = Course.objects.get(id=course)
course_slot_object = CourseSlot.objects.get(id = random_student_selected[1])
semester_object = Semester.objects.get(Q(semester_no = sem) & Q(curriculum = curriculum_object))
course_registration.objects.create(
FinalRegistration.objects.create(
student_id = stud,
working_year = year,
verified=False,
semester_id = semester_object,
course_id = course_object,
course_slot_id = course_slot_object
Expand All @@ -107,7 +107,36 @@ def allocate(request) :
with transaction.atomic() :
for course_slot in unique_course_slot :
course_slot_object = CourseSlot.objects.get(id=course_slot)
if course_slot_object.type == "Open Elective": # Runs only for open elective course slots
print(course_slot_object)
if course_slot_object.type != "Open Elective":
# Fetch students registered in this course slot
students = InitialRegistration.objects.filter(
Q(semester_id__semester_no=sem) &
Q(course_slot_id=course_slot_object) &
Q(student_id__batch=batch)
).values_list('student_id', flat=True)

# Allocate each student directly to FinalRegistration
for student_id in students:
student = Student.objects.get(id=student_id)
semester = Semester.objects.get(semester_no=sem, curriculum=student.batch_id.curriculum)
print(semester.id)
# course = Course.objects.get(id=course_slot_object.courses.id)
course_id = course_slot_object.courses.values_list('id', flat=True).first()
# Retrieve the Course instance
course = Course.objects.get(id=course_id)

# Insert directly into FinalRegistration
FinalRegistration.objects.create(
student_id=student,
verified=False,
semester_id=semester,
course_id=course,
course_slot_id=course_slot_object
)

unique_course_name.append(course_slot_object.name)
elif course_slot_object.type == "Open Elective": # Runs only for open elective course slots
if course_slot_object.name not in unique_course_name:
stat = random_algo(batch,sem,year,course_slot_object.name)
unique_course_name.append(course_slot_object.name)
Expand All @@ -122,10 +151,10 @@ def allocate(request) :
def view_alloted_course(request) :
batch = request.POST.get('batch')
sem = request.POST.get('sem')
year = request.POST.get('year')
verified = request.POST.get('year')
course = request.POST.get('course')

registrations = course_registration.objects.filter(Q(student_id__batch = batch) & Q(working_year = year) & Q(semester_id__semester_no = sem) & Q(course_id__code = course))
registrations = FinalRegistration.objects.filter(Q(student_id__batch = batch) & Q(semester_id__semester_no = sem) & Q(course_id__code = course))
return_list = []
for registration in registrations:
obj = {
Expand Down
4 changes: 2 additions & 2 deletions FusionIIIT/applications/academic_information/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from django.template.loader import render_to_string
from django.contrib.auth.decorators import login_required

from applications.academic_procedures.models import MinimumCredits, Register, InitialRegistration, course_registration, AssistantshipClaim,Assistantship_status
from applications.academic_procedures.models import MinimumCredits, Register, InitialRegistration, course_registration, AssistantshipClaim,Assistantship_status,FinalRegistration
from applications.globals.models import (Designation, ExtraInfo,
HoldsDesignation, DepartmentInfo)

Expand Down Expand Up @@ -1156,7 +1156,7 @@ def get_excel(request):
sem = request.POST.get('semester-check-view')
year = request.POST.get('year-check-view')
course = request.POST.get('Course-check-view')
registrations = course_registration.objects.filter(Q(student_id__batch = batch) & Q(working_year = year) & Q(semester_id__semester_no = sem) & Q(course_id__code = course))
registrations = FinalRegistration.objects.filter(Q(student_id__batch = batch) & Q(semester_id__semester_no = sem) & Q(course_id__code = course))
return_list = []
for registration in registrations:
return_list.append(registration.student_id.id.id)
Expand Down
Loading