This commit is contained in:
Paul Konstantin Gerke 2023-07-05 00:18:52 +02:00 committed by Christopher Charbonneau Wells
parent c716334f02
commit c1eb9da7f3
2 changed files with 10 additions and 9 deletions

View File

@ -10,6 +10,7 @@ from django.utils import timezone, translation
from django.contrib.auth.middleware import RemoteUserMiddleware
from django.http import HttpRequest
class UserLanguageMiddleware:
"""
Customizes settings based on user language setting.
@ -139,11 +140,10 @@ class HomeAssistant:
url_parts._replace(path=x_ingress_path + url_parts.path)
)
return url
return wrapper
request.build_absolute_uri = wrap_x_ingress_path(
request.build_absolute_uri
)
request.build_absolute_uri = wrap_x_ingress_path(request.build_absolute_uri)
def __call__(self, request: HttpRequest):
if self.home_assistant_support_enabled:
@ -156,4 +156,3 @@ class HomeAssistant:
self.__wrap_build_absolute_uri(request)
return self.get_response(request)

View File

@ -67,4 +67,6 @@ class HomeAssistantMiddlewareTestCase(TestCase):
)
json_response = json.loads(response.content)
self.assertEqual(json_response["profile"], "http://testserver/magic/sub/url/api/profile")
self.assertEqual(
json_response["profile"], "http://testserver/magic/sub/url/api/profile"
)