mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-01 03:00:54 +00:00
fix(backend): change notification for INVE-W10 (#9864)
implements changes requested in https://github.com/inventree/InvenTree/pull/9769#issuecomment-3004193476
This commit is contained in:
@ -17,6 +17,7 @@ from rest_framework.response import Response
|
|||||||
from rest_framework.serializers import ValidationError
|
from rest_framework.serializers import ValidationError
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
|
import InvenTree.config
|
||||||
import InvenTree.version
|
import InvenTree.version
|
||||||
from common.settings import get_global_setting
|
from common.settings import get_global_setting
|
||||||
from InvenTree import helpers
|
from InvenTree import helpers
|
||||||
@ -309,7 +310,7 @@ class InfoView(APIView):
|
|||||||
'system_health': check_system_health() if is_staff else None,
|
'system_health': check_system_health() if is_staff else None,
|
||||||
'database': InvenTree.version.inventreeDatabase() if is_staff else None,
|
'database': InvenTree.version.inventreeDatabase() if is_staff else None,
|
||||||
'platform': InvenTree.version.inventreePlatform() if is_staff else None,
|
'platform': InvenTree.version.inventreePlatform() if is_staff else None,
|
||||||
'installer': InvenTree.version.inventreeInstaller() if is_staff else None,
|
'installer': InvenTree.config.inventreeInstaller() if is_staff else None,
|
||||||
'target': InvenTree.version.inventreeTarget() if is_staff else None,
|
'target': InvenTree.version.inventreeTarget() if is_staff else None,
|
||||||
'django_admin': settings.INVENTREE_ADMIN_URL
|
'django_admin': settings.INVENTREE_ADMIN_URL
|
||||||
if (is_staff and settings.INVENTREE_ADMIN_ENABLED)
|
if (is_staff and settings.INVENTREE_ADMIN_ENABLED)
|
||||||
|
@ -74,8 +74,40 @@ def get_root_dir() -> Path:
|
|||||||
return get_base_dir().parent.parent.parent
|
return get_base_dir().parent.parent.parent
|
||||||
|
|
||||||
|
|
||||||
|
def inventreeInstaller() -> Optional[str]:
|
||||||
|
"""Returns the installer for the running codebase - if set or detectable."""
|
||||||
|
# First look in the environment variables, e.g. if running in docker
|
||||||
|
|
||||||
|
installer = os.environ.get('INVENTREE_PKG_INSTALLER', '')
|
||||||
|
|
||||||
|
if installer:
|
||||||
|
return str(installer)
|
||||||
|
elif os.environ.get('INVENTREE_DEVCONTAINER', 'False') == 'True':
|
||||||
|
return 'DEV'
|
||||||
|
|
||||||
|
try:
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
from InvenTree.version import main_commit
|
||||||
|
|
||||||
|
if settings.DOCKER:
|
||||||
|
return 'DOC'
|
||||||
|
elif main_commit is not None:
|
||||||
|
return 'GIT'
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_config_dir() -> Path:
|
def get_config_dir() -> Path:
|
||||||
"""Returns the InvenTree configuration directory."""
|
"""Returns the InvenTree configuration directory depending on the install type."""
|
||||||
|
if inst := inventreeInstaller():
|
||||||
|
if inst == 'DOC':
|
||||||
|
return Path('/home/inventree/data/').resolve()
|
||||||
|
elif inst == 'DEV':
|
||||||
|
return Path('/home/inventree/dev/').resolve()
|
||||||
|
elif inst == 'PKG':
|
||||||
|
return Path('/etc/inventree/').resolve()
|
||||||
return get_root_dir().joinpath('config').resolve()
|
return get_root_dir().joinpath('config').resolve()
|
||||||
|
|
||||||
|
|
||||||
@ -544,6 +576,7 @@ def check_config_dir(
|
|||||||
setting_name,
|
setting_name,
|
||||||
config_dir,
|
config_dir,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from common.settings import GlobalWarningCode, set_global_warning
|
from common.settings import GlobalWarningCode, set_global_warning
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ from django.conf import settings as djangosettings
|
|||||||
import structlog
|
import structlog
|
||||||
|
|
||||||
import common.models
|
import common.models
|
||||||
|
import InvenTree.config
|
||||||
import InvenTree.helpers
|
import InvenTree.helpers
|
||||||
import plugin.models
|
import plugin.models
|
||||||
from common.settings import get_global_setting
|
from common.settings import get_global_setting
|
||||||
@ -119,7 +120,7 @@ def inventree_commit_hash(*args, **kwargs):
|
|||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
def inventree_installer(*args, **kwargs):
|
def inventree_installer(*args, **kwargs):
|
||||||
"""Return InvenTree package installer string."""
|
"""Return InvenTree package installer string."""
|
||||||
return version.inventreeInstaller()
|
return InvenTree.config.inventreeInstaller()
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
|
@ -262,22 +262,6 @@ def inventreeCommitDate():
|
|||||||
return str(commit_dt.date())
|
return str(commit_dt.date())
|
||||||
|
|
||||||
|
|
||||||
def inventreeInstaller():
|
|
||||||
"""Returns the installer for the running codebase - if set."""
|
|
||||||
# First look in the environment variables, e.g. if running in docker
|
|
||||||
|
|
||||||
installer = os.environ.get('INVENTREE_PKG_INSTALLER', '')
|
|
||||||
|
|
||||||
if installer:
|
|
||||||
return installer
|
|
||||||
elif settings.DOCKER:
|
|
||||||
return 'DOC'
|
|
||||||
elif main_commit is not None:
|
|
||||||
return 'GIT'
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def inventreeBranch():
|
def inventreeBranch():
|
||||||
"""Returns the branch for the running codebase - if set."""
|
"""Returns the branch for the running codebase - if set."""
|
||||||
# First look in the environment variables, e.g. if running in docker
|
# First look in the environment variables, e.g. if running in docker
|
||||||
|
Reference in New Issue
Block a user