From 1d92de5719c8b108202f24c1f75713234684ca37 Mon Sep 17 00:00:00 2001 From: Johnson Chetty Date: Thu, 9 Feb 2012 13:38:04 +0100 Subject: [PATCH] changes to admin listview for atlas and flag widget for stop --- chaloBEST/imports/postload_cleanup.py | 24 ++++++++++++++++++++++++ chaloBEST/mumbai/admin.py | 10 +++++++++- chaloBEST/mumbai/models.py | 13 +++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 chaloBEST/imports/postload_cleanup.py diff --git a/chaloBEST/imports/postload_cleanup.py b/chaloBEST/imports/postload_cleanup.py new file mode 100644 index 0000000..c183648 --- /dev/null +++ b/chaloBEST/imports/postload_cleanup.py @@ -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] + + diff --git a/chaloBEST/mumbai/admin.py b/chaloBEST/mumbai/admin.py index 0fd39d9..72ef894 100644 --- a/chaloBEST/mumbai/admin.py +++ b/chaloBEST/mumbai/admin.py @@ -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, { diff --git a/chaloBEST/mumbai/models.py b/chaloBEST/mumbai/models.py index 0986655..17a392a 100644 --- a/chaloBEST/mumbai/models.py +++ b/chaloBEST/mumbai/models.py @@ -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)