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

(Academic module)made some changes in allot courses after add and drop #1705

Merged
merged 1 commit into from
Feb 4, 2025
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
32 changes: 25 additions & 7 deletions FusionIIIT/applications/academic_procedures/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1754,40 +1754,58 @@ def allot_courses_after_add_and_drop(request):
try:
if request.method == 'POST' and request.FILES:
profiles=request.FILES['allotedCourses']
sem_no=int(request.POST['semester'])
working_year =int(request.POST['working_year'])
excel = xlrd.open_workbook(file_contents=profiles.read())
sheet=excel.sheet_by_index(0)
course_registrations=[]
course_registrations=[]
final_registrations=[]
pre_registrations=[]
student_checks=[]
currroll=set()
print(sheet.nrows)
for i in range(1,sheet.nrows):
roll_no = str(sheet.cell(i,0).value).split(".")[0]
course_slot_name = sheet.cell_value(i,1)
course_code = sheet.cell_value(i,2)
try:

user=User.objects.get(username=roll_no)
user_info = ExtraInfo.objects.get(user=user)
student = Student.objects.get(id=user_info)
batch=student.batch_id
sem_id=Semester.objects.get(curriculum=batch.curriculum,semester_no=sem_no)
sem_id=Semester.objects.get(curriculum=batch.curriculum,semester_no=student.curr_semester_no)
course_slot=CourseSlot.objects.get(name=course_slot_name.strip(),semester=sem_id)
course = course_slot.courses.get(code=course_code.strip())

if(roll_no not in currroll):
student_check=StudentRegistrationChecks(student_id = student, semester_id = sem_id, pre_registration_flag = True,final_registration_flag = True)
student_checks.append(student_check)
currroll.add(roll_no)
except Exception as e:
print('----------------------' , e)



pre_registration=InitialRegistration(student_id=student,course_slot_id=course_slot,
course_id=course,semester_id=sem_id,priority=1)
pre_registrations.append(pre_registration)
final_registration=FinalRegistration(student_id=student,course_slot_id=course_slot,
course_id=course,semester_id=sem_id, verified=True )
final_registrations.append(final_registration)
courseregistration=course_registration(working_year=working_year,course_id=course,semester_id=sem_id,student_id=student,course_slot_id=course_slot)
course_registrations.append(courseregistration)


try:
course_registration.objects.bulk_create(course_registrations)
with transaction.atomic():
InitialRegistration.objects.bulk_create(pre_registrations)
StudentRegistrationChecks.objects.bulk_create(student_checks)
FinalRegistration.objects.bulk_create(final_registrations)
course_registration.objects.bulk_create(course_registrations)
messages.success(request, 'Successfully uploaded!')
return HttpResponseRedirect('/academic-procedures/main')
# return HttpResponse("Success")
except Exception as e:
messages.error(request, 'Error: '+str(e))
return HttpResponseRedirect('/academic-procedures/main')
# return HttpResponse("Success")
except Exception as e:
messages.error(request, 'Error: Query does not match. Please check if all the data input is in the correct format.')
return HttpResponseRedirect('/academic-procedures/main')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,6 @@ <h4 class="ui blue header">Note : Provide the data in Excel Sheet in following f
<h4 class="ui dividing header"><a href="../media/Administrator/academic_procedures/sample_courses_allotment.xls">Download</a>
the sample Excel, fill the data accordingly and then upload the same</h4>
</div>

<div class="field">
<label>Semester</label>
<select class="ui dropdown" required="true" name="semester">
<option value="NULL" class="sem">Select Semester</option>
<option value="1" class="sem">1</option>
<option value="2" class="sem">2</option>
<option value="3" class="sem">3</option>
<option value="4" class="sem">4</option>
<option value="5" class="sem">5</option>
<option value="6" class="sem">6</option>
<option value="7" class="sem">7</option>
<option value="8" class="sem">8</option>
</select>
</div>
<div class="field">
<label>Working Year</label>
<input type="number" id="working_year" name="working_year" required="true">
Expand Down