[paperwork] Use a ListView for member certifications

This commit is contained in:
Adam Goldsmith 2022-02-15 21:43:19 -05:00
parent f3a262f56f
commit 187e958b60
2 changed files with 10 additions and 8 deletions

View File

@ -7,7 +7,7 @@ app_name = "paperwork"
urlpatterns = [
path(
"certifications/by_uid/<str:uid>",
views.member_certifications,
views.MemberCertificationListView.as_view(),
name="member_certifications",
),
]

View File

@ -1,12 +1,14 @@
from django.shortcuts import render
from django.shortcuts import get_object_or_404
from django.views.generic import ListView
from membershipworks.models import Member
from .models import Certification
def member_certifications(request, uid: str):
context = {
"member": Member.objects.get(uid=uid),
"certifications": Certification.objects.filter(member_id=uid),
}
return render(request, "paperwork/member_certifications.dj.html", context)
class MemberCertificationListView(ListView):
template_name = "paperwork/member_certifications.dj.html"
context_object_name = "certifications"
def get_queryset(self):
self.member = get_object_or_404(Member, uid=self.kwargs["uid"])
return Certification.objects.filter(member=self.member)