From 3d0c79f68c9c405167db19962b8f0a38c544ed86 Mon Sep 17 00:00:00 2001 From: Johnson Chetty Date: Fri, 16 Dec 2011 17:48:17 +0530 Subject: [PATCH] a little better admin interface and cleaner code --- chaloBEST/admin.py | 68 ++++++++++++++++++++++++++++++ chaloBEST/chalobest.db | Bin 988160 -> 988160 bytes chaloBEST/imports/import_atlas.py | 7 +++ chaloBEST/mumbai/models.py | 38 +---------------- 4 files changed, 76 insertions(+), 37 deletions(-) create mode 100644 chaloBEST/admin.py diff --git a/chaloBEST/admin.py b/chaloBEST/admin.py new file mode 100644 index 0000000..ce7f0d5 --- /dev/null +++ b/chaloBEST/admin.py @@ -0,0 +1,68 @@ +from django.contrib import admin +from django import forms +from mumbai.models import * + +class AreaAdmin(admin.ModelAdmin): + list_display = ("a_code", "areanm") + + +class RoadAdmin(admin.ModelAdmin): + list_display = ("roadcd","roadnm") + + +class FareAdmin(admin.ModelAdmin): + list_display = ("slab","ordinary","limited","express","ac","ac_express") + + +class StopForm(forms.ModelForm): + + class Meta: + model = Stop + + +class StopAdmin(admin.ModelAdmin): + list_display = ("stopcd","stopnm", "roadcd","a_code","stopfl","depot","chowki") + fieldsets = ( + (None, { + 'fields': ('stopnm', 'a_code', 'roadcd') + }), + ('Advanced options', { + 'classes': ('collapse',), + 'fields': ('stopcd', 'chowki', 'depot') + }), + ) + form = StopForm + # For mapping widget + #formfield_overrides = { + # models.TextField: {'widget': RichTextEditorWidget}, + #} + + +class RouteDetailsAdmin(admin.ModelAdmin): + list_display = ("rno","stopsr","stopcd","stage","km") + + +class RouteAdmin(admin.ModelAdmin): + list_display = ("routealias","route","from_stop","to_stop","distance","stages") + + +class RouteTypesAdmin(admin.ModelAdmin): + list_display = ("routecode","routetype","faretype") + + +class HardCodedRoutesAdmin(admin.ModelAdmin): + list_display = ("routecode","routealias","faretype") + + + +admin.site.register(Area, AreaAdmin) +admin.site.register(Road, RoadAdmin) +admin.site.register(Fare,FareAdmin) + +admin.site.register(Stop, StopAdmin) +admin.site.register(RouteDetails, RouteDetailsAdmin) +admin.site.register(Route, RouteAdmin) + +admin.site.register(RouteTypes, RouteTypesAdmin) +admin.site.register(HardCodedRoutes, HardCodedRoutesAdmin) + diff --git a/chaloBEST/chalobest.db b/chaloBEST/chalobest.db index fcedc825335c5ad1c7599989588e2a4f5fee4981..9075c502f5111397a6ead8a75f5735e1a05fb77b 100644 GIT binary patch delta 549 zcmbWzy-EW?6b0a{Hzxi>C4~@BG=+_VGBdlA*@QG36GUXAxMFk)F+00)iK}3tkysdi zz{bL`kD!IE1hf$ggN=`1mnZNE1VdyUgbMxKIbp46jVOPeO~oEzOt?I(mV}> zb$OirslpJ`n0|5){!Y{@qAZZD6NV~8rMAG1ZM#f!bU_5B+J6$w>Yicj;zPsoRttXG zbJl`=s~*>rM9ol?QB!gbT@DgNt&ctcKLkG9L$igv4Jb~4sr)rV6L=HaiWV8}|g z-bzzm4B$Eh9e9RoIB&%hH3(kXlla#zkufl2KE~6SOp{-g!)KlLMW?MuT@pxPsauLj VQK?7jmHMQ9DJBg(blQXCOP}4pssI20 delta 171 zcmZozVbid}W`Z=M<3t%}M#qf_@67~_6%5R+Obo3|4fHGxO^l6FrtW@lh# zXWFw_P+}9)>>>>>> MERGE-SOURCE diff --git a/chaloBEST/mumbai/models.py b/chaloBEST/mumbai/models.py index 3fe90e0..a78de93 100644 --- a/chaloBEST/mumbai/models.py +++ b/chaloBEST/mumbai/models.py @@ -1,6 +1,6 @@ from django.contrib.gis.db import models from django.contrib import admin - +from django import forms class Area(models.Model): a_code = models.IntegerField(primary_key=True) @@ -92,39 +92,3 @@ class HardCodedRoutes(models.Model): return self.routecode + " " +self.routealias -class AreaAdmin(admin.ModelAdmin): - pass - -class RoadAdmin(admin.ModelAdmin): - pass - -class FareAdmin(admin.ModelAdmin): - pass - -class StopAdmin(admin.ModelAdmin): - pass - -class RouteDetailsAdmin(admin.ModelAdmin): - pass - -class RouteAdmin(admin.ModelAdmin): - pass - -class RouteTypesAdmin(admin.ModelAdmin): - pass - -class HardCodedRoutesAdmin(admin.ModelAdmin): - pass - - -admin.site.register(Area, AreaAdmin) -admin.site.register(Road, RoadAdmin) -admin.site.register(Fare,FareAdmin) - -admin.site.register(Stop, StopAdmin) -admin.site.register(RouteDetails, RouteDetailsAdmin) -admin.site.register(Route, RouteAdmin) - -admin.site.register(RouteTypes, RouteTypesAdmin) -admin.site.register(HardCodedRoutes, HardCodedRoutesAdmin) -