summaryrefslogtreecommitdiff
path: root/app/birds/admin.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2018-01-28 10:30:57 -0600
committerluxagraf <sng@luxagraf.net>2018-01-28 10:30:57 -0600
commit916474036c1d2e041ed6425a3c0370a2e4c7e7bc (patch)
tree0536598b9a114303102f6f66242fb31d51beea36 /app/birds/admin.py
parenta278fc64c1dcd5321492a7dc384305b8719cb85e (diff)
abstracted birds out to sightings
Diffstat (limited to 'app/birds/admin.py')
-rw-r--r--app/birds/admin.py52
1 files changed, 42 insertions, 10 deletions
diff --git a/app/birds/admin.py b/app/birds/admin.py
index 77ebc8a..50bd755 100644
--- a/app/birds/admin.py
+++ b/app/birds/admin.py
@@ -1,12 +1,53 @@
from django.contrib import admin
from django.contrib.gis.admin import OSMGeoAdmin
-from birds.models import BirdSighting, BirdAudio, BirdClass, Bird
+from birds.models import BirdSighting, BirdAudio, BirdClass, Bird, 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')
+
+
+@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'
+
+
class BirdClassAdmin(admin.ModelAdmin):
list_display = ('common_name', 'scientific_name',)
@@ -19,15 +60,6 @@ class BirdAdmin(admin.ModelAdmin):
list_display = ('pk', 'common_name', 'scientific_name', 'code', 'bird_class')
list_filter = ('bird_class',)
-class GalleryFormPlus(GalleryForm):
- def __init__(self, *args, **kwargs):
- super(GalleryFormPlus, self).__init__(*args, **kwargs)
- self.base_fields['seen_by'].widget = CustomSelectMultiple()
-
- class Meta:
- model = BirdSighting
- fields = '__all__'
-
class BirdSightingAdmin(OSMGeoAdmin):
form = GalleryFormPlus
list_filter = (