diff --git a/wishlist/views.py b/wishlist/views.py index c82c833..861ba1e 100644 --- a/wishlist/views.py +++ b/wishlist/views.py @@ -1,4 +1,4 @@ -from django.shortcuts import render +from django.shortcuts import render, get_object_or_404 import wishlist.models as m import django.views.generic as dv @@ -6,6 +6,11 @@ class WishedItemView(dv.DetailView): model = m.WishedItem template_name = 'wishlist/item.html' + def get_context_data(self, **kwargs): + ctx = super().get_context_data(**kwargs) + ctx['page_title'] = f"Item: {ctx['object']}" + return ctx + class UserWishLists(dv.ListView): model = m.WishList template_name = 'wishlist/userwishlists.html' @@ -14,10 +19,21 @@ class UserWishLists(dv.ListView): qs = super().get_queryset() return qs.filter(owner__login=self.loginname) + def get_context_data(self, **kwargs): + ctx = super().get_context_data(**kwargs) + ctx['page_title'] = f"{ctx['object']}'s wishlists" + return ctx + class WishListView(dv.ListView): model = m.WishedItem template_name = 'wishlist/wishlist.html' def get_queryset(self): qs = super().get_queryset() - return qs.filter(wishlists__slug__in=[self.slug]) + return qs.filter(wishlists__slug__in=[self.kwargs["slug"]]) + + def get_context_data(self, **kwargs): + ctx = super().get_context_data(**kwargs) + ctx['page_title'] = f"Wishlist: {ctx['object']}" + ctx['wishlist'] = get_object_or_404(m.Wishlist, slug=self.kwargs['slug']) + return ctx