78 lines
2.6 KiB
Python
78 lines
2.6 KiB
Python
from django.contrib.gis.db import models
|
|
|
|
|
|
class SoilOrder(models.Model):
|
|
code = models.CharField(unique=True, max_length=1)
|
|
name = models.CharField(unique=True, max_length=50)
|
|
|
|
def __str__(self):
|
|
return f"{self.name} ({self.code})"
|
|
|
|
|
|
class SoilVariant(models.Model):
|
|
name = models.CharField(unique=True, max_length=10)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
|
|
class SoilLayer(models.Model):
|
|
nzsc_class = models.CharField(max_length=4)
|
|
nzsc_group = models.CharField(max_length=2)
|
|
nzsc_order = models.ForeignKey(SoilOrder, on_delete=models.CASCADE)
|
|
shape_leng = models.FloatField()
|
|
geom = models.PolygonField(srid=2193)
|
|
|
|
def __str__(self):
|
|
return self.nzsc_class
|
|
|
|
|
|
class EcologicalRegion(models.Model):
|
|
name = models.CharField(unique=True, max_length=50)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
|
|
class EcologicalDistrictLayer(models.Model):
|
|
ecological = models.CharField(max_length=5)
|
|
ecologic_1 = models.CharField(max_length=50)
|
|
ecologic_2 = models.ForeignKey(EcologicalRegion, on_delete=models.CASCADE)
|
|
shape_leng = models.FloatField()
|
|
shape_area = models.FloatField()
|
|
geom = models.PolygonField(srid=2193)
|
|
|
|
def __str__(self):
|
|
return f"{self.ecologic_1} ({self.ecologic_2})"
|
|
|
|
|
|
class ToleranceLevel(models.Model):
|
|
level = models.CharField(max_length=1)
|
|
|
|
def __str__(self):
|
|
return self.level
|
|
|
|
|
|
class Plant(models.Model):
|
|
name = models.CharField(unique=True, max_length=50)
|
|
commonname = models.CharField(null=True, blank=True, max_length=50)
|
|
maxheight = models.FloatField()
|
|
spacing = models.FloatField()
|
|
synonym = models.CharField(null=True, blank=True, max_length=200)
|
|
water_tolerance = models.ForeignKey(
|
|
ToleranceLevel, related_name='water_tolerance', on_delete=models.CASCADE)
|
|
drought_tolerance = models.ForeignKey(
|
|
ToleranceLevel, related_name='drought_tolerance', on_delete=models.CASCADE)
|
|
frost_tolerance = models.ForeignKey(
|
|
ToleranceLevel, related_name='frost_tolerance', on_delete=models.CASCADE)
|
|
salinity_tolerance = models.ForeignKey(
|
|
ToleranceLevel, related_name='salinity_tolerance', on_delete=models.CASCADE)
|
|
purpose = models.TextField(null=True, blank=True)
|
|
stage = models.PositiveIntegerField()
|
|
growth_form = models.CharField(null=True, blank=True, max_length=50)
|
|
ecological_regions = models.ManyToManyField(EcologicalRegion)
|
|
soil_order = models.ManyToManyField(SoilOrder)
|
|
soil_variants = models.ManyToManyField(SoilVariant)
|
|
|
|
def __str__(self):
|
|
return self.name
|