added alternative names stuff
This commit is contained in:
parent
a8662509c4
commit
5940e93352
|
@ -1,10 +1,16 @@
|
||||||
from django.contrib.gis import admin
|
from django.contrib.gis import admin
|
||||||
from django import forms
|
from django import forms
|
||||||
from mumbai.models import *
|
from mumbai.models import *
|
||||||
|
from django.contrib.contenttypes import generic
|
||||||
|
|
||||||
class RouteScheduleInline(admin.StackedInline):
|
class RouteScheduleInline(admin.StackedInline):
|
||||||
model = RouteSchedule
|
model = RouteSchedule
|
||||||
extras = 0
|
extra = 0
|
||||||
|
|
||||||
|
class AlternativeNameInline(generic.GenericStackedInline):
|
||||||
|
extra = 3
|
||||||
|
model = AlternativeName
|
||||||
|
|
||||||
|
|
||||||
class AreaAdmin(admin.OSMGeoAdmin):
|
class AreaAdmin(admin.OSMGeoAdmin):
|
||||||
list_display = ("code","display_name", "name_mr", "name", "slug")
|
list_display = ("code","display_name", "name_mr", "name", "slug")
|
||||||
|
@ -17,6 +23,7 @@ class AreaAdmin(admin.OSMGeoAdmin):
|
||||||
default_lat = 2170000.4068373
|
default_lat = 2170000.4068373
|
||||||
default_zoom = 10
|
default_zoom = 10
|
||||||
search_fields = ("name","display_name", "name_mr","slug")
|
search_fields = ("name","display_name", "name_mr","slug")
|
||||||
|
inlines = [AlternativeNameInline]
|
||||||
|
|
||||||
class RoadAdmin(admin.OSMGeoAdmin):
|
class RoadAdmin(admin.OSMGeoAdmin):
|
||||||
list_display = ("code","display_name", "name_mr", "name", "slug")
|
list_display = ("code","display_name", "name_mr", "name", "slug")
|
||||||
|
@ -31,6 +38,7 @@ class RoadAdmin(admin.OSMGeoAdmin):
|
||||||
default_lon = 8110203.9998955
|
default_lon = 8110203.9998955
|
||||||
default_lat = 2170000.4068373
|
default_lat = 2170000.4068373
|
||||||
default_zoom = 10
|
default_zoom = 10
|
||||||
|
inlines = [AlternativeNameInline]
|
||||||
|
|
||||||
class FareAdmin(admin.ModelAdmin):
|
class FareAdmin(admin.ModelAdmin):
|
||||||
list_display = ("slab","ordinary","limited","express","ac","ac_express")
|
list_display = ("slab","ordinary","limited","express","ac","ac_express")
|
||||||
|
@ -77,6 +85,8 @@ class StopAdmin(admin.OSMGeoAdmin):
|
||||||
default_lon = 8110203.9998955
|
default_lon = 8110203.9998955
|
||||||
default_lat = 2170000.4068373
|
default_lat = 2170000.4068373
|
||||||
default_zoom = 10
|
default_zoom = 10
|
||||||
|
inlines = [AlternativeNameInline]
|
||||||
|
|
||||||
|
|
||||||
class RouteDetailAdmin(admin.ModelAdmin):
|
class RouteDetailAdmin(admin.ModelAdmin):
|
||||||
list_display = ("route_code","serial","stop","stage","km")
|
list_display = ("route_code","serial","stop","stage","km")
|
||||||
|
@ -123,6 +133,7 @@ class LandmarkAdmin(admin.OSMGeoAdmin):
|
||||||
default_lon = 8110203.9998955
|
default_lon = 8110203.9998955
|
||||||
default_lat = 2170000.4068373
|
default_lat = 2170000.4068373
|
||||||
default_zoom = 10
|
default_zoom = 10
|
||||||
|
inlines = [AlternativeNameInline]
|
||||||
|
|
||||||
class StopLocationAdmin(admin.OSMGeoAdmin):
|
class StopLocationAdmin(admin.OSMGeoAdmin):
|
||||||
list_display = ("stop", "direction", "point")
|
list_display = ("stop", "direction", "point")
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
from django.contrib.gis.db import models
|
from django.contrib.gis.db import models
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
from django.contrib.contenttypes import generic
|
||||||
|
|
||||||
STOP_CHOICES = ( ('U','Up'),
|
STOP_CHOICES = ( ('U','Up'),
|
||||||
('D', 'Down'),
|
('D', 'Down'),
|
||||||
|
@ -45,6 +47,8 @@ class Area(models.Model):
|
||||||
name_mr= models.TextField(null=True, blank=True, max_length=512) #null=True,
|
name_mr= models.TextField(null=True, blank=True, max_length=512) #null=True,
|
||||||
display_name = models.TextField(blank=True, max_length=255)
|
display_name = models.TextField(blank=True, max_length=255)
|
||||||
geometry = models.PolygonField(blank=True, null=True)
|
geometry = models.PolygonField(blank=True, null=True)
|
||||||
|
alt_names = generic.GenericRelation("AlternativeName")
|
||||||
|
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -57,6 +61,8 @@ class Road(models.Model):
|
||||||
name_mr= models.TextField(null=True, blank=True, max_length=512)
|
name_mr= models.TextField(null=True, blank=True, max_length=512)
|
||||||
display_name = models.TextField(blank=True, max_length=255)
|
display_name = models.TextField(blank=True, max_length=255)
|
||||||
geometry = models.LineStringField(blank=True, null=True)
|
geometry = models.LineStringField(blank=True, null=True)
|
||||||
|
alt_names = generic.GenericRelation("AlternativeName")
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
@ -85,6 +91,8 @@ class Stop(models.Model):
|
||||||
name_mr= models.TextField(null=True, blank=True, max_length=512)#null=True,
|
name_mr= models.TextField(null=True, blank=True, max_length=512)#null=True,
|
||||||
|
|
||||||
point = models.PointField(null=True)
|
point = models.PointField(null=True)
|
||||||
|
alt_names = generic.GenericRelation("AlternativeName")
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
@ -193,6 +201,7 @@ class Landmark(models.Model):
|
||||||
name_mr = models.TextField(max_length=512, blank=True, null=True)
|
name_mr = models.TextField(max_length=512, blank=True, null=True)
|
||||||
display_name = models.TextField(blank=True, max_length=255)
|
display_name = models.TextField(blank=True, max_length=255)
|
||||||
point = models.PointField(blank=True, null=True)
|
point = models.PointField(blank=True, null=True)
|
||||||
|
alt_names = generic.GenericRelation("AlternativeName")
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -224,3 +233,20 @@ class Holiday(models.Model):
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
ALT_TYPE_CHOICES = (
|
||||||
|
('alt', 'General Alternative Name'),
|
||||||
|
('old', 'Old Name'),
|
||||||
|
('common', 'Common Name')
|
||||||
|
)
|
||||||
|
|
||||||
|
class AlternativeName(models.Model):
|
||||||
|
name = models.CharField(max_length=512)
|
||||||
|
name_mr = models.CharField(max_length=512, blank=True)
|
||||||
|
typ = models.CharField(max_length=64, choices=ALT_TYPE_CHOICES, default="alt")
|
||||||
|
content_type = models.ForeignKey(ContentType)
|
||||||
|
object_id = models.PositiveIntegerField()
|
||||||
|
content_object = generic.GenericForeignKey('content_type', 'object_id')
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.name
|
||||||
|
|
Loading…
Reference in New Issue
Block a user