2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 21:45:39 +00:00

Merge branch 'master' of https://github.com/inventree/InvenTree into matmair/issue2279

This commit is contained in:
Matthias
2022-01-12 02:13:50 +01:00
96 changed files with 12549 additions and 10196 deletions

View File

@ -1980,10 +1980,10 @@ class Part(MPTTModel):
@property
def attachment_count(self):
""" Count the number of attachments for this part.
"""
Count the number of attachments for this part.
If the part is a variant of a template part,
include the number of attachments for the template part.
"""
return self.part_attachments.count()
@ -2181,7 +2181,9 @@ def after_save_part(sender, instance: Part, created, **kwargs):
Function to be executed after a Part is saved
"""
if not created:
if created:
pass
else:
# Check part stock only if we are *updating* the part (not creating it)
# Run this check in the background

View File

@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
""" This module provides template tags for extra functionality
"""
This module provides template tags for extra functionality,
over and above the built-in Django tags.
"""
import os
import sys
from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _
@ -15,6 +17,7 @@ from django import template
from django.urls import reverse
from django.utils.safestring import mark_safe
from django.templatetags.static import StaticNode
from InvenTree import version, settings
import InvenTree.helpers
@ -22,6 +25,8 @@ import InvenTree.helpers
from common.models import InvenTreeSetting, ColorTheme, InvenTreeUserSetting
from common.settings import currency_code_default
from plugin.models import PluginSetting
register = template.Library()
@ -104,6 +109,13 @@ def inventree_docker_mode(*args, **kwargs):
return djangosettings.DOCKER
@register.simple_tag()
def plugins_enabled(*args, **kwargs):
""" Return True if plugins are enabled for the server instance """
return djangosettings.PLUGINS_ENABLED
@register.simple_tag()
def inventree_db_engine(*args, **kwargs):
""" Return the InvenTree database backend e.g. 'postgresql' """
@ -223,8 +235,16 @@ def setting_object(key, *args, **kwargs):
if a user-setting was requested return that
"""
if 'plugin' in kwargs:
# Note, 'plugin' is an instance of an InvenTreePlugin class
plugin = kwargs['plugin']
return PluginSetting.get_setting_object(key, plugin=plugin)
if 'user' in kwargs:
return InvenTreeUserSetting.get_setting_object(key, user=kwargs['user'])
return InvenTreeSetting.get_setting_object(key)