Fix: include subpath in logo url (#8374)

This commit is contained in:
shamoon 2024-11-28 08:11:35 -08:00
parent c08ca6e3e5
commit 771b6606e0
2 changed files with 23 additions and 1 deletions

View File

@ -14,7 +14,7 @@ def settings(request):
app_logo = ( app_logo = (
django_settings.APP_LOGO django_settings.APP_LOGO
if general_config.app_logo is None or len(general_config.app_logo) == 0 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 { return {

View File

@ -6,12 +6,14 @@ from django.conf import settings
from django.contrib.auth.models import Permission from django.contrib.auth.models import Permission
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.test import TestCase from django.test import TestCase
from django.test import override_settings
from django.utils import timezone from django.utils import timezone
from rest_framework import status from rest_framework import status
from documents.models import Document from documents.models import Document
from documents.models import ShareLink from documents.models import ShareLink
from documents.tests.utils import DirectoriesMixin from documents.tests.utils import DirectoriesMixin
from paperless.models import ApplicationConfiguration
class TestViews(DirectoriesMixin, TestCase): class TestViews(DirectoriesMixin, TestCase):
@ -67,6 +69,26 @@ class TestViews(DirectoriesMixin, TestCase):
f"frontend/{language_actual}/main.js", 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): def test_share_link_views(self):
""" """
GIVEN: GIVEN: