from django.db import models

from django.db import models
from django.contrib.auth.models import User

class PestDetectionRecord(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="用户")
    operation_type = models.CharField(max_length=50, verbose_name="操作类型")
    description = models.TextField(verbose_name="描述")
    result_path = models.CharField(max_length=255, blank=True, null=True, verbose_name="结果路径")
    created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    longitude = models.FloatField(null=True, blank=True, verbose_name="经度")
    latitude = models.FloatField(null=True, blank=True, verbose_name="纬度")

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

    class Meta:
        verbose_name = "病虫害检测记录"
        verbose_name_plural = "病虫害检测记录"