Added locations app

Moved contacts to new model
This commit is contained in:
st01765
2026-02-26 13:34:32 +11:00
parent a24daed8f6
commit 4025c28eae
25 changed files with 576 additions and 75 deletions
View File
+13
View File
@@ -0,0 +1,13 @@
from django.contrib import admin
from common.admin import MyImportExportModelAdmin
from locations.models import Suburb, Location
@admin.register(Suburb)
class SuburbsAdmin(MyImportExportModelAdmin, admin.ModelAdmin):
list_filter = ["state"]
@admin.register(Location)
class LocationAdmin(admin.ModelAdmin):
search_fields = ["address", "suburb__name", "suburb__postcode"]
+6
View File
@@ -0,0 +1,6 @@
from django.apps import AppConfig
class LocationsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'locations'
+35
View File
@@ -0,0 +1,35 @@
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}"
+3
View File
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
+3
View File
@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.