From e34b6f176f1e47c1f7cf74e7fe5f893a0c2a1f59 Mon Sep 17 00:00:00 2001 From: Sanj Date: Sat, 3 Dec 2011 12:01:12 +0530 Subject: [PATCH] first commit --- chaloBEST/__init__.py | 0 chaloBEST/manage.py | 11 ++ chaloBEST/mumbai/__init__.py | 0 chaloBEST/mumbai/models.py | 246 +++++++++++++++++++++++++++++++++++ chaloBEST/mumbai/tests.py | 23 ++++ chaloBEST/mumbai/views.py | 1 + chaloBEST/settings.py | 107 +++++++++++++++ chaloBEST/urls.py | 16 +++ 8 files changed, 404 insertions(+) create mode 100644 chaloBEST/__init__.py create mode 100755 chaloBEST/manage.py create mode 100644 chaloBEST/mumbai/__init__.py create mode 100644 chaloBEST/mumbai/models.py create mode 100644 chaloBEST/mumbai/tests.py create mode 100644 chaloBEST/mumbai/views.py create mode 100644 chaloBEST/settings.py create mode 100644 chaloBEST/urls.py diff --git a/chaloBEST/__init__.py b/chaloBEST/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/chaloBEST/manage.py b/chaloBEST/manage.py new file mode 100755 index 0000000..bcdd55e --- /dev/null +++ b/chaloBEST/manage.py @@ -0,0 +1,11 @@ +#!/usr/bin/python +from django.core.management import execute_manager +try: + import settings # Assumed to be in the same directory. +except ImportError: + import sys + sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) + sys.exit(1) + +if __name__ == "__main__": + execute_manager(settings) diff --git a/chaloBEST/mumbai/__init__.py b/chaloBEST/mumbai/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/chaloBEST/mumbai/models.py b/chaloBEST/mumbai/models.py new file mode 100644 index 0000000..fc50cad --- /dev/null +++ b/chaloBEST/mumbai/models.py @@ -0,0 +1,246 @@ +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 Area(models.Model): + AreaCode = models.CharField(max_length=512) + AreaName = models.CharField(max_length=512) + polygon = models.PolygonField(blank=True, null=True) + + def __unicode__(self): + return self.AreaName + + +class Stop(models.Model): + _id = models.IntegerField(unique=True, db_index=True, primary_key=True) + stopname = models.CharField(max_length=512) + stopnameid = models.CharField(max_length=512) +# areacode = models.IntegerField() + area = models.ForeignKey("Area") +# area = models.CharField(max_length=512) + point = models.PointField(blank=True, null=True) +# lat = models.DecimalField(max_digits=4, decimal_places=2) #max_digits -> 999.99 +# lon = models.DecimalField(max_digits=5, decimal_places=2) + buses = models.ManyToManyField("Route") +# buses = models.CharField(max_length=512) +# landmark = models.CharField(max_length=512) +# areastopnamelandmark = models.CharField(max_length=512) +# noofbuses = models.IntegerField() + + def __unicode__(self): + return self.stopname + +class Landmark(models.Model): + stop = models.ForeignKey(Stop) + point = models.PointField(blank=True, null=True) +# stopcode = models.CharField(max_length=512) + landmark = models.CharField(max_length=512) + + def __unicode__(self): + return self.landmark + +class StopLocation(models.Model): + _id = models.IntegerField(unique=True, db_index=True, primary_key=True) + stopid = models.ForeignKey(Stop) +# stopnameid = models.CharField(max_length=512) +# landmark = models.CharField(max_length=512) + pointu = models.PointField(blank=True, null=True) + pointd = models.PointField(blank=True, null=True) + point = models.PointField(blank=True, null=True) + +# lat = models.PointField(blank=True, null=True) +# lon = models.PointField(blank=True, null=True) + busesup = models.ManyToManyField("Route" , related_name="buses_up") +# busesup = models.CharField(max_length=512) + busesdown = models.ManyToManyField("Route", related_name="buses_dn") +# stopcode = models.CharField(max_length=512) + + def __unicode__(self): + return self.stopnameid + +''' +class StopsCollected(models.Model): + area = models.CharField(max_length=512) + stopname = models.CharField(max_length=512) + landmark = models.CharField(max_length=512) + buses_up = models.CharField(max_length=512) + pointu = models.PointField(blank=True, null=True) + pointd = models.PointField(blank=True, null=True) +# latu = models.CharField(max_length=512) +# lonu = models.CharField(max_length=512) + buses_dn = models.CharField(max_length=512) + latd = models.CharField(max_length=512) + lond = models.CharField(max_length=512) + displayname = models.CharField(max_length=512) +# arealat = models.CharField(max_length=512) +# arealon = models.CharField(max_length=512) +# areabest = models.CharField(max_length=512) +# stopcode = models.ForeignKey('Stop', related_name="code") + area = models.ForeignKey("Area") +# areacode = models.CharField(max_length=512) + stopnameid = models.ForeignKey('Stop', related_name="nameid") + + def __unicode__(self): + return self.stopname +''' + +class Stopcode(models.Model): + _id = models.IntegerField(unique=True, db_index=True, primary_key=True) + stopcode = models.CharField(max_length=512) + stopid = models.ForeignKey(Stop) +# landmark = models.CharField(max_length=512) + + def __unicode__(self): + return self.stopcode + + +class Atlas(models.Model): + atlas_id = models.IntegerField(unique=True, db_index=True, primary_key=True) + route = models.ForeignKey("Route") +# RouteCode = models.CharField(max_length=512) +# FirstStop = models.CharField(max_length=512) + FirstFrom = models.DecimalField(max_digits=4, decimal_places=2) + FirstTo = models.DecimalField(max_digits=4, decimal_places=2) +# LastStop = models.CharField(max_length=512) + LastFrom = models.DecimalField(max_digits=4, decimal_places=2) + LastTo = models.DecimalField(max_digits=4, decimal_places=2) + am = models.DecimalField(max_digits=4, decimal_places=2) + noon = models.DecimalField(max_digits=4, decimal_places=2) + pm = models.DecimalField(max_digits=4, decimal_places=2) + schedule = models.CharField(max_length=255) + firststopserial = models.IntegerField() + laststopserial = models.IntegerField() +# firststopnameid = models.CharField(max_length=512) +# laststopnameid = models.CharField(max_length=512) + firststopid = models.ForeignKey(Stop, blank=True, null=True, related_name="first_stop") + laststopid = models.ForeignKey(Stop, blank=True, null=True, related_name="last_stop") + + def __unicode__(self): + return "%s %s" %(self.firststopid, self.laststopid) + +class Route(models.Model): + _id = models.IntegerField(unique=True, db_index=True, primary_key=True) + routeCode = models.CharField(max_length=512) + laststop = models.IntegerField() + busno = models.CharField(max_length=512) + firststopid = models.ForeignKey(Stop, related_name="stop_up") + laststopid = models.ForeignKey(Stop, related_name="stop_dn") + fstopname = models.CharField(max_length=512) + lstopname = models.CharField(max_length=512) + + def __unicode__(self): + return self.routeCode + + +class RouteDetail(models.Model): + _id = models.IntegerField(unique=True, db_index=True, primary_key=True) + routeCode = models.CharField(max_length=512) + stopSerial = models.IntegerField() +# stopCode = models.IntegerField() #FIXME + stage = models.CharField(max_length=512) + km = models.CharField(max_length=512) + busno = models.IntegerField() + stoplocationidup = models.ForeignKey("StopLocation", related_name="route_up") + stoplocationiddown = models.ForeignKey("StopLocation", related_name="route_dn") + stopid = models.ForeignKey(Stop) + + def __unicode__(self): + return self.routeCode + +class Frequency(models.Model): + _id = models.IntegerField(unique=True, db_index=True, primary_key=True) + startheadway = models.IntegerField() + endheadway = models.IntegerField() + frequency = models.IntegerField() + startdayweek = models.IntegerField() + enddayweek = models.IntegerField() +# firststopserial = models.IntegerField() +# laststopserial = models.IntegerField() + holiday = models.CharField(max_length=512) +# routecode = models.CharField(max_length=512) +# firststopid = models.ForeignKey(Stop) +# laststopid = models.ForeignKey(Stop) +# atlasfirststop = models.CharField(max_length=512) +# atlaslaststop = models.CharField(max_length=512) + atlas_id = models.ForeignKey(Atlas) + + + def __unicode__(self): + return "frequency" + + +class BestAtlas(models.Model): + RouteCode = models.CharField(max_length=512) + BusNo = models.CharField(max_length=512) + FirstStop = models.CharField(max_length=512) + FirstFrom = models.CharField(max_length=512) + LastFrom = models.CharField(max_length=512) + Laststop = models.CharField(max_length=512) + FirstTo = models.CharField(max_length=512) + LastTo = models.CharField(max_length=512) + Am = models.CharField(max_length=512) + Noon = models.CharField(max_length=512) + Pm = models.CharField(max_length=512) + Schedule = models.CharField(max_length=512) + + def __unicode__(self): + return self.RouteCode + +class BestStopMaster(models.Model): + StopCode = models.CharField(max_length=512) + StopName = models.CharField(max_length=512) + STOPFL = models.CharField(max_length=512) + RoadCode = models.CharField(max_length=512) + AreaCode = models.CharField(max_length=512) + DEPOT = models.CharField(max_length=512) + + def __unicode__(self): + return self.StopName + +class ScheduleLookup(models.Model): + schedule = models.CharField(max_length=512) + startday = models.IntegerField() + endday = models.IntegerField() + holiday = models.CharField(max_length=512) + + def __unicode__(self): + return self.schedule + +class BestRouteDetails(models.Model): + RouteCode = models.CharField(max_length=512) + StopSerial = models.CharField(max_length=512) + StopCode = models.CharField(max_length=512) + Stage = models.CharField(max_length=512) + Km = models.CharField(max_length=512) + + + def __unicode__(self): + return self.RouteCode + +class BestAreaMaster(models.Model): + AreaCode = models.CharField(max_length=512) + AreaName = models.CharField(max_length=512) + + + def __unicode__(self): + return self.AreaName diff --git a/chaloBEST/mumbai/tests.py b/chaloBEST/mumbai/tests.py new file mode 100644 index 0000000..2247054 --- /dev/null +++ b/chaloBEST/mumbai/tests.py @@ -0,0 +1,23 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from django.test import TestCase + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.failUnlessEqual(1 + 1, 2) + +__test__ = {"doctest": """ +Another way to test that 1 + 1 is equal to 2. + +>>> 1 + 1 == 2 +True +"""} + diff --git a/chaloBEST/mumbai/views.py b/chaloBEST/mumbai/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/chaloBEST/mumbai/views.py @@ -0,0 +1 @@ +# Create your views here. diff --git a/chaloBEST/settings.py b/chaloBEST/settings.py new file mode 100644 index 0000000..f6e1ada --- /dev/null +++ b/chaloBEST/settings.py @@ -0,0 +1,107 @@ +# Django settings for chaloBEST project. +import os +from os.path import join + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +PROJECT_ROOT = os.path.dirname(__file__) + +ADMINS = ( + # ('Your Name', 'your_email@domain.com'), +) + +LOCAL_DEVELOPMENT = True +JSON_DEBUG = True + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': 'chalobest', # Or path to database file if using sqlite3. + 'USER': 'sanj', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# On Unix systems, a value of None will cause Django to use the same +# timezone as the operating system. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = 'America/Chicago' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = 'en-us' + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True + +# If you set this to False, Django will not format dates, numbers and +# calendars according to the current locale +USE_L10N = True + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = join(PROJECT_ROOT, 'static') + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://media.lawrence.com", "http://example.com/media/" +MEDIA_URL = '' + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = '/media/' + +# Make this unique, and don't share it with anybody. +SECRET_KEY = 'nx7&&v8l)%6y#$#(%g3^lo2-zt0*jk49154n_7$$%h68%32cag' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', +# 'django.template.loaders.eggs.Loader', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', +) + +ROOT_URLCONF = 'chaloBEST.urls' + +TEMPLATE_DIRS = ( + join(PROJECT_ROOT, 'templates'), + # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + # Uncomment the next line to enable the admin: + 'django.contrib.admin', + # Uncomment the next line to enable admin documentation: + 'django.contrib.gis', + 'django_extensions', + 'mumbai', + # 'django.contrib.admindocs', +) diff --git a/chaloBEST/urls.py b/chaloBEST/urls.py new file mode 100644 index 0000000..83014ec --- /dev/null +++ b/chaloBEST/urls.py @@ -0,0 +1,16 @@ +from django.conf.urls.defaults import * + +# Uncomment the next two lines to enable the admin: +# from django.contrib import admin +# admin.autodiscover() + +urlpatterns = patterns('', + # Example: + # (r'^chaloBEST/', include('chaloBEST.foo.urls')), + + # Uncomment the admin/doc line below to enable admin documentation: + # (r'^admin/doc/', include('django.contrib.admindocs.urls')), + + # Uncomment the next line to enable the admin: + # (r'^admin/', include(admin.site.urls)), +)