From 207706dc5cb521fa00e2d9460af355712cbb015b Mon Sep 17 00:00:00 2001 From: Harshul Date: Fri, 17 Jan 2025 17:39:46 +0530 Subject: [PATCH] (academics):restricted the page reload for acad admin drop courses feature and sorted courses --- .../applications/academic_procedures/views.py | 2 +- .../academic_procedures/studentCourses.html | 73 +++++++++++++------ 2 files changed, 51 insertions(+), 24 deletions(-) diff --git a/FusionIIIT/applications/academic_procedures/views.py b/FusionIIIT/applications/academic_procedures/views.py index 4ec95339d..0fda5adee 100644 --- a/FusionIIIT/applications/academic_procedures/views.py +++ b/FusionIIIT/applications/academic_procedures/views.py @@ -2168,7 +2168,7 @@ def get_currently_registered_course(id, sem_id, courseregobj=False): if (type(sem_id) == int): obj = course_registration.objects.all().filter(student_id = id, semester_id__semester_no=sem_id) else: - obj = course_registration.objects.all().filter(student_id = id) + obj = course_registration.objects.all().filter(student_id = id).order_by('-semester_id_id') courses = [] for i in obj: if (courseregobj): diff --git a/FusionIIIT/templates/academic_procedures/studentCourses.html b/FusionIIIT/templates/academic_procedures/studentCourses.html index c79d4a39a..af772c539 100644 --- a/FusionIIIT/templates/academic_procedures/studentCourses.html +++ b/FusionIIIT/templates/academic_procedures/studentCourses.html @@ -10,28 +10,42 @@ .modal('show') ; }); - }); - function courseDropCalled(event) { - // Prevent the default action of the link - event.preventDefault(); - - // Get the URL from the link's href attribute - let url = event.target.href; - - // Perform AJAX request - $.ajax({ - url: url, - type: 'GET', - success: function(data) { - // Reload the page after successful deletion - location.reload(); - }, - error: function(xhr, status, error) { - // Handle errors if needed - console.error(error); - } + let url = ""; + let rowToDelete; + $('.trigger-link-acad').on('click', function (event) { + event.preventDefault(); // Prevent the default behavior of the link + url = event.target.href + rowToDelete = $(this).closest('tr'); + course_name = $(this).attr('course_name_stu') + course_code = $(this).attr('course_code_stu') + $('.course_details_stu').html('Are you sure you want to drop '+course_code+'-'+course_name +'?'); + $('#confirmation-modal-acad').modal('show'); // Show the modal }); - } + + // Handle Cancel button + $('#cancel-button-acad-course').on('click', function () { + $('#confirmation-modal-acad').modal('hide'); // Hide the modal + }); + + // Handle OK button + $('#confirm-button-acad').on('click', function () { + $('#confirmation-modal-acad').modal('hide'); // Hide the modal + + // Perform AJAX API call + $.ajax({ + url: url, + type: 'GET', + success: function(data) { + rowToDelete.remove(); + alert('course dropped successfully') + }, + error: function(xhr, status, error) { + // Handle errors if needed + console.error(error); + } + }); + }); + }); @@ -110,8 +124,8 @@ {{ items.registration_type }} - + DROP @@ -190,5 +204,18 @@ + + + + \ No newline at end of file