From 338e6db93b40f5ff01436b158a617550c5c20947 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 22 Apr 2025 04:40:53 +0545 Subject: [PATCH] signals(fix): error on course tracking --- app/signals.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/app/signals.py b/app/signals.py index c4ec4f5..e31e186 100644 --- a/app/signals.py +++ b/app/signals.py @@ -126,21 +126,20 @@ def create_course_tracking(sender, instance, created, **kwargs): expected_end_date = start_date + timedelta(days=duration_days) - # Create course tracking with transaction - with transaction.atomic(): - course_tracking = CourseTracking.objects.create( - student=instance, - course=instance.course, - start_date=start_date, - expected_end_date=expected_end_date, - current_period=instance.current_period, - period_start_date=start_date, - period_end_date=start_date - + timedelta(days=180), # 6 months for first semester - ) + # Create course tracking without nested transaction + course_tracking = CourseTracking.objects.create( + student=instance, + course=instance.course, + start_date=start_date, + expected_end_date=expected_end_date, + current_period=instance.current_period, + period_start_date=start_date, + period_end_date=start_date + + timedelta(days=180), # 6 months for first semester + ) - # Force initial percentage calculation - course_tracking.force_update_percentage() + # The model's save() method will handle the percentage calculation automatically + # No need to manually call update_completion_percentage() except Exception as e: print(