summaryrefslogtreecommitdiff
path: root/app/sightings
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2018-06-09 13:59:23 -0500
committerluxagraf <sng@luxagraf.net>2018-06-09 13:59:23 -0500
commit91c284b00174f1f11b1bec6fec633dadb9f40dd1 (patch)
tree3428b2d11e6c8760626b9ef48df35bc697713037 /app/sightings
parent90822f204979663c79444ef8e89bda4701b8defb (diff)
added a have_seen column to admin for aps
Diffstat (limited to 'app/sightings')
-rw-r--r--app/sightings/admin.py11
-rw-r--r--app/sightings/models.py7
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