2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +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

@ -21,6 +21,7 @@ import common.notifications
import common.settings
import company.models
import InvenTree.helpers
import InvenTree.helpers_model
import InvenTree.tasks
import part.models
import stock.models
@ -41,7 +42,7 @@ def notify_low_stock(part: part.models.Part):
'part': part,
'name': name,
'message': message,
'link': InvenTree.helpers.construct_absolute_url(part.get_absolute_url()),
'link': InvenTree.helpers_model.construct_absolute_url(part.get_absolute_url()),
'template': {
'html': 'email/low_stock_notification.html',
'subject': name,

View File

@ -14,6 +14,7 @@ from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
import InvenTree.helpers
import InvenTree.helpers_model
from common.models import ColorTheme, InvenTreeSetting, InvenTreeUserSetting
from common.settings import currency_code_default
from InvenTree import settings, version
@ -105,7 +106,7 @@ def render_date(context, date_object):
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()
@ -224,7 +225,7 @@ def inventree_splash(**kwargs):
@register.simple_tag()
def inventree_base_url(*args, **kwargs):
"""Return the base URL of the InvenTree server"""
return InvenTree.helpers.get_base_url()
return InvenTree.helpers_model.get_base_url()
@register.simple_tag()