Fix: include subpath in logo url

This commit is contained in:
shamoon 2024-11-28 07:54:56 -08:00
parent c08ca6e3e5
commit f278c30cfb
No known key found for this signature in database
2 changed files with 27 additions and 1 deletions

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:

View File

@ -113,4 +113,8 @@ class GeneralConfig(BaseConfig):
app_config = self._get_config_instance() app_config = self._get_config_instance()
self.app_title = app_config.app_title or None self.app_title = app_config.app_title or None
self.app_logo = app_config.app_logo.url if app_config.app_logo else None self.app_logo = (
settings.BASE_URL + app_config.app_logo.url.lstrip("/")
if app_config.app_logo
else None
)