2016-11-05 18:35:58 +08:00
|
|
|
from django.contrib.gis.db import models
|
2008-08-06 02:13:06 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2014-01-01 18:01:46 +08:00
|
|
|
class SimpleModel(models.Model):
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
|
|
|
|
|
|
|
class Location(SimpleModel):
|
2008-08-06 02:13:06 +08:00
|
|
|
point = models.PointField()
|
2013-10-17 16:17:41 +08:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.point.wkt
|
2008-08-06 02:13:06 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2014-01-01 18:01:46 +08:00
|
|
|
class City(SimpleModel):
|
2008-08-06 02:13:06 +08:00
|
|
|
name = models.CharField(max_length=50)
|
2012-12-25 06:10:40 +08:00
|
|
|
state = models.CharField(max_length=2)
|
2015-07-22 22:43:21 +08:00
|
|
|
location = models.ForeignKey(Location, models.CASCADE)
|
2013-10-17 16:17:41 +08:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
2008-12-06 09:52:14 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2008-12-06 09:52:14 +08:00
|
|
|
class AugmentedLocation(Location):
|
|
|
|
extra_text = models.TextField(blank=True)
|
2014-01-01 18:01:46 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2014-01-01 18:01:46 +08:00
|
|
|
class DirectoryEntry(SimpleModel):
|
2008-12-06 09:52:14 +08:00
|
|
|
listing_text = models.CharField(max_length=50)
|
2015-07-22 22:43:21 +08:00
|
|
|
location = models.ForeignKey(AugmentedLocation, models.CASCADE)
|
2009-03-04 06:10:15 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2014-01-01 18:01:46 +08:00
|
|
|
class Parcel(SimpleModel):
|
2009-03-04 06:10:15 +08:00
|
|
|
name = models.CharField(max_length=30)
|
2015-07-22 22:43:21 +08:00
|
|
|
city = models.ForeignKey(City, models.CASCADE)
|
2009-03-04 06:10:15 +08:00
|
|
|
center1 = models.PointField()
|
|
|
|
# Throwing a curveball w/`db_column` here.
|
2012-08-12 18:32:08 +08:00
|
|
|
center2 = models.PointField(srid=2276, db_column="mycenter")
|
2009-03-04 06:10:15 +08:00
|
|
|
border1 = models.PolygonField()
|
|
|
|
border2 = models.PolygonField(srid=2276)
|
2013-10-17 16:17:41 +08:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
2009-06-03 12:49:16 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2014-01-01 18:01:46 +08:00
|
|
|
class Author(SimpleModel):
|
2009-06-03 12:49:16 +08:00
|
|
|
name = models.CharField(max_length=100)
|
2011-09-11 06:53:26 +08:00
|
|
|
dob = models.DateField()
|
2009-06-03 12:49:16 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2014-01-01 18:01:46 +08:00
|
|
|
class Article(SimpleModel):
|
2010-07-21 03:05:46 +08:00
|
|
|
title = models.CharField(max_length=100)
|
2015-07-22 22:43:21 +08:00
|
|
|
author = models.ForeignKey(Author, models.CASCADE, unique=True)
|
2010-07-21 03:05:46 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2014-01-01 18:01:46 +08:00
|
|
|
class Book(SimpleModel):
|
2009-06-03 12:49:16 +08:00
|
|
|
title = models.CharField(max_length=100)
|
2015-07-22 22:43:21 +08:00
|
|
|
author = models.ForeignKey(Author, models.SET_NULL, related_name="books", null=True)
|
2014-08-12 20:08:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
class Event(SimpleModel):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
when = models.DateTimeField()
|