diff --git a/src/documents/context_processors.py b/src/documents/context_processors.py index a9200ac11..9a012bc3a 100644 --- a/src/documents/context_processors.py +++ b/src/documents/context_processors.py @@ -14,7 +14,7 @@ def settings(request): app_logo = ( django_settings.APP_LOGO if general_config.app_logo is None or len(general_config.app_logo) == 0 - else general_config.app_logo + else django_settings.BASE_URL + general_config.app_logo.lstrip("/") ) return { diff --git a/src/documents/tests/test_views.py b/src/documents/tests/test_views.py index ca1db5782..9f52a6aa4 100644 --- a/src/documents/tests/test_views.py +++ b/src/documents/tests/test_views.py @@ -6,12 +6,14 @@ from django.conf import settings from django.contrib.auth.models import Permission from django.contrib.auth.models import User from django.test import TestCase +from django.test import override_settings from django.utils import timezone from rest_framework import status from documents.models import Document from documents.models import ShareLink from documents.tests.utils import DirectoriesMixin +from paperless.models import ApplicationConfiguration class TestViews(DirectoriesMixin, TestCase): @@ -67,6 +69,26 @@ class TestViews(DirectoriesMixin, TestCase): f"frontend/{language_actual}/main.js", ) + @override_settings(BASE_URL="/paperless/") + def test_index_app_logo_with_base_url(self): + """ + GIVEN: + - Existing config with app_logo specified + WHEN: + - Index page is loaded + THEN: + - app_logo is prefixed with BASE_URL + """ + config = ApplicationConfiguration.objects.first() + config.app_logo = "/logo/example.jpg" + config.save() + self.client.force_login(self.user) + response = self.client.get("/") + self.assertEqual( + response.context["APP_LOGO"], + f"/paperless{config.app_logo}", + ) + def test_share_link_views(self): """ GIVEN: