From 1ba4f9e9e04b1fbb55e12783f1a866b87ea27519 Mon Sep 17 00:00:00 2001 From: Johnson Chetty Date: Tue, 18 Sep 2012 20:06:49 +0200 Subject: [PATCH] gtfs . . .v9.6 --- chaloBEST/imports/data_mapper.py | 6 ++---- chaloBEST/imports/postload_cleanup.py | 15 +++++++++++++++ chaloBEST/mumbai/models.py | 3 ++- sqldiff/sqldiff160912.sql | 8 ++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 sqldiff/sqldiff160912.sql diff --git a/chaloBEST/imports/data_mapper.py b/chaloBEST/imports/data_mapper.py index d21b843..f0f3646 100644 --- a/chaloBEST/imports/data_mapper.py +++ b/chaloBEST/imports/data_mapper.py @@ -297,14 +297,12 @@ def CsvLoader(thismodel): def fire_up(): for model in saveorder: CsvLoader(model) - loadFKinRouteDetail() - - # also importUniqueRoutes() print "loading UniqueRoute..." - #postclean.copydefaultStopLocations() postclean.copynames2display_name() + postclean.make_stage_info() + postclean.make_type_info() #---------------------------------------------------------- diff --git a/chaloBEST/imports/postload_cleanup.py b/chaloBEST/imports/postload_cleanup.py index ddf7cca..b55c40d 100644 --- a/chaloBEST/imports/postload_cleanup.py +++ b/chaloBEST/imports/postload_cleanup.py @@ -16,5 +16,20 @@ def copynames2display_name(): obj.display_name =obj.name obj.save() +def make_stage_info(): + for rd in RouteDetail.objects.all(): + if rd.km: + rd.stage=True + rd.save() +def make_type_info(): + for r in Route.objects.all(): + r.route_type = RouteType.objects.get(code=str(r.code)[3]) + r.save() + +def make_code_info(): + for r in Route.objects.all(): + if r.code.isdigit(): + r.code3 = str(r.code)[0:3] + r.save() diff --git a/chaloBEST/mumbai/models.py b/chaloBEST/mumbai/models.py index 888bd01..62e056e 100644 --- a/chaloBEST/mumbai/models.py +++ b/chaloBEST/mumbai/models.py @@ -257,7 +257,8 @@ class Route(models.Model): to_stop = models.ForeignKey(Stop, related_name='routes_to', default=None, null=True, blank=True) distance = models.DecimalField(max_digits=3, decimal_places=1) stages = models.IntegerField() - + route_type = models.ForeignKey('RouteType', default=0, null=True, blank=True) + code3 = models.CharField(max_length=5) class Meta: ordering = ['code'] diff --git a/sqldiff/sqldiff160912.sql b/sqldiff/sqldiff160912.sql new file mode 100644 index 0000000..4d3d821 --- /dev/null +++ b/sqldiff/sqldiff160912.sql @@ -0,0 +1,8 @@ + + + +ALTER TABLE "mumbai_route" ADD COLUMN "code3" string; + +ALTER TABLE "mumbai_route" ADD COLUMN "route_type_id" integer; + +ALTER TABLE "mumbai_route" ADD CONSTRAINT "route_type_id_refs_id_6b818b01" FOREIGN KEY ("route_type_id") REFERENCES "mumbai_routetype" ("id") DEFERRABLE INITIALLY DEFERRED;