[paperwork] Use a ListView for member certifications
This commit is contained in:
parent
f3a262f56f
commit
187e958b60
@ -7,7 +7,7 @@ app_name = "paperwork"
|
||||
urlpatterns = [
|
||||
path(
|
||||
"certifications/by_uid/<str:uid>",
|
||||
views.member_certifications,
|
||||
views.MemberCertificationListView.as_view(),
|
||||
name="member_certifications",
|
||||
),
|
||||
]
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user