From 9697290f959c6d3b7e11eac1eb5540cc98b54caf Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 23 Aug 2011 20:29:20 +0530 Subject: [PATCH] added list_display fields in admin; show only 300 features per page, not 500 --- gazetteer/places/admin.py | 8 ++++++-- gazetteer/places/models.py | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/gazetteer/places/admin.py b/gazetteer/places/admin.py index c57b737..422baca 100644 --- a/gazetteer/places/admin.py +++ b/gazetteer/places/admin.py @@ -14,7 +14,8 @@ class FeatureAdmin(admin.OSMGeoAdmin): search_fields = ['preferred_name'] list_filter = ('feature_type',) inlines = [FeatureNamesInline] - list_per_page = 500 + list_display = ('__unicode__', 'feature_type_name', 'time_start', 'time_end',) + list_per_page = 300 openlayers_url = 'http://openlayers.org/dev/OpenLayers.js' openlayers_img_path = None # map_template = 'gis/admin/osm.html' @@ -23,7 +24,10 @@ class FeatureAdmin(admin.OSMGeoAdmin): # default_zoom = 4 # extra_js = ['http://openstreetmap.org/openlayers/OpenStreetMap.js'] +class FeatureTypeAdmin(admin.ModelAdmin): + list_display = ('code', 'name', 'description', 'feature_class',) + admin.site.register(Feature, FeatureAdmin) admin.site.register(TimeFrame) -admin.site.register(FeatureType) +admin.site.register(FeatureType, FeatureTypeAdmin) admin.site.register(Relationship) diff --git a/gazetteer/places/models.py b/gazetteer/places/models.py index affbb7f..e37b955 100644 --- a/gazetteer/places/models.py +++ b/gazetteer/places/models.py @@ -28,6 +28,25 @@ class Feature(models.Model): def __unicode__(self): return self.preferred_name + def feature_type_name(self): + return "%s: %s" % (self.feature_type.code, self.feature_type.name,) + feature_type_name.description = "Feature Type" + + def time_start(self): + tf = self.time_frame + if tf is not None: + return str(tf.start_date) + else: + return '' + time_start.description = "Start Date" + + def time_end(self): + tf = self.time_frame + if tf is not None: + return str(tf.end_sate) + else: + return '' + time_end.description = "End Date" LANGUAGE_CHOICES = (