Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dhiraj Thakur
committed
Jul 11, 2015
1 parent
c5b7dc3
commit ef44844
Showing
44 changed files
with
740 additions
and
117,831 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
import geoposition.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='BusRouteTiming', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('time', models.TimeField()), | ||
('is_ac', models.BooleanField()), | ||
], | ||
options={ | ||
'verbose_name': 'Bus Route Timing', | ||
'verbose_name_plural': 'Bus Route Timings', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Route', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('name', models.CharField(max_length=64)), | ||
('direction', models.CharField(max_length=2)), | ||
('ac_bus_available', models.BooleanField(default=False)), | ||
], | ||
options={ | ||
'verbose_name': 'Route', | ||
'verbose_name_plural': 'Routes', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Stage', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('name', models.CharField(unique=True, max_length=64)), | ||
('coordinates', geoposition.fields.GeopositionField(max_length=42)), | ||
], | ||
options={ | ||
'verbose_name': 'Stage', | ||
'verbose_name_plural': 'Stages', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='StageSequence', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('sequence', models.IntegerField()), | ||
('route', models.ForeignKey(to='busroutes.Route')), | ||
('stage', models.ForeignKey(to='busroutes.Stage')), | ||
], | ||
options={ | ||
'verbose_name': 'Stage Sequence', | ||
'verbose_name_plural': 'Stage Sequences', | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='route', | ||
name='end_stage', | ||
field=models.ForeignKey(related_name='end_stage', to='busroutes.Stage'), | ||
), | ||
migrations.AddField( | ||
model_name='route', | ||
name='stages', | ||
field=models.ManyToManyField(to='busroutes.Stage', through='busroutes.StageSequence'), | ||
), | ||
migrations.AddField( | ||
model_name='route', | ||
name='start_stage', | ||
field=models.ForeignKey(related_name='start_stage', to='busroutes.Stage'), | ||
), | ||
migrations.AddField( | ||
model_name='busroutetiming', | ||
name='route', | ||
field=models.ForeignKey(to='busroutes.Route'), | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='stagesequence', | ||
unique_together=set([('route', 'stage', 'sequence')]), | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='route', | ||
unique_together=set([('name', 'start_stage', 'end_stage'), ('name', 'direction')]), | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='busroutetiming', | ||
unique_together=set([('route', 'time', 'is_ac')]), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('busroutes', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='route', | ||
name='direction', | ||
field=models.CharField(max_length=4), | ||
), | ||
] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.db import models | ||
from geoposition.fields import GeopositionField | ||
|
||
|
||
class Stage(models.Model): | ||
name = models.CharField(max_length=64,unique=True) | ||
coordinates = GeopositionField() | ||
|
||
class Meta: | ||
verbose_name = "Stage" | ||
verbose_name_plural = "Stages" | ||
|
||
def __unicode__(self): | ||
return self.name | ||
|
||
|
||
class BusRouteTiming(models.Model): | ||
route = models.ForeignKey('Route') | ||
time = models.TimeField() | ||
is_ac = models.BooleanField() # is air-conditioned | ||
|
||
class Meta: | ||
verbose_name = "Bus Route Timing" | ||
verbose_name_plural = "Bus Route Timings" | ||
|
||
unique_together=(('route','time','is_ac'),) | ||
|
||
|
||
class Route(models.Model): | ||
name = models.CharField(max_length=64) | ||
start_stage = models.ForeignKey(Stage, related_name='start_stage') | ||
end_stage = models.ForeignKey(Stage, related_name='end_stage') | ||
direction = models.CharField(max_length=4) # up or down | ||
ac_bus_available = models.BooleanField(default=False) | ||
stages = models.ManyToManyField( | ||
Stage, through="StageSequence",through_fields=('route', 'stage')) | ||
|
||
class Meta: | ||
verbose_name = "Route" | ||
verbose_name_plural = "Routes" | ||
|
||
unique_together = (('name','direction'),('name','start_stage','end_stage'),) | ||
|
||
def __unicode__(self): | ||
return self.name | ||
|
||
|
||
class StageSequence(models.Model): | ||
route = models.ForeignKey(Route) | ||
stage = models.ForeignKey(Stage) | ||
sequence = models.IntegerField() | ||
|
||
class Meta: | ||
verbose_name = "Stage Sequence" | ||
verbose_name_plural = "Stage Sequences" | ||
|
||
unique_together = (('route','stage','sequence'),) | ||
|
||
def __unicode__(self): | ||
return str(self.route.id)+' | '+str(self.stage.id)+'('+str(self.sequence)+')' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""dtc_bus_routes URL Configuration | ||
The `urlpatterns` list routes URLs to views. For more information please see: | ||
https://docs.djangoproject.com/en/1.8/topics/http/urls/ | ||
Examples: | ||
Function views | ||
1. Add an import: from my_app import views | ||
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') | ||
Class-based views | ||
1. Add an import: from other_app.views import Home | ||
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') | ||
Including another URLconf | ||
1. Add an import: from blog import urls as blog_urls | ||
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) | ||
""" | ||
from django.conf.urls import include, url | ||
from django.contrib import admin | ||
|
||
from django.views.generic import TemplateView | ||
|
||
urlpatterns = [ | ||
url(r'^admin/', include(admin.site.urls)), | ||
|
||
url(r'^$', TemplateView.as_view(template_name="home.html"), name='home'), | ||
|
||
url(r'route/search/$','busroutes.views.search_by_stage',name='search_by_stage'), | ||
url(r'search/$','busroutes.views.search_by_num',name='search_by_num'), | ||
# url(r'stage/(?P<stageid>\d+)/$','buroutes.views.stage_by_id',name='stage_by_id') #not implemented yet | ||
url(r'route/(?P<busid>\d+)/$','busroutes.views.bus_by_id',name='bus_by_id'), | ||
url(r'ajax/bus/$','busroutes.views.ajax_bus',name='ajax_bus'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for dtc_bus_routes project. | ||
It exposes the WSGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dtc_bus_routes.settings") | ||
|
||
application = get_wsgi_application() |
Oops, something went wrong.