Skip to content

Commit

Permalink
Merge pull request #1580 from FusionIIIT/ac-2
Browse files Browse the repository at this point in the history
Minor bug fix in AC-2 to latest_staging
  • Loading branch information
prabhatsuman authored Apr 27, 2024
2 parents 69b987d + 447de08 commit 35408d2
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 37 deletions.
31 changes: 21 additions & 10 deletions FusionIIIT/applications/academic_information/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from applications.academic_procedures.views import acad_proced_global_context , get_sem_courses
from applications.programme_curriculum.models import Batch

from django.db.models import Q


@login_required
Expand Down Expand Up @@ -845,6 +845,8 @@ def generatexlsheet(request):
# print(request.POST)
try:
batch = request.POST['batch']#batch hai year wala (2020 , 21)
if batch == "":
batch = datetime.datetime.now().year
course_id = int(request.POST['course']) # id of course in integer
course = course = Courses.objects.get(id=course_id)

Expand All @@ -858,17 +860,26 @@ def generatexlsheet(request):
obj=""

registered_courses = []
for i in obj:
if i.student_id.batch_id.year == int(batch):
registered_courses.append(i)
registered_courses = course_registration.objects.filter(
Q(working_year=int(batch)) &
Q(course_id=course) &
Q(student_id__finalregistration__verified=True)
)

# for i in obj:
# if i.student_id.batch_id.year == int(batch):
# registered_courses.append(i)
ans = []
student_ids = set()
for i in registered_courses:
k = []
k.append(i.student_id.id.id)
k.append(i.student_id.id.user.first_name)
k.append(i.student_id.id.user.last_name)
k.append(i.student_id.id.department)
ans.append(k)
if i.student_id.id.id not in student_ids:
student_ids.add(i.student_id.id.id )
k = []
k.append(i.student_id.id.id)
k.append(i.student_id.id.user.first_name)
k.append(i.student_id.id.user.last_name)
k.append(i.student_id.id.department)
ans.append(k)
ans.sort()
output = BytesIO()

Expand Down
43 changes: 26 additions & 17 deletions FusionIIIT/applications/academic_procedures/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Student_attendance)

from applications.central_mess.models import(Monthly_bill, Payments)

from applications.online_cms.models import (Student_grades)
from applications.programme_curriculum.models import (CourseSlot, Course as Courses, Batch, Semester , CourseInstructor)
from applications.globals.models import (DepartmentInfo, Designation,
ExtraInfo, Faculty, HoldsDesignation)
Expand Down Expand Up @@ -478,11 +478,11 @@ def academic_procedures_student(request):
cur_spi='Sem results not available' # To be fetched from db if result uploaded

backlogCourseList = []
auto_backlog_courses = list(SemesterMarks.objects.filter(student_id = obj , grade = 'F'))
auto_backlog_courses = list(Student_grades.objects.filter(roll_no = obj , grade = 'F'))
auto_backlog_courses_list = []
for i in auto_backlog_courses:
if not i.curr_id.courseslots.filter(type__contains="Optional").exists():
auto_backlog_courses_list.append([i.curr_id.name, i.curr_id.code, i.curr_id.version, i.curr_id.credit , i.grade])
if not i.course_id.courseslots.filter(type__contains="Optional").exists():
auto_backlog_courses_list.append([i.course_id.name, i.course_id.code, i.course_id.version, i.course_id.credit , i.grade])

