Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:maykinmedia/open-inwoner into de…
Browse files Browse the repository at this point in the history
…velop
  • Loading branch information
alextreme committed Oct 13, 2023
2 parents 995abdd + b335e52 commit aca76f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
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
10 changes: 8 additions & 2 deletions src/open_inwoner/ssd/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import requests
from lxml import etree # nosec
from lxml.etree import LxmlError # nosec
from xsdata.exceptions import ParserError
from xsdata.formats.dataclass.context import XmlContext
from xsdata.formats.dataclass.parsers import XmlParser
Expand Down Expand Up @@ -41,14 +42,19 @@ def _get_report_info(
if not response.content:
return None

tree = etree.fromstring(response.content)
node = tree.find(info_response_node)
try:
tree = etree.fromstring(response.content).getroottree()
node = tree.find(info_response_node)
except LxmlError:
return None

parser = XmlParser(context=XmlContext(), handler=LxmlEventHandler)

try:
info = parser.parse(node, info_type)
except ParserError:
return None

return info


Expand Down

0 comments on commit aca76f9

Please sign in to comment.