From 86928205c1ed0ba8516112d6f6372f17291d8583 Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 2 Jan 2012 16:50:51 +0530 Subject: [PATCH] schema for atlas import added to models.py --- chaloBEST/imports/import_atlas.py | 7 +------ chaloBEST/mumbai/models.py | 35 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/chaloBEST/imports/import_atlas.py b/chaloBEST/imports/import_atlas.py index 9395c55..ac837e8 100644 --- a/chaloBEST/imports/import_atlas.py +++ b/chaloBEST/imports/import_atlas.py @@ -19,12 +19,7 @@ def csvToJSON(): jsonFile = open(join(PROJECT_ROOT, "../db_csv_files/Atlas.json"), "w") jsonFile.write(json.dumps(atlasDict, indent=2)) jsonFile.close() -<<<<<<< TREE + def csvClean1(): atlasCSV = csv.reader(open(join(PROJECT_ROOT, "../db_csv_files/Atlas.csv"), "r"), delimiter="\t") - -======= - - ->>>>>>> MERGE-SOURCE diff --git a/chaloBEST/mumbai/models.py b/chaloBEST/mumbai/models.py index dd7860d..0b70c70 100644 --- a/chaloBEST/mumbai/models.py +++ b/chaloBEST/mumbai/models.py @@ -108,6 +108,41 @@ class Route(models.Model): def __unicode__(self): return self.route +class UniqueRoute(models.Model): + route = models.ForeignKey(Route) + from_stop = models.ForeignKey(Stop, related_name="routes_from") + to_stop = models.ForeignKey(Stop, related_name="routes_to") + distance = models.DecimalField(max_digits=3, decimal_places=2) + is_full = models.BooleanField() + + def __unicode__(self): + return "%s: %s to %s" % (self.route.routealias, self.from_stop, self.to_stop,) + +class RouteSchedule(models.Model): + unique_route = models.ForeignKey(UniqueRoute) + schedule_type = models.CharField(max_length=16) + busesAM = models.IntegerField(blank=True, null=True) + busesN = models.IntegerField(blank=True, null=True) + busesPM = models.IntegerField(blank=True, null=True) + bus_type = models.CharField(max_length=3, default="SD") + depot = models.ForeignKey("Depot") + first_from = models.TimeField(blank=True, null=True) + last_from = models.TimeField(blank=True, null=True) + first_to = models.TimeField(blank=True, null=True) + last_to = models.TimeField(blank=True, null=True) + runtime1 = models.IntegerField(blank=True, null=True) + runtime2 = models.IntegerField(blank=True, null=True) + runtime3 = models.IntegerField(blank=True, null=True) + runtime4 = models.IntegerField(blank=True, null=True) + headway1 = models.IntegerField(blank=True, null=True) + headway2 = models.IntegerField(blank=True, null=True) + headway3 = models.IntegerField(blank=True, null=True) + headway4 = models.IntegerField(blank=True, null=True) + headway5 = models.IntegerField(blank=True, null=True) + + def __unicode__(self): + return "%s: %s" % (unicode(self.unique_route), self.schedule_type,) + class RouteTypes(models.Model): routecode = models.TextField(max_length=50) routetype = models.TextField(max_length=50)