devicehub-django/lot/models.py

32 lines
1.0 KiB
Python
Raw Normal View History

2024-06-12 07:32:49 +00:00
from django.db import models
2024-07-09 11:35:35 +00:00
from django.utils.translation import gettext_lazy as _
2024-07-18 15:21:22 +00:00
from utils.constants import (
STR_SM_SIZE,
STR_SIZE,
STR_EXTEND_SIZE,
)
2024-06-12 07:32:49 +00:00
2024-07-09 11:35:35 +00:00
from user.models import User
from device.models import Device
2024-07-18 15:21:22 +00:00
from snapshot.models import Annotation
2024-07-09 11:35:35 +00:00
2024-07-18 15:21:22 +00:00
class LotTag(models.Model):
name = models.CharField(max_length=STR_SIZE, blank=False, null=False)
owner = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
return self.name
2024-07-09 11:35:35 +00:00
2024-07-18 15:21:22 +00:00
class Lot(models.Model):
2024-07-09 11:35:35 +00:00
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=STR_SIZE, blank=True, null=True)
code = models.CharField(max_length=STR_SIZE, blank=True, null=True)
description = models.CharField(max_length=STR_SIZE, blank=True, null=True)
closed = models.BooleanField(default=True)
owner = models.ForeignKey(User, on_delete=models.CASCADE)
2024-07-18 15:21:22 +00:00
type = models.ForeignKey(LotTag, on_delete=models.CASCADE)
2024-07-09 11:35:35 +00:00
devices = models.ManyToManyField(Device)