from django.contrib.gis.db import models from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic LANGUAGE_CHOICES = ( ('en', 'English'), ('ma', 'Marathi'), ('hi', 'Hindi'), ) ALTERNATIVE_NAME_TYPES = ( ('colloquial', 'Colloquial'), ('official', 'Official'), ('historical', 'Historical'), ('other', 'Other'), ) DIRECTION_CHOICES = ( ('up', 'Up'), ('down', 'Down'), ('ring', 'Ring'), ) class Stop(models.Model): stopcode = models.IntegerField(unique=True, db_index=True) stopname = models.CharField(max_length=512) areacode = models.ForeignKey('Area') displayname = models.CharField(max_length=512) smlength = models.IntegerField() def __unicode__(self): return self.stopname class AlternativeName(models.Model): name = models.CharField(max_length=255) language = models.CharField(max_length=10, choices=LANGUAGE_CHOICES) typ = models.CharField(max_length=64, choices=ALTERNATIVE_NAME_TYPES) priority = models.IntegerField(default=0) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') def __unicode__(self): return self.name class PhysicalStop(models.Model): point = models.PointField(blank=True) stop = models.ForeignKey(Stop) direction = models.CharField(choices=DIRECTION_CHOICES, max_length=16) def __unicode__(self): return self.stop.displayname class Area(models.Model): areacode = models.IntegerField(unique=True, db_index=True) areaname = models.CharField(max_length=512) polygon = models.PolygonField(blank=True) def __unicode__(self): return self.areaname class Atlas(models.Model): routecode = models.CharField(max_length=512, db_index=True) route = models.CharField(max_length=512) busfrom = models.CharField(max_length=512) firstfrom = models.CharField(max_length=512) lastfrom = models.CharField(max_length=512) busto = models.CharField(max_length=512) firstto = models.CharField(max_length=512) lastto = models.CharField(max_length=512) routespan = models.CharField(max_length=512) runtime7to11 = models.CharField(max_length=512) runtime11to17 = models.CharField(max_length=512) runtime17toend = models.CharField(max_length=512) runtimenight = models.CharField(max_length=512) headwaybefore7 = models.CharField(max_length=512) headway7to11 = models.CharField(max_length=512) headway11to17 = models.CharField(max_length=512) headway17to20 = models.CharField(max_length=512) headway20tolast = models.CharField(max_length=512) reliefpoint = models.CharField(max_length=512) traveltime = models.CharField(max_length=512) scheduletype = models.CharField(max_length=512) def __unicode__(self): return self.route class RouteType(models.Model): typenumber = models.IntegerField() routetype = models.CharField(max_length=512) def __unicode__(self): return self.routetype class Route(models.Model): routecode = models.CharField(max_length=512) stopserial = models.IntegerField() stageno = models.IntegerField() stopcode = models.ForeignKey('Stop') physical_stop = models.ForeignKey('PhysicalStop') stage = models.CharField(max_length=512) km = models.FloatField() stopname = models.CharField(max_length=512) class Meta: abstract = True def __unicode__(self): return self.routecode class RegularRoute(Route): pass class AcExpressRoute(Route): pass class AsRoute(Route): pass class Expressroutes(Route): pass ''' class LocationsPoint(models.Model): id = models.IntegerField(primary_key=True) latitude = models.DecimalField(max_digits=13, decimal_places=10) longitude = models.DecimalField(max_digits=13, decimal_places=10) class Meta: db_table = u'locations_point' def __unicode__(self): return str(self.id) class LocationsLocationtype(models.Model): name = models.CharField(max_length=100) slug = models.CharField(max_length=50, primary_key=True) class Meta: db_table = u'locations_locationtype' def __unicode__(self): return self.name class LocationsLocation(models.Model): id = models.IntegerField(primary_key=True) point = models.ForeignKey(LocationsPoint) type = models.ForeignKey(LocationsLocationtype) # parent_type = models.ForeignKey(DjangoContentType) parent_id = models.IntegerField() class Meta: db_table = u'locations_location' def __unicode__(self): return str(self.id) '''