diff --git a/InvenTree/InvenTree/context.py b/InvenTree/InvenTree/context.py new file mode 100644 index 0000000000..7de41eef15 --- /dev/null +++ b/InvenTree/InvenTree/context.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +""" +Provides extra global data to all templates. +""" + +from InvenTree.status_codes import SalesOrderStatus, PurchaseOrderStatus +from InvenTree.status_codes import BuildStatus, StockStatus + + +def status_codes(request): + + return { + # Expose the StatusCode classes to the templates + 'SalesOrderStatus': SalesOrderStatus, + 'PurchaseOrderStatus': PurchaseOrderStatus, + 'BuildStatus': BuildStatus, + 'StockStatus': StockStatus, + } diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index fa6bf96ec7..e409c3dc4b 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -145,8 +145,10 @@ TEMPLATES = [ 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', + 'django.template.context_processors.i18n', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + 'InvenTree.context.status_codes', ], }, }, diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index f7c8ace219..0e0bf52849 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -65,7 +65,7 @@ src="{% static 'img/blank_image.png' %}" {% trans "Status" %} - {% build_status build.status %} + {% build_status_label build.status %} diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index 42f8852ef9..6abbc69bc5 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -40,7 +40,7 @@ {% trans "Status" %} - {% build_status build.status %} + {% build_status_label build.status %} {% if build.batch %} diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html index 0105e71e83..64bf832c02 100644 --- a/InvenTree/order/templates/order/order_base.html +++ b/InvenTree/order/templates/order/order_base.html @@ -67,7 +67,7 @@ src="{% static 'img/blank_image.png' %}" {% trans "Order Status" %} - {% purchase_order_status order.status %} + {% purchase_order_status_label order.status %} diff --git a/InvenTree/order/templates/order/sales_order_base.html b/InvenTree/order/templates/order/sales_order_base.html index 5cba99a0cb..9aeaa02e73 100644 --- a/InvenTree/order/templates/order/sales_order_base.html +++ b/InvenTree/order/templates/order/sales_order_base.html @@ -29,6 +29,7 @@ src="{% static 'img/blank_image.png' %}" {% block page_data %} +

{% trans "Sales Order" %}


{{ order }}

@@ -36,12 +37,15 @@ src="{% static 'img/blank_image.png' %}"
- {% if order.is_pending %} + {% if order.status == SalesOrderStatus.PENDING %} + @@ -62,7 +66,7 @@ src="{% static 'img/blank_image.png' %}" {% trans "Order Status" %} - {% sales_order_status order.status %} + {% sales_order_status_label order.status %} diff --git a/InvenTree/order/templates/order/sales_order_detail.html b/InvenTree/order/templates/order/sales_order_detail.html index a809f498b4..e4200f73f8 100644 --- a/InvenTree/order/templates/order/sales_order_detail.html +++ b/InvenTree/order/templates/order/sales_order_detail.html @@ -6,9 +6,6 @@ {% load static %} {% block details %} - -{% include 'order/so_tabs.html' with tab='details' %} -

{% trans "Sales Order Items" %}

diff --git a/InvenTree/part/templates/part/allocation.html b/InvenTree/part/templates/part/allocation.html index cab6c44022..77fa720403 100644 --- a/InvenTree/part/templates/part/allocation.html +++ b/InvenTree/part/templates/part/allocation.html @@ -18,7 +18,7 @@ {{ allocation.build.title }} {{ allocation.build.quantity }} × {{ allocation.build.part.full_name }} {{ allocation.quantity }} - {% build_status allocation.build.status %} + {% build_status_label allocation.build.status %} {% endfor %} diff --git a/InvenTree/part/templatetags/status_codes.py b/InvenTree/part/templatetags/status_codes.py index 704bcd3b7c..ad972726c1 100644 --- a/InvenTree/part/templatetags/status_codes.py +++ b/InvenTree/part/templatetags/status_codes.py @@ -11,35 +11,24 @@ register = template.Library() @register.simple_tag -def purchase_order_status(key, *args, **kwargs): +def purchase_order_status_label(key, *args, **kwargs): + """ Render a PurchaseOrder status label """ return mark_safe(PurchaseOrderStatus.render(key)) @register.simple_tag -def sales_order_status(key, *args, **kwargs): +def sales_order_status_label(key, *args, **kwargs): + """ Render a SalesOrder status label """ return mark_safe(SalesOrderStatus.render(key)) @register.simple_tag -def stock_status(key, *args, **kwargs): +def stock_status_label(key, *args, **kwargs): + """ Render a StockItem status label """ return mark_safe(StockStatus.render(key)) @register.simple_tag -def build_status(key, *args, **kwargs): +def build_status_label(key, *args, **kwargs): + """ Render a Build status label """ return mark_safe(BuildStatus.render(key)) - - -@register.simple_tag(takes_context=True) -def load_status_codes(context): - """ - Make the various StatusCodes available to the page context - """ - - context['purchase_order_status_codes'] = PurchaseOrderStatus.list() - context['sales_order_status_codes'] = SalesOrderStatus.list() - context['stock_status_codes'] = StockStatus.list() - context['build_status_codes'] = BuildStatus.list() - - # Need to return something as the result is rendered to the page - return '' diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index c90a062fa1..b6114927f0 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -210,7 +210,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} {% trans "Status" %} - {% stock_status item.status %} + {% stock_status_label item.status %} {% endblock %} diff --git a/InvenTree/templates/table_filters.html b/InvenTree/templates/table_filters.html index ccaea8ecab..b337b25ac8 100644 --- a/InvenTree/templates/table_filters.html +++ b/InvenTree/templates/table_filters.html @@ -1,14 +1,12 @@ {% load i18n %} {% load status_codes %} -{% load_status_codes %} -