Files
RasadDam_Backend/apps/herd/models.py

47 lines
1.5 KiB
Python

from apps.core.models import BaseModel
from apps.authentication import models as auth_models
from django.db import models
class Herd(BaseModel):
name = models.CharField(max_length=50)
photo = models.CharField(max_length=50, null=True)
code = models.CharField(max_length=20)
postal = models.CharField(
max_length=10,
help_text="herd postal code", null=True
)
institution = models.CharField(
max_length=20,
help_text="herd institution code", null=True
)
epidemiologic = models.CharField(max_length=18, null=True) # noqa
contractor = models.ForeignKey(
auth_models.Organization,
on_delete=models.CASCADE,
related_name="herd_contractor",
null=True
)
latitude = models.DecimalField(max_digits=22, decimal_places=16, null=True)
longitude = models.DecimalField(max_digits=22, decimal_places=16, null=True)
unit_unique_id = models.CharField(max_length=20, null=True)
activity_types = (
("I", "Industrial"),
("V", "Village"),
("N", "Nomadic")
)
activity = models.CharField(
choices=activity_types,
max_length=1,
null=True
)
activity_state = models.BooleanField(default=False)
operating_license_state = models.BooleanField(default=False)
capacity = models.IntegerField(default=0)
def __str__(self):
return f'{self.name}-{self.code}'
def save(self, *args, **kwargs):
super(Herd, self).save(*args, **kwargs)