2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 04:00:57 +00:00

Base URL configuration options (#4749)

* Improve construct_absolute_url method

- Look for hard-coded site URL if provided
- Otherwise look for specified site URL
- Otherwise look at the provided request object

* Refactor existing code which used base URL setting

* Update docs

* Validate that a provided base URL is valid
This commit is contained in:
Oliver
2023-05-02 22:14:57 +10:00
committed by GitHub
parent 10c3d101e8
commit 61d613ff34
9 changed files with 75 additions and 33 deletions

View File

@ -20,7 +20,7 @@ import common.models
import order.models
import part.models
import stock.models
from InvenTree.helpers import validateFilterString
from InvenTree.helpers import get_base_url, validateFilterString
from InvenTree.models import MetadataMixin
from plugin.registry import registry
@ -203,7 +203,7 @@ class ReportTemplateBase(MetadataMixin, ReportBase):
# Generate custom context data based on the particular report subclass
context = self.get_context_data(request)
context['base_url'] = common.models.InvenTreeSetting.get_setting('INVENTREE_BASE_URL')
context['base_url'] = get_base_url(request=request)
context['date'] = datetime.datetime.now().date()
context['datetime'] = datetime.datetime.now()
context['default_page_size'] = common.models.InvenTreeSetting.get_setting('REPORT_DEFAULT_PAGE_SIZE')

View File

@ -205,10 +205,7 @@ def logo_image(**kwargs):
def internal_link(link, text):
"""Make a <a></a> href which points to an InvenTree URL.
Important Note: This only works if the INVENTREE_BASE_URL parameter is set!
If the INVENTREE_BASE_URL parameter is not configured,
the text will be returned (unlinked)
Uses the InvenTree.helpers.construct_absolute_url function to build the URL.
"""
text = str(text)