2012-08-12 10:32:08 +00:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2008-08-05 18:13:06 +00:00
|
|
|
|
2015-04-04 16:09:46 +00:00
|
|
|
from ..models import models
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2014-01-01 10:01:46 +00:00
|
|
|
class SimpleModel(models.Model):
|
|
|
|
|
|
|
|
objects = models.GeoManager()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
2015-04-04 16:09:46 +00:00
|
|
|
required_db_features = ['gis_enabled']
|
2014-01-01 10:01:46 +00:00
|
|
|
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2014-01-01 10:01:46 +00:00
|
|
|
class Location(SimpleModel):
|
2008-08-05 18:13:06 +00:00
|
|
|
point = models.PointField()
|
2013-10-17 08:17:41 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.point.wkt
|
2008-08-05 18:13:06 +00:00
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2014-01-01 10:01:46 +00:00
|
|
|
class City(SimpleModel):
|
2008-08-05 18:13:06 +00:00
|
|
|
name = models.CharField(max_length=50)
|
2012-12-24 22:10:40 +00:00
|
|
|
state = models.CharField(max_length=2)
|
2008-08-05 18:13:06 +00:00
|
|
|
location = models.ForeignKey(Location)
|
2013-10-17 08:17:41 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
2008-12-06 01:52:14 +00:00
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2008-12-06 01:52:14 +00:00
|
|
|
class AugmentedLocation(Location):
|
|
|
|
extra_text = models.TextField(blank=True)
|
2014-01-01 10:01:46 +00:00
|
|
|
|
2008-12-06 01:52:14 +00:00
|
|
|
objects = models.GeoManager()
|
2012-08-12 10:32:08 +00:00
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2014-01-01 10:01:46 +00:00
|
|
|
class DirectoryEntry(SimpleModel):
|
2008-12-06 01:52:14 +00:00
|
|
|
listing_text = models.CharField(max_length=50)
|
|
|
|
location = models.ForeignKey(AugmentedLocation)
|
2009-03-03 22:10:15 +00:00
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2014-01-01 10:01:46 +00:00
|
|
|
class Parcel(SimpleModel):
|
2009-03-03 22:10:15 +00:00
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
city = models.ForeignKey(City)
|
|
|
|
center1 = models.PointField()
|
|
|
|
# Throwing a curveball w/`db_column` here.
|
2012-08-12 10:32:08 +00:00
|
|
|
center2 = models.PointField(srid=2276, db_column='mycenter')
|
2009-03-03 22:10:15 +00:00
|
|
|
border1 = models.PolygonField()
|
|
|
|
border2 = models.PolygonField(srid=2276)
|
2013-10-17 08:17:41 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
2009-06-03 04:49:16 +00:00
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2009-06-03 04:49:16 +00:00
|
|
|
# These use the GeoManager but do not have any geographic fields.
|
2014-01-01 10:01:46 +00:00
|
|
|
class Author(SimpleModel):
|
2009-06-03 04:49:16 +00:00
|
|
|
name = models.CharField(max_length=100)
|
2011-09-10 22:53:26 +00:00
|
|
|
dob = models.DateField()
|
2009-06-03 04:49:16 +00:00
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2014-01-01 10:01:46 +00:00
|
|
|
class Article(SimpleModel):
|
2010-07-20 19:05:46 +00:00
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
author = models.ForeignKey(Author, unique=True)
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2014-01-01 10:01:46 +00:00
|
|
|
class Book(SimpleModel):
|
2009-06-03 04:49:16 +00:00
|
|
|
title = models.CharField(max_length=100)
|
2009-06-29 16:31:21 +00:00
|
|
|
author = models.ForeignKey(Author, related_name='books', null=True)
|
2014-08-12 12:08:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Event(SimpleModel):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
when = models.DateTimeField()
|