Fix merge

This commit is contained in:
Lacey Williams Henschel
2023-02-14 10:44:04 -08:00
parent 0eba85382c
commit 8c251bdab6

View File

@@ -53,6 +53,21 @@ class LibraryDetail(CategoryMixin, DetailView):
model = Library
template_name = "libraries/detail.html"
def get_object(self):
slug = self.kwargs.get("slug")
version = Version.objects.most_recent()
if not LibraryVersion.objects.filter(
version=version, library__slug=slug
).exists():
raise Http404("No library found matching the query")
try:
obj = self.get_queryset().get(slug=slug)
except queryset.model.DoesNotExist:
raise Http404("No library found matching the query")
return obj
def get(self, request, *args, **kwargs):
self.object = self.get_object()
context = self.get_context_data(object=self.object)