Are you sure you want to proceed with this action? This action cannot be undone.
+diff --git a/FusionIIIT/applications/academic_procedures/api/urls.py b/FusionIIIT/applications/academic_procedures/api/urls.py index 42d825b9a..3baab2e2b 100644 --- a/FusionIIIT/applications/academic_procedures/api/urls.py +++ b/FusionIIIT/applications/academic_procedures/api/urls.py @@ -11,7 +11,8 @@ url(r'^stu/view_offered_courses' , views.view_offered_courses , name = 'student_view_offered_courses'), # url(r'^stu/backlog_courses', views.student_backlog_courses , name = 'student_backlog_courses'), url(r'^stu/add_course' , views.add_course , name ='add_course') , - url(r'^stu/drop_course' , views.drop_course , name = 'drop_course'), + url(r'^stu/drop_course/$' , views.drop_course , name = 'drop_course'), + url(r'^stu/swayam_add_course/', views.student_swayam_add_course, name = 'student_swayam_add_course'), # url(r'^stu/replaceCourse' , views.replaceCourse , name = 'replaceCourse') diff --git a/FusionIIIT/applications/academic_procedures/api/views.py b/FusionIIIT/applications/academic_procedures/api/views.py index 217b1b9ba..9273dbaa2 100644 --- a/FusionIIIT/applications/academic_procedures/api/views.py +++ b/FusionIIIT/applications/academic_procedures/api/views.py @@ -475,26 +475,62 @@ def add_course(request): return Response(data = str(e) , status= status.HTTP_500_INTERNAL_SERVER_ERROR) -@api_view(['POST']) +@api_view(['GET']) def drop_course(request): + if not request.user.is_authenticated: + return Response({'message': 'Login required '}, status=status.HTTP_400_BAD_REQUEST) + data = request.GET.get('id') + reg_id = int(data) current_user = request.user current_user = ExtraInfo.objects.all().filter(user=current_user).first() current_user = Student.objects.all().filter(id = current_user.id).first() - - courses = request.data['courses'] - - for course in courses: - try: - course_id = Courses.objects.all().filter(id=course).first() - course_registration.objects.filter(course_id = course_id, student_id = current_user).delete() - except Exception as e: - resp = {"message" : "Course drop failed", "error" : str(e)} - return Response(data = resp, status = status.HTTP_400_BAD_REQUEST) + try: + course_registration.objects.filter(id = reg_id, student_id = current_user).delete() + except Exception as e: + resp = {"message" : "Course drop failed", "error" : str(e)} + return Response(data = resp, status = status.HTTP_400_BAD_REQUEST) resp = {"message" : "Course successfully dropped"} return Response(data = resp , status = status.HTTP_200_OK) +@api_view(['POST']) +def student_swayam_add_course(request): + if not request.user.is_authenticated: + return JsonResponse({'message': 'Login required '}, status=401) + try: + current_user = request.user + current_user = ExtraInfo.objects.all().filter(user=current_user).first() + current_user = Student.objects.all().filter(id = current_user.id).first() + course_id = request.POST["course_id"] + courseslot_id = request.POST["courseslot_id"] + registration_type = request.POST["registration_type"] + if (not course_id) or (not courseslot_id) or (not registration_type): + return JsonResponse({'message': 'Enter Complete Form Details '}, status=400) + course = Courses.objects.get(id=course_id) + courseslot = CourseSlot.objects.get(id=courseslot_id) + semester_no = current_user.curr_semester_no + curr_id = current_user.batch_id.curriculum + semester = Semester.objects.get(curriculum = curr_id, semester_no = semester_no) + try: + course_registration.objects.get(course_slot_id = courseslot, student_id = current_user) + return JsonResponse({'message': 'already registered a course in course slot'}, status=400) + except: + pass + try: + course_registration.objects.get(course_id = course, student_id = current_user) + return JsonResponse({'message': 'already registered a particular course'}, status=400) + except: + pass + cr = course_registration( + course_slot_id=courseslot, course_id=course, student_id=current_user, semester_id=semester , working_year = datetime.datetime.now().year, registration_type=registration_type) + cr.save() + return JsonResponse({'message': 'Successfully added swayam course' }, status=200) + except Exception as e: + print(str(e)) + return JsonResponse({'message': 'Error adding course '}, status=500) + + # simple api for getting to know the details of user who have logined in the system @api_view(['GET']) def get_user_info(request): diff --git a/FusionIIIT/applications/academic_procedures/migrations/0006_auto_20250114_0326.py b/FusionIIIT/applications/academic_procedures/migrations/0006_auto_20250114_0326.py new file mode 100644 index 000000000..b7434719e --- /dev/null +++ b/FusionIIIT/applications/academic_procedures/migrations/0006_auto_20250114_0326.py @@ -0,0 +1,43 @@ +# Generated by Django 3.1.5 on 2025-01-14 03:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('academic_procedures', '0005_auto_20241202_1439'), + ] + + operations = [ + migrations.AlterField( + model_name='assistantshipclaim', + name='year', + field=models.IntegerField(choices=[(2025, 2025), (2024, 2024)]), + ), + migrations.AlterField( + model_name='course_registration', + name='registration_type', + field=models.CharField(choices=[('Audit', 'Audit'), ('Improvement', 'Improvement'), ('Backlog', 'Backlog'), ('Regular', 'Regular'), ('Extra Credits', 'Extra Credits'), ('Replacement', 'Replacement')], default='Regular', max_length=20), + ), + migrations.AlterField( + model_name='course_registration', + name='working_year', + field=models.IntegerField(blank=True, choices=[(2025, 2025), (2024, 2024)], null=True), + ), + migrations.AlterField( + model_name='finalregistrations', + name='batch', + field=models.IntegerField(default=2025), + ), + migrations.AlterField( + model_name='messdue', + name='year', + field=models.IntegerField(choices=[(2025, 2025), (2024, 2024)]), + ), + migrations.AlterField( + model_name='register', + name='year', + field=models.IntegerField(default=2025), + ), + ] diff --git a/FusionIIIT/applications/academic_procedures/models.py b/FusionIIIT/applications/academic_procedures/models.py index daf284262..d3e40a576 100644 --- a/FusionIIIT/applications/academic_procedures/models.py +++ b/FusionIIIT/applications/academic_procedures/models.py @@ -710,6 +710,8 @@ class course_registration(models.Model): ('Improvement', 'Improvement'), ('Backlog', 'Backlog'), ('Regular', 'Regular'), + ('Extra Credits', 'Extra Credits'), + ('Replacement', 'Replacement'), ] registration_type = models.CharField( max_length=20, diff --git a/FusionIIIT/applications/academic_procedures/views.py b/FusionIIIT/applications/academic_procedures/views.py index 4096dfc35..81a125084 100644 --- a/FusionIIIT/applications/academic_procedures/views.py +++ b/FusionIIIT/applications/academic_procedures/views.py @@ -391,7 +391,7 @@ def academic_procedures_student(request): final_registration_date_flag = get_final_registration_eligibility(current_date) add_or_drop_course_date_flag = get_add_or_drop_course_date_eligibility(current_date) swayam_registration_flag = get_swayam_registration_eligibility(current_date, user_sem, year) - print("Swayam Registration: ", user_sem, swayam_registration_flag) + drop_date_flag = get_drop_course_date_eligibility(current_date, year) pre_registration_flag = False final_registration_flag = False @@ -552,6 +552,12 @@ def academic_procedures_student(request): # Mess_bill = Monthly_bill.objects.filter(student_id = obj) # Mess_pay = Payments.objects.filter(student_id = obj) + swayam_course_slots = get_current_semester_swayam_course_slots(curr_sem_id=curr_sem_id) + swayam_courses = [] + try: + swayam_courses = swayam_course_slots[0].courses.all() + except: + pass Mess_bill = [] Mess_pay = [] # Branch Change Form save @@ -608,10 +614,12 @@ def academic_procedures_student(request): 'prd_start_date': prd_start_date, 'frd': final_registration_date_flag, 'adc_date_flag': add_or_drop_course_date_flag, + 'drop_date_flag' : drop_date_flag, 'pre_registration_flag' : pre_registration_flag, 'final_registration_flag': final_registration_flag, 'swayam_registration_flag': swayam_registration_flag, 'swayam_courses_count':swayam_courses_count, + 'swayam_courseslots':swayam_course_slots, # 'final_r': final_register_1, 'teaching_credit_registration_course' : teaching_credit_registration_course, @@ -633,6 +641,7 @@ def academic_procedures_student(request): 'BranchFlag':branchchange_flag, 'assistantship_flag' : student_status, 'notifications': notifs, + 'swayam_courses' : swayam_courses, } ) @@ -953,6 +962,8 @@ def dropcourseadmin(request): rid - Registration ID of Registers table response_data - data to be responded. ''' + if user_check(request): + return HttpResponseRedirect('/academic-procedures/main') data = request.GET.get('id') # data = data.split(" - ") reg_id = int(data) @@ -1118,6 +1129,8 @@ def verify_course(request): # view to add Course for a student def acad_add_course(request): if(request.method == "POST"): + if user_check(request): + return HttpResponseRedirect('/academic-procedures/main') course_id = request.POST["course_id"] courseslot_id = request.POST["courseslot_id"] course = Courses.objects.get(id=course_id) @@ -1426,7 +1439,6 @@ def get_course_verification_date_eligibilty(current_date): def get_swayam_registration_eligibility(current_date, user_sem, year): try: swayam_registration_date = Calendar.objects.all().filter(description=f"Swayam Registration {user_sem} {year}").first() - print(swayam_registration_date, user_sem, year) swayam_start_date = swayam_registration_date.from_date swayam_end_date = swayam_registration_date.to_date if current_date>=swayam_start_date and current_date<=swayam_end_date: @@ -1435,6 +1447,18 @@ def get_swayam_registration_eligibility(current_date, user_sem, year): return False except Exception as e: return False + +def get_drop_course_date_eligibility(current_date, year): + try: + drop_course_date = Calendar.objects.all().filter(description=f"drop course date {year}").first() + drop_start_date = drop_course_date.from_date + drop_end_date = drop_course_date.to_date + if current_date>=drop_start_date and current_date<=drop_end_date: + return True + else : + return False + except Exception as e: + return False def get_user_branch(user_details): return user_details.department.name @@ -2045,7 +2069,7 @@ def get_add_course_options(branch_courses, current_register, batch): if courseslot not in slots: lis = [] for course in courseslot.courses.all(): - print(course) + # print(course) if course_registration.objects.filter(student_id__batch_id__year = batch, course_id = course).count() < max_limit: lis.append(course) course_option.append((courseslot, lis)) @@ -4237,4 +4261,10 @@ def register_backlog_course(request): return JsonResponse({'message': 'Error Registering course ' + str(e)}, status=500) except Exception as e: print(str(e)) - return JsonResponse({'message': 'Adding Backlog Failed ' +str(e)}, status=500) \ No newline at end of file + return JsonResponse({'message': 'Adding Backlog Failed ' +str(e)}, status=500) + + +def get_current_semester_swayam_course_slots(curr_sem_id): + courseslot_list = CourseSlot.objects.filter(semester = curr_sem_id, name__startswith='SW') + return courseslot_list + \ No newline at end of file diff --git a/FusionIIIT/templates/academic_procedures/academic.html b/FusionIIIT/templates/academic_procedures/academic.html index a4f364418..8b289a460 100644 --- a/FusionIIIT/templates/academic_procedures/academic.html +++ b/FusionIIIT/templates/academic_procedures/academic.html @@ -180,6 +180,9 @@ Swayam-Registration + + drop courses +
|
+ + | |||||
---|---|---|---|---|---|---|
+ {{ items.course_id.name}} + | +
+ |
+
+ |
+
+ |
+ + + DROP + | +
Are you sure you want to proceed with this action? This action cannot be undone.
+Swayam Registration Date is yet to come
{% endif %} - {% else %} +