from django.db import models

class ModelConfig(models.Model):
    name = models.CharField(max_length=100, unique=True)
    model_path = models.CharField(max_length=255)

    def __str__(self):
        return self.name


class OperationRecord(models.Model):

    user = models.ForeignKey('app01.UserInfo', on_delete=models.CASCADE, verbose_name="用户")

    operation_type = models.CharField(max_length=20, choices=[
        ('IMAGE', '图片检测'),
        ('VIDEO', '视频检测'),
        ('CAMERA', '实时检测')
    ], verbose_name="操作类型")

    description = models.TextField(verbose_name="操作描述")
    result_path = models.CharField(max_length=255, null=True, blank=True, verbose_name="结果路径")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="记录时间")

    class Meta:
        verbose_name = "操作记录"
        verbose_name_plural = verbose_name

    def __str__(self):
        return f"{self.user.username} - {self.operation_type} - {self.create_time}"