From 9dc41ba1228a91052f3bf35a0b17b4e36c20c954 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 17 Apr 2018 16:58:37 +1000 Subject: [PATCH] Fix requirements >= rather than == --- .../migrations/0004_auto_20180417_0657.py | 48 +++++++++++++++++++ InvenTree/build/models.py | 42 ++++++++++------ InvenTree/stock/models.py | 3 ++ requirements/base.txt | 18 +++---- 4 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 InvenTree/build/migrations/0004_auto_20180417_0657.py diff --git a/InvenTree/build/migrations/0004_auto_20180417_0657.py b/InvenTree/build/migrations/0004_auto_20180417_0657.py new file mode 100644 index 0000000000..23211a8d7c --- /dev/null +++ b/InvenTree/build/migrations/0004_auto_20180417_0657.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.12 on 2018-04-17 06:57 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0019_auto_20180416_1249'), + ('build', '0003_build_part'), + ] + + operations = [ + migrations.CreateModel( + name='BuildOutput', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('quantity', models.PositiveIntegerField(default=1, help_text='Number of parts to build', validators=[django.core.validators.MinValueValidator(1)])), + ], + ), + migrations.RemoveField( + model_name='build', + name='part', + ), + migrations.RemoveField( + model_name='build', + name='quantity', + ), + migrations.AlterField( + model_name='build', + name='status', + field=models.PositiveIntegerField(choices=[(40, 'Cancelled'), (10, 'Pending'), (20, 'Allocated'), (50, 'Complete'), (30, 'Holding')], default=10, validators=[django.core.validators.MinValueValidator(0)]), + ), + migrations.AddField( + model_name='buildoutput', + name='build', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='outputs', to='build.Build'), + ), + migrations.AddField( + model_name='buildoutput', + name='part', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='builds', to='part.Part'), + ), + ] diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index a55abb15fc..960fce3edf 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from django.utils.translation import ugettext as _ + from django.db import models from django.core.validators import MinValueValidator -from InvenTree.helpers import ChoiceEnum - from part.models import Part class Build(models.Model): @@ -14,22 +14,34 @@ class Build(models.Model): Parts are then taken from stock """ - class BUILD_STATUS(ChoiceEnum): - # The build is 'pending' - no action taken yet - Pending = 10 + # Build status codes + PENDING = 10 + ALLOCATED = 20 + HOLDING = 30 + CANCELLED = 40 + COMPLETE = 50 - # The parts required for this build have been allocated - Allocated = 20 - - # The build has been cancelled (parts unallocated) - Cancelled = 30 - - # The build is complete! - Complete = 40 + BUILD_STATUS_CODES = { + PENDING : _("Pending"), + ALLOCATED : _("Allocated"), + HOLDING : _("Holding"), + CANCELLED : _("Cancelled"), + COMPLETE : _("Complete"), + } # Status of the build - status = models.PositiveIntegerField(default=BUILD_STATUS.Pending.value, - choices=BUILD_STATUS.choices()) + status = models.PositiveIntegerField(default=PENDING, + choices=BUILD_STATUS_CODES.items(), + validators=[MinValueValidator(0)]) + + +class BuildOutput(models.Model): + """ + A build output represents a single build part/quantity combination + """ + + build = models.ForeignKey(Build, on_delete=models.CASCADE, + related_name='outputs') part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='builds') diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 358d11e1d8..c3a5514730 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -1,5 +1,8 @@ +# -*- coding: utf-8 -*- from __future__ import unicode_literals + from django.utils.translation import ugettext as _ + from django.db import models, transaction from django.core.validators import MinValueValidator from django.contrib.auth.models import User diff --git a/requirements/base.txt b/requirements/base.txt index b39b8ebd07..9c9b4ed8b5 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,9 +1,9 @@ -Django==1.11 -pillow==3.1.2 -djangorestframework==3.6.2 -django_filter==1.0.2 -django-simple-history==1.8.2 -coreapi==2.3.0 -pygments==2.2.0 -django-crispy-forms==1.7.2 -django-import-export==1.0.0 \ No newline at end of file +Django>=1.11 +pillow>=5.0.0 +djangorestframework>=3.6.2 +django_filter>=1.0.2 +django-simple-history>=1.8.2 +coreapi>=2.3.0 +pygments>=2.2.0 +django-crispy-forms>=1.7.2 +django-import-export>=1.0.0 \ No newline at end of file