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

Refactor model helpers into own file (#4927)

* Refactor model helpers into own file to allow helper import when apps not loaded yet

* Import helper functions at module level

* Added missing imports where vscode couldnt help because its no explicit import
This commit is contained in:
Lukas
2023-05-31 01:18:42 +02:00
committed by GitHub
parent a196f443a1
commit 99d122baa9
20 changed files with 343 additions and 316 deletions

View File

@ -20,7 +20,8 @@ import common.models
import order.models
import part.models
import stock.models
from InvenTree.helpers import get_base_url, validateFilterString
from InvenTree.helpers import validateFilterString
from InvenTree.helpers_model import get_base_url
from InvenTree.models import MetadataMixin
from plugin.registry import registry

View File

@ -8,6 +8,7 @@ from django.conf import settings
from django.utils.safestring import SafeString, mark_safe
import InvenTree.helpers
import InvenTree.helpers_model
from common.models import InvenTreeSetting
from company.models import Company
from part.models import Part
@ -205,11 +206,11 @@ def logo_image(**kwargs):
def internal_link(link, text):
"""Make a <a></a> href which points to an InvenTree URL.
Uses the InvenTree.helpers.construct_absolute_url function to build the URL.
Uses the InvenTree.helpers_model.construct_absolute_url function to build the URL.
"""
text = str(text)
url = InvenTree.helpers.construct_absolute_url(link)
url = InvenTree.helpers_model.construct_absolute_url(link)
# If the base URL is not set, just return the text
if not url:
@ -246,7 +247,7 @@ def divide(x, y):
def render_currency(money, **kwargs):
"""Render a currency / Money object"""
return InvenTree.helpers.render_currency(money, **kwargs)
return InvenTree.helpers_model.render_currency(money, **kwargs)
@register.simple_tag