Skip to content
Snippets Groups Projects
Commit 2e3d1521 authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

normalize path

parent b1f450ce
No related branches found
No related tags found
1 merge request!1Release
import os
from xml.etree import ElementTree from xml.etree import ElementTree
import requests import requests
...@@ -427,11 +429,14 @@ def get_ares_info(request, ico: int): ...@@ -427,11 +429,14 @@ def get_ares_info(request, ico: int):
def handle_404(request, exception): def handle_404(request, exception):
path = request.get_full_path() path = os.path.normpath(request.get_full_path())
archive_url = f"https://smlouvy-archiv.pirati.cz{path}" archive_url = f"https://smlouvy-archiv.pirati.cz{path}"
archive_response = requests.get(archive_url) archive_response = requests.get(archive_url)
# Quick dirty check for whether the page found is an actual contract
was_found = archive_response.ok and "Datum podpisu" in str(archive_response.content)
return render( return render(
request, request,
"contracts/404.html", "contracts/404.html",
...@@ -439,7 +444,7 @@ def handle_404(request, exception): ...@@ -439,7 +444,7 @@ def handle_404(request, exception):
**get_base_context(request), **get_base_context(request),
"title": "Stránka nenalezena", "title": "Stránka nenalezena",
"description": "", "description": "",
"archive_page_exists": archive_response.ok, "archive_page_exists": was_found,
"archive_url": archive_url, "archive_url": archive_url,
} }
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment