diff --git a/FusionIIIT/applications/academic_information/urls.py b/FusionIIIT/applications/academic_information/urls.py index ea984242e..3e8c2eecb 100755 --- a/FusionIIIT/applications/academic_information/urls.py +++ b/FusionIIIT/applications/academic_information/urls.py @@ -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'), ] diff --git a/FusionIIIT/applications/academic_information/utils.py b/FusionIIIT/applications/academic_information/utils.py index 2fed73044..77323538a 100644 --- a/FusionIIIT/applications/academic_information/utils.py +++ b/FusionIIIT/applications/academic_information/utils.py @@ -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') diff --git a/FusionIIIT/applications/academic_information/views.py b/FusionIIIT/applications/academic_information/views.py index f4ef54b5f..021214732 100755 --- a/FusionIIIT/applications/academic_information/views.py +++ b/FusionIIIT/applications/academic_information/views.py @@ -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): diff --git a/FusionIIIT/templates/ais/start_elective_allocation.html b/FusionIIIT/templates/ais/start_elective_allocation.html index dc59fb411..29d48a2cf 100644 --- a/FusionIIIT/templates/ais/start_elective_allocation.html +++ b/FusionIIIT/templates/ais/start_elective_allocation.html @@ -49,7 +49,7 @@
-
+ {% csrf_token %}
@@ -72,6 +72,11 @@ View allocation
+
+ +
@@ -138,6 +143,9 @@ if(data.status == -1){ alert("not enough seats to allocate students") } + else{ + alert("allocation done") + } } }) })