signals(fix): error on course tracking

This commit is contained in:
sankalp committed 2025-04-22 04:40:53 +05:45
1 parent b6eacf720b
commit a7ce06325c
1 file changed
+3 -4
+3 -4
View File
@@ -126,8 +126,7 @@ def create_course_tracking(sender, instance, created, **kwargs):
expected_end_date = start_date + timedelta(days=duration_days) expected_end_date = start_date + timedelta(days=duration_days)
# Create course tracking with transaction # Create course tracking without nested transaction
with transaction.atomic():
course_tracking = CourseTracking.objects.create( course_tracking = CourseTracking.objects.create(
student=instance, student=instance,
course=instance.course, course=instance.course,
@@ -139,8 +138,8 @@ def create_course_tracking(sender, instance, created, **kwargs):
+ timedelta(days=180), # 6 months for first semester + timedelta(days=180), # 6 months for first semester
) )
# Force initial percentage calculation # The model's save() method will handle the percentage calculation automatically
course_tracking.force_update_percentage() # No need to manually call update_completion_percentage()
except Exception as e: except Exception as e:
print( print(