changes to admin listview for atlas and flag widget for stop

This commit is contained in:
Johnson Chetty 2012-02-09 13:38:04 +01:00
parent 5940e93352
commit 1d92de5719
3 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,24 @@
from mumbai.models import *
"Road, Area, Landmark, Stop"
def copynames2display_name():
for obj in Stop.objects.all():
obj.display_name =obj.name
obj.save()
for obj in Area.objects.all():
obj.display_name =obj.name
obj.save()
for obj in Landmark.objects.all():
obj.display_name =obj.name
obj.save()
for obj in Road.objects.all():
obj.display_name =obj.name
obj.save()
def copydefaultStopLocations():
for stop in Stop.objects.all():
stop.stop = stop.stoplocation_set.all()[0]

View File

@ -49,6 +49,12 @@ class FareAdmin(admin.ModelAdmin):
}
class UniqueRouteAdmin(admin.ModelAdmin):
list_display = ("route","from_stop", "to_stop","distance","is_full")
readonly_fields = ("route","from_stop", "to_stop","distance","is_full")
search_fields = ("route", "from_stop__name", "to_stop__name")
ordering = ('route',)
list_per_page = 50
inlines = [RouteScheduleInline]
@ -59,12 +65,14 @@ class StopForm(forms.ModelForm):
class StopAdmin(admin.OSMGeoAdmin):
list_display = ("code","display_name", "name_mr","name", "road","area","depot", "point")
list_display = ("code","display_name", "name_mr","name", "road","area","depot", "has_point")
list_editable = ("display_name", "name_mr","depot",)
readonly_fields = ("code","name","road","area","depot","chowki" )
search_fields = ("code",'name', 'depot__name', "road__name", "area__name")
ordering = ('name',)
list_per_page = 20
"""
fieldsets = (
(None, {

View File

@ -96,6 +96,18 @@ class Stop(models.Model):
def __unicode__(self):
return self.name
'''
check if point exists for stop
'''
def has_point(self):
if self.stoplocation_set.all():
return True
else:
return False
has_point.boolean = True
class Route(models.Model):
code = models.TextField(max_length=255, unique=True)
@ -138,6 +150,7 @@ class UniqueRoute(models.Model):
class Meta:
verbose_name = 'Atlas'
verbose_name_plural = 'Atlas'
def __unicode__(self):
return "%s: %s to %s" % (self.route.alias, self.from_stop_txt, self.to_stop_txt)