diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/sightings/admin.py | 11 | ||||
-rw-r--r-- | app/sightings/models.py | 7 |
2 files changed, 16 insertions, 2 deletions
diff --git a/app/sightings/admin.py b/app/sightings/admin.py index 03aaa83..5d51941 100644 --- a/app/sightings/admin.py +++ b/app/sightings/admin.py @@ -28,7 +28,8 @@ class APClassAdmin(admin.ModelAdmin): class SightingInline(OSMGeoAdmin, admin.StackedInline): """ This is very fragile and probably a bad idea since I copied this - code straight from Django and it may change, but it works for now + code straight from Django and it may change, but unless GeoDjango + adds a Mixin, this will have to do. """ model = Sighting extra = 1 @@ -64,14 +65,20 @@ class APAdmin(admin.ModelAdmin): inlines = [ SightingInline, ] - list_display = ('pk', 'common_name', 'scientific_name', 'kind', 'code', 'apclass') + list_display = ('common_name', 'have_seen', 'scientific_name', 'kind', 'code', 'apclass') list_filter = ('apclass__kind', 'apclass') search_fields = ['common_name', 'scientific_name'] + def have_seen(self, obj): + return obj.seen + have_seen.admin_order_field = 'seen' + have_seen.boolean = True + class Media: js = ('image-loader.js', 'next-prev-links.js') + @admin.register(Sighting) class SightingAdmin(OSMGeoAdmin): form = SightingsForm diff --git a/app/sightings/models.py b/app/sightings/models.py index b8d7c6f..7368bd4 100644 --- a/app/sightings/models.py +++ b/app/sightings/models.py @@ -93,6 +93,13 @@ class AP(models.Model): def get_absolute_url(self): return reverse("sightings:detail", kwargs={"slug": self.slug}) + @property + def seen(self): + if self.sighting_set.all(): + return True + else: + return False + def kind(self): return self.apclass.kind |