Skip to content

Commit

Permalink
Merge pull request #1645 from ChallaBharadwajReddy/latest_staging
Browse files Browse the repository at this point in the history
Corrections for open ellective allocation
  • Loading branch information
dvjsharma authored Nov 6, 2024
2 parents e91aeee + e524982 commit f9d17b7
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 12 deletions.
1 change: 1 addition & 0 deletions FusionIIIT/applications/academic_information/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@
url(r'^api/',include('applications.academic_information.api.urls')),
url(r'^view_all_student_data', views.view_all_student_data, name='view_all_student_data'),
url(r'^generateStudentSheet$',views.generatestudentxlsheet, name = 'generatestudentxlsheet'),
url(r'^course_allocated_students$',views.get_excel, name = 'course_allocated_students'),
]
22 changes: 11 additions & 11 deletions FusionIIIT/applications/academic_information/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,20 @@ def allocate(request) :
unique_course_name = []
try:
with transaction.atomic() :
for course_slot in unique_course_slot :
course_slot_object = CourseSlot.objects.get(id=course_slot)
if course_slot_object.type == "Professional 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)
if(stat == -1) :
raise Exception("seats not enough for course_slot"+str(course_slot_object.name))
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
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)
if(stat == -1) :
print(course_slot_object.name)
raise Exception("seats not enough for course_slot"+str(course_slot_object.name))

return JsonResponse({'status': 1 , 'message' : "course allocation successful"})
except:
return JsonResponse({'status': -1 , 'message' : "seats not enough for course_slot"+str(course_slot_object.name) })


return JsonResponse({'status': -1 , 'message' : "seats not enough for some course_slot"})

def view_alloted_course(request) :
batch = request.POST.get('batch')
sem = request.POST.get('sem')
Expand Down
45 changes: 45 additions & 0 deletions FusionIIIT/applications/academic_information/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,52 @@ def generate_preregistration_report(request):
st = 'attachment; filename = ' + batch.name + batch.discipline.acronym + str(batch.year) + '-preresgistration.xlsx'
response['Content-Disposition'] = st
return response

@login_required
def get_excel(request):
batch = request.POST.get('batch-check-view')
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))
return_list = []
for registration in registrations:
return_list.append(registration.student_id.id.id)

return_list.sort()
output = BytesIO()

book = Workbook(output,{'in_memory':True})
title = book.add_format({'bold': True,
'font_size': 22,
'align': 'center',
'valign': 'vcenter'})
subtitle = book.add_format({'bold': True,
'font_size': 15,
'align': 'center',
'valign': 'vcenter'})
normaltext = book.add_format({'bold': False,
'font_size': 15,
'align': 'center',
'valign': 'vcenter'})
sheet = book.add_worksheet()
sheet.set_default_row(25)
sheet.write_string('A1','Student Roll no',subtitle)
sheet.write_string('B1','Student name',subtitle)
k=2
for no in return_list :
student= User.objects.get(username=no)
sheet.write_string('A'+str(k),no,normaltext)
sheet.write_string('B'+str(k),student.first_name+student.last_name,normaltext)
k+=1

book.close()
output.seek(0)

response = HttpResponse(output.read(),content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
response['Content-Disposition'] = 'attachment; filename='+ course +'_student_list.xlsx'
response['Content-Transfer-Encoding'] = 'binary'
return response

@login_required
def add_new_profile (request):
Expand Down
10 changes: 9 additions & 1 deletion FusionIIIT/templates/ais/start_elective_allocation.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</div>
<div class="ui tab segment " data-tab="view-allocation">
<div class="ui vertical segment">
<form class="ui form" method="post" id="allocation-check">
<form class="ui form" method="post" id="allocation-check" action="/aims/course_allocated_students">
{% csrf_token %}
<div class="field">
<label>Batch</label>
Expand All @@ -72,6 +72,11 @@
View allocation
</button>
</div>
<div class="field">
<button id="download-allocation-view" type="submit" class="ui fluid primary button">
download allocation list
</button>
</div>
</form>
<div>
<table>
Expand Down Expand Up @@ -138,6 +143,9 @@
if(data.status == -1){
alert("not enough seats to allocate students")
}
else{
alert("allocation done")
}
}
})
})
Expand Down

0 comments on commit f9d17b7

Please sign in to comment.