diff options
Diffstat (limited to 'app/sightings/admin.py')
-rw-r--r-- | app/sightings/admin.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/app/sightings/admin.py b/app/sightings/admin.py new file mode 100644 index 0000000..196712a --- /dev/null +++ b/app/sightings/admin.py @@ -0,0 +1,49 @@ +from django.contrib import admin +from django.contrib.gis.admin import OSMGeoAdmin +from .models import APClass, AP, Sighting + +from photos.forms import GalleryForm +from utils.util import get_latlon +from utils.widgets import CustomSelectMultiple + + +class GalleryFormPlus(GalleryForm): + def __init__(self, *args, **kwargs): + super(GalleryFormPlus, self).__init__(*args, **kwargs) + self.base_fields['seen_by'].widget = CustomSelectMultiple() + + class Meta: + model = Sighting + fields = '__all__' + + +@admin.register(APClass) +class APClassAdmin(admin.ModelAdmin): + list_display = ('common_name', 'scientific_name', 'kind') + list_filter = ('kind',) + + +@admin.register(AP) +class APAdmin(admin.ModelAdmin): + list_display = ('pk', 'common_name', 'scientific_name', 'kind', 'code', 'apclass') + list_filter = ('apclass__kind','apclass') + search_fields = ['common_name', 'scientific_name'] + + +@admin.register(Sighting) +class SightingAdmin(OSMGeoAdmin): + form = GalleryFormPlus + list_filter = ('seen_by',('location', admin.RelatedOnlyFieldListFilter),) + list_display = ('ap', 'location') + # options for OSM map Using custom ESRI topo map + lat, lon = get_latlon() + print(lat, lon) + default_lon = lon + default_lat = lat + default_zoom = 13 + units = True + scrollable = False + map_width = 700 + map_height = 425 + map_template = 'gis/admin/osm.html' + openlayers_url = '/static/admin/js/OpenLayers.js' |