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