diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/sightings/admin.py | 13 | ||||
-rw-r--r-- | app/sightings/urls.py | 19 | ||||
-rw-r--r-- | app/sightings/views.py | 8 |
3 files changed, 30 insertions, 10 deletions
diff --git a/app/sightings/admin.py b/app/sightings/admin.py index a90cf95..d6ac5d4 100644 --- a/app/sightings/admin.py +++ b/app/sightings/admin.py @@ -24,15 +24,22 @@ class APClassAdmin(admin.ModelAdmin): list_filter = ('kind',) +class SightingInline(admin.TabularInline): + model = Sighting + + @admin.register(AP) class APAdmin(admin.ModelAdmin): form = LGEntryForm + inlines = [ + SightingInline, + ] list_display = ('pk', 'common_name', 'scientific_name', 'kind', 'code', 'apclass') - list_filter = ('apclass__kind','apclass') + list_filter = ('apclass__kind', 'apclass') search_fields = ['common_name', 'scientific_name'] - + class Media: - js = ('image-loader.js','next-prev-links.js') + js = ('image-loader.js', 'next-prev-links.js') @admin.register(Sighting) diff --git a/app/sightings/urls.py b/app/sightings/urls.py index 76a952e..7aa6ace 100644 --- a/app/sightings/urls.py +++ b/app/sightings/urls.py @@ -5,12 +5,17 @@ app_name = "sightings" urlpatterns = [ path( - r'', + r'', views.SightingListView.as_view(), - {'page':1}, + {'page': 1}, name="list" ), re_path( + r'life-list$', + views.LifeListView.as_view(), + name='life-list' + ), + re_path( r'(?P<page>\d+)/$', views.SightingListView.as_view(), name="list" @@ -20,15 +25,15 @@ urlpatterns = [ views.SightingDetailView.as_view(), name='detail' ), - #path( - # r'<str:user>/', + # path( + # r'<str:user>/', # views.SightingListUserView.as_view(), # {'page':1}, # name='list_by_person' - #), - #path( + # ), + # path( # r'<str:user>/<int:page>/', # views.SightingListUserView.as_view(), # name='list_by_person' - #), + # ), ] diff --git a/app/sightings/views.py b/app/sightings/views.py index cb821c8..f65011c 100644 --- a/app/sightings/views.py +++ b/app/sightings/views.py @@ -1,4 +1,5 @@ from django.views.generic.detail import DetailView +from django.views.generic import ListView from django.contrib.auth.models import User from utils.views import PaginatedListView from .models import AP, Sighting @@ -13,6 +14,13 @@ class SightingListView(PaginatedListView): return Sighting.objects.filter(id__in=qs_ids).order_by('-pub_date') +class LifeListView(ListView): + template_name = 'archives/life-list.html' + + def get_queryset(self): + return Sighting.objects.filter(ap__apclass__kind=1).order_by('ap__id').distinct('ap') + + class SightingListUserView(PaginatedListView): template_name = 'archives/sightings.html' |