added list_display fields in admin; show only 300 features per page, not 500

This commit is contained in:
Sanj 2011-08-23 20:29:20 +05:30
parent 715fe5ccf1
commit 9697290f95
2 changed files with 25 additions and 2 deletions

View File

@ -14,7 +14,8 @@ class FeatureAdmin(admin.OSMGeoAdmin):
search_fields = ['preferred_name'] search_fields = ['preferred_name']
list_filter = ('feature_type',) list_filter = ('feature_type',)
inlines = [FeatureNamesInline] 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_url = 'http://openlayers.org/dev/OpenLayers.js'
openlayers_img_path = None openlayers_img_path = None
# map_template = 'gis/admin/osm.html' # map_template = 'gis/admin/osm.html'
@ -23,7 +24,10 @@ class FeatureAdmin(admin.OSMGeoAdmin):
# default_zoom = 4 # default_zoom = 4
# extra_js = ['http://openstreetmap.org/openlayers/OpenStreetMap.js'] # 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(Feature, FeatureAdmin)
admin.site.register(TimeFrame) admin.site.register(TimeFrame)
admin.site.register(FeatureType) admin.site.register(FeatureType, FeatureTypeAdmin)
admin.site.register(Relationship) admin.site.register(Relationship)

View File

@ -28,6 +28,25 @@ class Feature(models.Model):
def __unicode__(self): def __unicode__(self):
return self.preferred_name 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 = ( LANGUAGE_CHOICES = (