From ac4ffa059fb2585922da33ad77f3d1100b62ff6f Mon Sep 17 00:00:00 2001 From: Sanj Date: Sat, 1 Oct 2011 16:37:03 +0530 Subject: [PATCH] cleaned up models file in new_best/models.py --- best/new_best/models.py | 159 +++++++++++--------- best/static/rapidsms/stylesheets/layout.css | 6 +- best/static/rapidsms/stylesheets/tables.css | 2 +- 3 files changed, 89 insertions(+), 78 deletions(-) diff --git a/best/new_best/models.py b/best/new_best/models.py index 44f0ca8..318eef2 100644 --- a/best/new_best/models.py +++ b/best/new_best/models.py @@ -1,31 +1,73 @@ -# This is an auto-generated Django model module. -# You'll have to do the following manually to clean this up: -# * Rearrange models' order -# * Make sure each model has one field with primary_key=True -# Feel free to rename the models, but don't rename db_table values or field names. -# -# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]' -# into your database. +from django.contrib.gis.db import models +from django.contrib.contenttypes.models import ContentType +from django.contrib.contenttypes import generic -from django.db import models -class Acexpressroutes(models.Model): - routecode = models.CharField(max_length=512) - stopserial = models.IntegerField() - stageno = models.IntegerField() - stopcode = models.ForeignKey('Stopmaster', db_column='stopcode') - stage = models.CharField(max_length=512) - km = models.FloatField() +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) - class Meta: - db_table = u'acexpressroutes' + areacode = models.ForeignKey('Area') + displayname = models.CharField(max_length=512) + smlength = models.IntegerField() def __unicode__(self): - return self.routecode + 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) + 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) @@ -46,85 +88,51 @@ class Atlas(models.Model): reliefpoint = models.CharField(max_length=512) traveltime = models.CharField(max_length=512) scheduletype = models.CharField(max_length=512) - id = models.IntegerField(unique=True, primary_key=True) - class Meta: - db_table = u'atlas' def __unicode__(self): return self.route -class Regularroutes(models.Model): - routecode = models.CharField(max_length=512) - stopserial = models.IntegerField() - stageno = models.IntegerField() - stopcode = models.ForeignKey('Stopmaster', db_column='stopcode') - stage = models.CharField(max_length=512) - km = models.FloatField() - stopname = models.CharField(max_length=512) - class Meta: - db_table = u'regularroutes' - def __unicode__(self): - return self.routecode - -class Routetype(models.Model): +class RouteType(models.Model): typenumber = models.IntegerField() routetype = models.CharField(max_length=512) - class Meta: - db_table = u'routetype' def __unicode__(self): return self.routetype -class Stopmaster(models.Model): - stopcode = models.IntegerField(unique=True, primary_key=True) - stopname = models.CharField(max_length=512) - areacode = models.ForeignKey('Areamaster', db_column='areacode') - displayname = models.CharField(max_length=512) - smlength = models.IntegerField() - class Meta: - db_table = u'stopmaster' - def __unicode__(self): - return self.stopname - -class Areamaster(models.Model): - areacode = models.IntegerField(unique=True, primary_key=True) - areaname = models.CharField(max_length=512) - class Meta: - db_table = u'areamaster' - - def __unicode__(self): - return self.areaname - -class Asroutes(models.Model): +class Route(models.Model): routecode = models.CharField(max_length=512) stopserial = models.IntegerField() stageno = models.IntegerField() - stopcode = models.ForeignKey('Stopmaster', db_column='stopcode') + stopcode = models.ForeignKey('Stop') + physical_stop = models.ForeignKey('PhysicalStop') stage = models.CharField(max_length=512) km = models.FloatField() - stopname = models.CharField(max_length=512) + stopname = models.CharField(max_length=512) + class Meta: - db_table = u'asroutes' + abstract = True def __unicode__(self): return self.routecode -class Expressroutes(models.Model): - routecode = models.CharField(max_length=512) - stopserial = models.IntegerField() - stageno = models.IntegerField() - stopcode = models.ForeignKey('Stopmaster', db_column='stopcode') - stage = models.CharField(max_length=512) - km = models.FloatField() - stopname = models.CharField(max_length=512) - class Meta: - db_table = u'expressroutes' +class RegularRoute(Route): + pass - def __unicode__(self): - return self.routecode +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) @@ -155,3 +163,4 @@ class LocationsLocation(models.Model): def __unicode__(self): return str(self.id) +''' diff --git a/best/static/rapidsms/stylesheets/layout.css b/best/static/rapidsms/stylesheets/layout.css index 764c25a..abfcba3 100644 --- a/best/static/rapidsms/stylesheets/layout.css +++ b/best/static/rapidsms/stylesheets/layout.css @@ -86,12 +86,14 @@ background: linear-gradient(top, #94997e 0%,#d2dab3 10%,#d2dab3 80%,#94997e 100% margin: 0 10px; right: 0; top: 0; - } +} #header #auth a { color: #CE0000; padding-right:6px; - font-size:80%;} + font-size:80%; + + } #branding { diff --git a/best/static/rapidsms/stylesheets/tables.css b/best/static/rapidsms/stylesheets/tables.css index 87a1ec5..5b78722 100644 --- a/best/static/rapidsms/stylesheets/tables.css +++ b/best/static/rapidsms/stylesheets/tables.css @@ -13,7 +13,7 @@ table { col.sorted { background: #fcfcff; } - tr { } + tr{ } td, th { padding: 0.5em;