Fix some build status code thingies

This commit is contained in:
Oliver Walters 2019-06-04 23:42:48 +10:00
parent f731c45ce8
commit 4f1acddb5d
3 changed files with 14 additions and 9 deletions

View File

@ -6,6 +6,8 @@ from django.test import TestCase
from .models import Build from .models import Build
from part.models import Part from part.models import Part
from InvenTree.status_codes import BuildStatus
class BuildTestSimple(TestCase): class BuildTestSimple(TestCase):
@ -14,14 +16,14 @@ class BuildTestSimple(TestCase):
description='Simple description') description='Simple description')
Build.objects.create(part=part, Build.objects.create(part=part,
batch='B1', batch='B1',
status=Build.PENDING, status=BuildStatus.PENDING,
title='Building 7 parts', title='Building 7 parts',
quantity=7, quantity=7,
notes='Some simple notes') notes='Some simple notes')
Build.objects.create(part=part, Build.objects.create(part=part,
batch='B2', batch='B2',
status=Build.COMPLETE, status=BuildStatus.COMPLETE,
title='Building 21 parts', title='Building 21 parts',
quantity=21, quantity=21,
notes='Some simple notes') notes='Some simple notes')

View File

@ -15,6 +15,7 @@ from stock.models import StockLocation, StockItem
from InvenTree.views import AjaxUpdateView, AjaxCreateView, AjaxDeleteView from InvenTree.views import AjaxUpdateView, AjaxCreateView, AjaxDeleteView
from InvenTree.helpers import str2bool from InvenTree.helpers import str2bool
from InvenTree.status_codes import BuildStatus
class BuildIndex(ListView): class BuildIndex(ListView):
@ -32,10 +33,12 @@ class BuildIndex(ListView):
context = super(BuildIndex, self).get_context_data(**kwargs).copy() context = super(BuildIndex, self).get_context_data(**kwargs).copy()
context['active'] = self.get_queryset().filter(status__in=[Build.PENDING, ]) context['BuildStatus'] = BuildStatus
context['completed'] = self.get_queryset().filter(status=Build.COMPLETE) context['active'] = self.get_queryset().filter(status__in=BuildStatus.ACTIVE_CODES)
context['cancelled'] = self.get_queryset().filter(status=Build.CANCELLED)
context['completed'] = self.get_queryset().filter(status=BuildStatus.COMPLETE)
context['cancelled'] = self.get_queryset().filter(status=BuildStatus.CANCELLED)
return context return context

View File

@ -1,10 +1,10 @@
{% if build.status == build.PENDING %} {% if build.status == BuildStatus.PENDING %}
<span class='label label-large label-info'> <span class='label label-large label-info'>
{% elif build.status == build.ALLOCATED %} {% elif build.status == BuildStatus.ALLOCATED %}
<span class='label label-large label-primary'> <span class='label label-large label-primary'>
{% elif build.status == build.CANCELLED %} {% elif build.status == BuildStatus.CANCELLED %}
<span class='label label-large label-danger'> <span class='label label-large label-danger'>
{% elif build.status == build.COMPLETE %} {% elif build.status == BuildStatus.COMPLETE %}
<span class='label label-large label-success'> <span class='label label-large label-success'>
{% endif %} {% endif %}
{{ build.get_status_display }} {{ build.get_status_display }}