4025c28eae
Moved contacts to new model
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from django.db import models
|
|
|
|
class Suburb(models.Model):
|
|
STATE = [
|
|
("VIC", "Victoria"),
|
|
("NSW", "New South Wales"),
|
|
("SA", "South Australia"),
|
|
("ACT", "Australia Capital Territory"),
|
|
("QLD", "Queensland"),
|
|
("NT", "Northern Territory"),
|
|
("WA", "Western Australia"),
|
|
("TAS", "Tasmania"),
|
|
]
|
|
name = models.CharField(max_length=30, unique=True)
|
|
state = models.CharField(max_length=3, choices=STATE)
|
|
postcode = models.PositiveSmallIntegerField()
|
|
distance = models.PositiveSmallIntegerField(blank=True, null=True)
|
|
|
|
class Meta:
|
|
ordering = ["name"]
|
|
|
|
def __str__(self):
|
|
return f"{self.name}, {self.state} {self.postcode}"
|
|
|
|
class Location(models.Model):
|
|
address = models.CharField(max_length=255, blank=True)
|
|
suburb = models.ForeignKey(Suburb, on_delete=models.PROTECT)
|
|
|
|
latitude = models.FloatField(null=True, blank=True)
|
|
longitude = models.FloatField(null=True, blank=True)
|
|
|
|
class Meta: unique_together = ("suburb", "address")
|
|
|
|
def __str__(self):
|
|
return f"{self.address}, {self.suburb}" |