admin.py 1.16 KB
Newer Older
1
from django.contrib import admin
2
3

from django import forms
4
from .models import Specimen, SpecimenLocation, Person, Fixation
5
6
7
8
9
10
11
12
13
14
from .widgets import LatLongWidget


# Custom form to provide lat/lon widget instead of OL map.
class MyAdminForm(forms.ModelForm):

    class Meta:
        model = Specimen
        fields = "__all__"
        widgets = {
15
            'coords': LatLongWidget
16
17
        }

18
19

class SpecimenAdmin(admin.ModelAdmin):
20
    form = MyAdminForm
21

Nicolas Noé's avatar
Nicolas Noé committed
22
    list_display = ('specimen_id', 'scientific_name', 'identified_by', 'specimen_location', 'depth_str', 'fixation')
23
    list_filter = ('identified_by', 'specimen_location', 'fixation')
24
25
    search_fields = ['scientific_name', 'specimen_id']
    # TODO: document searchable fields in template? (https://stackoverflow.com/questions/11411622/add-help-text-for-search-field-in-admin-py)
26
27
28
29
30
31
32
33
34
35

class SpecimenLocationAdmin(admin.ModelAdmin):
    pass

class PersonAdmin(admin.ModelAdmin):
    pass

class FixationAdmin(admin.ModelAdmin):
    pass

36
admin.site.register(Specimen, SpecimenAdmin)
37
38
39
admin.site.register(SpecimenLocation, SpecimenLocationAdmin)
admin.site.register(Person, PersonAdmin)
admin.site.register(Fixation, FixationAdmin)