from django.db import models
from django.contrib.auth.models import User
from accounts.models import Profile
#from schedule.models import Course

class Student(models.Model):
    profile = models.OneToOneField(Profile, on_delete=models.CASCADE)
    #course = models.ForeignKey(Course, on_delete=models.SET_NULL, null=True)
    medical_certificate = models.FileField(upload_to='medical_certificates/', null=True, blank=True)
    driving_license_number = models.CharField(max_length=20, blank=True)
    progress = models.IntegerField(default=0, help_text="Прогресс обучения в процентах")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self):
        return f"{self.profile.user.get_full_name()}"

class StudentProgress(models.Model):
    student = models.ForeignKey(Student, on_delete=models.CASCADE)
    theory_progress = models.IntegerField(default=0)
    practice_progress = models.IntegerField(default=0)
    last_lesson_date = models.DateTimeField(null=True, blank=True)
    notes = models.TextField(blank=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self):
        return f"Прогресс {self.student} - Теория: {self.theory_progress}%, Практика: {self.practice_progress}%" 