Skip to content

Commit

Permalink
[#1804] Fix missing category 500
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-sigma committed Oct 13, 2023
1 parent 5a60c3e commit 00a1688
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/open_inwoner/pdc/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,10 @@ def test_category_detail_description_rendered(self):
'[<p class="p">A <em>descriptive</em> description</p>, <em>descriptive</em>]',
response.rendered_content,
)

def test_category_breadcrumbs_404(self):
url = reverse(
"products:category_detail", kwargs={"slug": f"none/{self.category.slug}"}
)
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
3 changes: 2 additions & 1 deletion src/open_inwoner/pdc/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db.models import Q
from django.http import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.urls import reverse, reverse_lazy
from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _
Expand Down Expand Up @@ -32,7 +33,7 @@ def get_orderd_categories(self, slug_name="slug"):
{
"slug": sl,
"build_slug": f"{older_slugs}/{sl}" if older_slugs else sl,
"category": Category.objects.get(slug=sl),
"category": get_object_or_404(Category, slug=sl),
}
)
if older_slugs:
Expand Down

0 comments on commit 00a1688

Please sign in to comment.