Merge remote-tracking branch 'inventree/master'

This commit is contained in:
Oliver Walters 2020-11-23 12:52:27 +11:00
commit c05499b723
2 changed files with 31 additions and 0 deletions

View File

@ -13,6 +13,22 @@ from users.models import RuleSet
def health_status(request):
"""
Provide system health status information to the global context.
- Not required for AJAX requests
- Do not provide if it is already provided to the context
"""
if request.path.endswith('.js'):
# Do not provide to script requests
return {}
if hasattr(request, '_inventree_health_status'):
# Do not duplicate efforts
return {}
request._inventree_health_status = True
return {
"system_healthy": InvenTree.status.check_system_health(),
@ -20,6 +36,15 @@ def health_status(request):
def status_codes(request):
"""
Provide status code enumerations.
"""
if hasattr(request, '_inventree_status_codes'):
# Do not duplicate efforts
return {}
request._inventree_status_codes = True
return {
# Expose the StatusCode classes to the templates

View File

@ -274,6 +274,12 @@ class SupplierPartEdit(AjaxUpdateView):
def get_form(self):
form = super().get_form()
supplier_part = self.get_object()
# It appears that hiding a MoneyField fails validation
# Therefore the idea to set the value before hiding
if form.is_valid():
form.cleaned_data['single_pricing'] = supplier_part.unit_pricing
# Hide the single-pricing field (only for creating a new SupplierPart!)
form.fields['single_pricing'].widget = HiddenInput()