2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-20 13:56:30 +00:00

Expose more status code data to the templates

- Status codes are now exposed globally to every page
- Much simplified so wow
- https://stackoverflow.com/questions/3221592/how-to-pass-common-dictionary-data-to-every-page-in-django
This commit is contained in:
Oliver Walters
2020-04-24 09:18:37 +10:00
parent 2c9b112562
commit b45fec221c
11 changed files with 45 additions and 36 deletions

View File

@ -18,7 +18,7 @@
<td><a href="{% url 'build-detail' allocation.build.id %}">{{ allocation.build.title }}</a></td>
<td>{{ allocation.build.quantity }} &times <a href="{% url 'part-detail' allocation.build.part.id %}">{{ allocation.build.part.full_name }}</a></td>
<td>{{ allocation.quantity }}</td>
<td>{% build_status allocation.build.status %}</td>
<td>{% build_status_label allocation.build.status %}</td>
</tr>
{% endfor %}
</table>

View File

@ -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 ''