backlogCourses = backlog_course.objects.select_related('course_id' , 'student_id' , 'semester_id' ).filter(student_id=obj)
for i in backlogCourses:
Expand Down Expand Up @@ -916,21 +916,30 @@ def gen_course_list(request):
course_id = request.POST['course']
course = Courses.objects.get(id = course_id)
#obj = course_registration.objects.all().filter(course_id = course)
obj=course_registration.objects.filter(course_id__id=course_id, student_id__batch=batch).select_related(
obj=course_registration.objects.filter(course_id__id=course_id, working_year=batch).select_related(
'student_id__id__user','student_id__id__department').only('student_id__batch',
'student_id__id__user__first_name', 'student_id__id__user__last_name',
'student_id__id__department__name','student_id__id__user__username')
except Exception as e:
batch=""
course=""
obj=""
students = []
for i in obj:
students.append({"rollno":i.student_id.id.user.username,
"name":i.student_id.id.user.first_name+" "+i.student_id.id.user.last_name,
"department":i.student_id.id.department.name})
verified_students = []
for registration in obj:
final_registration = FinalRegistration.objects.filter(
course_id=course,
semester_id=registration.semester_id,
student_id=registration.student_id,
verified=True
).exists()
if final_registration:
verified_students.append({
"rollno": registration.student_id.id.user.username,
"name": registration.student_id.id.user.first_name + " " + registration.student_id.id.user.last_name,
"department": registration.student_id.id.department.name
})
html = render_to_string('academic_procedures/gen_course_list.html',
{'students': students, 'batch':batch, 'course':course_id}, request)
{'students': verified_students, 'batch':batch, 'course':course_id}, request)
maindict = {'html': html}
obj = json.dumps(maindict)
return HttpResponse(obj, content_type='application/json')
Expand Down Expand Up @@ -2584,7 +2593,7 @@ def verify_registration(request):
sem_no = student.curr_semester_no+1
sem_id = Semester.objects.get(curriculum = curr_id, semester_no = sem_no)
with transaction.atomic():
academicadmin = get_object_or_404(User, username = "acadadmin")
academicadmin = get_object_or_404(User, username = request.user.username)
FinalRegistration.objects.filter(student_id = student_id, verified = False, semester_id = sem_id).delete()
StudentRegistrationChecks.objects.filter(student_id = student_id, semester_id = sem_id).update(final_registration_flag = False)
FeePayments.objects.filter(student_id = student_id, semester_id = sem_id).delete()
Expand Down Expand Up @@ -2632,7 +2641,7 @@ def auto_verify_registration(request):
sem_no = student_id.curr_semester_no+1
sem_id = Semester.objects.get(curriculum = curr_id, semester_no = sem_no)
with transaction.atomic():
academicadmin = get_object_or_404(User, username = "acadadmin")
academicadmin = get_object_or_404(User, username = request.user.username)
# FinalRegistration.objects.filter(student_id = student_id, verified = False, semester_id = sem_id).delete()
StudentRegistrationChecks.objects.filter(student_id = student_id, semester_id = sem_id).update(final_registration_flag = False)
FeePayments.objects.filter(student_id = student_id, semester_id = sem_id).delete()
Expand Down Expand Up @@ -3775,8 +3784,8 @@ def add_course_to_slot(request):
course_code = data.get('course_name')
# print('-----------------------------------------------------------------------------------------' , course_slot_name , course_code)
try:
course_slot = CourseSlot.objects.get(name=course_slot_name)
course = Courses.objects.get(code=course_code)
course_slot = CourseSlot.objects.filter(name=course_slot_name).first()
course = Courses.objects.filter(code=course_code).first()
course_slot.courses.add(course)

return JsonResponse({'message': f'Course {course_code} added to slot {course_slot_name} successfully.'}, status=200)
Expand All @@ -3795,8 +3804,8 @@ def remove_course_from_slot(request):
course_code = data.get('course_name')
# print('-----------------------------------------------------------------------------------------' , course_slot_name , course_code)
try:
course_slot = CourseSlot.objects.get(name=course_slot_name)
course = Courses.objects.get(code=course_code)
course_slot = CourseSlot.objects.filter(name=course_slot_name).first()
course = Courses.objects.filter(code=course_code).first()
course_slot.courses.remove(course)
return JsonResponse({'message': f'Course {course_code} removed from slot {course_slot_name} successfully.'}, status=200)
except CourseSlot.DoesNotExist:
Expand Down
6 changes: 3 additions & 3 deletions FusionIIIT/templates/academic_procedures/academicfac.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<td colspan="2"><h4>Programme</h4></td>

<td colspan="2"><h4>Branch</h4></td>
<td colspan="2"><h4>Year</h4></td>
<!-- <td colspan="2"><h4>Year</h4></td> -->

<td colspan="2"><h4>Download Roll List</h4></td>

Expand All @@ -99,15 +99,15 @@
<td colspan="2"> {{course.course_id.version }}</td>
<td colspan="2"> {{course.batch_id.name }}</td>
<td colspan="2"> {{course.batch_id.discipline.name }}</td>
<td colspan="2"> {{course.batch_id.year }}</td>
<!-- <td colspan="2"> {{course.batch_id.year }}</td> -->

<!-- <td colspan="2"><a href="">Roll List</a></td> -->

<td colspan="2">
<form method="post" action="/aims/generateSheet">
{% csrf_token %}
<input type="hidden" name="course" value="{{ course.course_id.id }}">
<input type="hidden" name="batch" value="{{ course.batch_id.year }}">
<input type="hidden" name="batch" value="">
<button class="ui button green" type="submit">Roll List</button>
</form>
</td>
Expand Down
14 changes: 7 additions & 7 deletions FusionIIIT/templates/ais/generateSheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<div class="ui pointing secondary menu">
<a class="active item" data-tab="this-sem">
This Semester
Roll List
</a>
<a class="item" data-tab="prereg">
Pre Registration Report
Expand All @@ -45,17 +45,17 @@
<form class="ui form" action="/academic-procedures/acad_person/gen_course_list" method="post" id="gen_form">
{% csrf_token %}
<div class="field">
<label>Batch</label>
<div class="ui fluid search selection dropdown">
<input type="hidden" id="batch" name="batch" required="true">
<i class="dropdown icon"></i>
<label>Running Year</label>
<!-- <div class="ui fluid search selection dropdown"> -->
<input type="number" id="batch" name="batch" required="true">
<!-- <i class="dropdown icon"></i>
<div class="default text">Select Batch from list</div>
<div class="menu">
{% for i in batch_grade_data.batch_grade_data %}
<div class="item" data-value="{{i.batch_list_year}}">{{i.batch_list_year}}</div>
{% endfor %}
</div>
</div>
</div> -->
<!-- </div> -->
</div>

<div class="field">
Expand Down

0 comments on commit 35408d2

Please sign in to comment.