summaryrefslogtreecommitdiff
path: root/app/birds/admin.py
blob: 7bcaab24baa195e320b2ce9da67f9cc6e03c15bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from django.contrib import admin
from django.contrib.gis.admin import OSMGeoAdmin
from birds.models import BirdSighting, BirdAudio, BirdClass, Bird
from django.contrib.gis.geos import GEOSGeometry, Point

def convertll(lat, lon):
    pnt = GEOSGeometry('POINT({0} {1})'.format(lon, lat), srid=4326)
    pnt.transform(3857)
    return pnt.y, pnt.x


# Florida: lat, lon = convertll(29.658057, -84.867797)
# Athens:
lon = -9285175
lat = 4025046


class BirdClassAdmin(admin.ModelAdmin):
    list_display = ('common_name', 'scientific_name',)

class BirdAudioAdmin(admin.ModelAdmin):
    list_display = ('bird', 'recorder',)

class BirdAdmin(admin.ModelAdmin):
    list_display = ('pk', 'common_name', 'scientific_name', 'code', 'bird_class')
    list_filter = ('bird_class',)


class BirdSightingAdmin(OSMGeoAdmin):
    
    list_display = ('bird', 'location')
    list_filter = ('location',)
    fieldsets = (
        ('Sighting', {
            'fields': (
                'bird',
                'point',
                'date',
                'image',
                'seen_by'
            ),
            'classes': (
                'show',
                'extrapretty',
                'wide'
            )
        }
        ),
    )
    # options for OSM map Using custom ESRI topo map
    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'

admin.site.register(BirdSighting, BirdSightingAdmin)
admin.site.register(BirdClass, BirdClassAdmin)
admin.site.register(BirdAudio, BirdAudioAdmin)
admin.site.register(Bird, BirdAdmin)