diff --git a/InvenTree/InvenTree/models.py b/InvenTree/InvenTree/models.py index 033a8b3a09..4eb8dd8daa 100644 --- a/InvenTree/InvenTree/models.py +++ b/InvenTree/InvenTree/models.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals from django.db import models -from django.core.exceptions import ObjectDoesNotExist from django.contrib.contenttypes.models import ContentType @@ -99,7 +98,7 @@ class InvenTreeTree(models.Model): available = contents.get_all_objects_for_this_type() # List of child IDs - childs = getUniqueChildren() + childs = self.getUniqueChildren() acceptable = [None] diff --git a/InvenTree/manage.py b/InvenTree/manage.py index cfaeab5f9e..dc8d382fac 100755 --- a/InvenTree/manage.py +++ b/InvenTree/manage.py @@ -11,7 +11,7 @@ if __name__ == "__main__": # issue is really that Django is missing to avoid masking other # exceptions on Python 2. try: - import django + import django # NOQA except ImportError: raise ImportError( "Couldn't import Django. Are you sure it's installed and " diff --git a/InvenTree/part/admin.py b/InvenTree/part/admin.py index f36f4f8931..dd5ec73763 100644 --- a/InvenTree/part/admin.py +++ b/InvenTree/part/admin.py @@ -4,14 +4,14 @@ from .models import PartCategory, Part, PartParameter, PartParameterTemplate, Ca class PartAdmin(admin.ModelAdmin): - + list_display = ('name', 'IPN', 'stock', 'category') class PartCategoryAdmin(admin.ModelAdmin): - + list_display = ('name', 'path', 'description') - + class ParameterTemplateAdmin(admin.ModelAdmin): list_display = ('name', 'units', 'format') @@ -20,7 +20,7 @@ class ParameterTemplateAdmin(admin.ModelAdmin): class ParameterAdmin(admin.ModelAdmin): list_display = ('part', 'template', 'value') - + admin.site.register(Part, PartAdmin) admin.site.register(PartCategory, PartCategoryAdmin) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 9ba26149ae..740bcd0cfd 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals from django.utils.translation import ugettext as _ from django.db import models from django.db.models import Sum -from django.core.exceptions import ObjectDoesNotExist, ValidationError from InvenTree.models import InvenTreeTree @@ -116,7 +115,7 @@ class PartParameterTemplate(models.Model): PARAM_BOOL: _("Bool") } - format = models.IntegerField( + format = models.PositiveIntegerField( default=PARAM_NUMERIC, choices=PARAM_TYPE_CODES.items()) diff --git a/InvenTree/part/tests.py b/InvenTree/part/tests.py index 7ce503c2dd..a79ca8be56 100644 --- a/InvenTree/part/tests.py +++ b/InvenTree/part/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +# from django.test import TestCase # Create your tests here. diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index 37b59486ca..cc60db27b7 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -1,6 +1,4 @@ -from django.shortcuts import render, get_object_or_404 -from django.http import HttpResponse, Http404 - +from django.http import HttpResponse from rest_framework import generics from .models import PartCategory, Part @@ -11,9 +9,11 @@ from .serializers import PartCategoryBriefSerializer, PartCategoryDetailSerializ def part_index(request): return HttpResponse("Hello world. This is the parts page") + def category_index(request): return HttpResponse("This is the category page") + class PartDetail(generics.RetrieveAPIView): queryset = Part.objects.all() diff --git a/InvenTree/project/admin.py b/InvenTree/project/admin.py index 0f1ad27b11..2d8b43b0d9 100644 --- a/InvenTree/project/admin.py +++ b/InvenTree/project/admin.py @@ -18,6 +18,7 @@ class ProjectPartAdmin(admin.ModelAdmin): class ProjectRunAdmin(admin.ModelAdmin): list_display = ('project', 'quantity', 'run_date') + admin.site.register(ProjectCategory, ProjectCategoryAdmin) admin.site.register(Project, ProjectAdmin) admin.site.register(ProjectPart, ProjectPartAdmin) diff --git a/InvenTree/project/tests.py b/InvenTree/project/tests.py index 7ce503c2dd..a79ca8be56 100644 --- a/InvenTree/project/tests.py +++ b/InvenTree/project/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +# from django.test import TestCase # Create your tests here. diff --git a/InvenTree/project/views.py b/InvenTree/project/views.py index a9b40c0cc5..adbd6ac6ef 100644 --- a/InvenTree/project/views.py +++ b/InvenTree/project/views.py @@ -1,4 +1,3 @@ -from django.shortcuts import render, get_object_or_404 from django.http import HttpResponse diff --git a/InvenTree/stock/admin.py b/InvenTree/stock/admin.py index 94de179851..7bfd55fe3c 100644 --- a/InvenTree/stock/admin.py +++ b/InvenTree/stock/admin.py @@ -10,5 +10,6 @@ class WarehouseAdmin(admin.ModelAdmin): class StockItemAdmin(admin.ModelAdmin): list_display = ('part', 'quantity', 'location', 'status', 'updated') + admin.site.register(Warehouse, WarehouseAdmin) admin.site.register(StockItem, StockItemAdmin) diff --git a/InvenTree/stock/tests.py b/InvenTree/stock/tests.py index 7ce503c2dd..a79ca8be56 100644 --- a/InvenTree/stock/tests.py +++ b/InvenTree/stock/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +# from django.test import TestCase # Create your tests here. diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index 394fe97ad0..3fbebb9bd0 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -1,11 +1,10 @@ -from django.shortcuts import render, get_object_or_404 -from django.http import HttpResponse +from django.shortcuts import render -from .models import Warehouse, StockItem +from .models import Warehouse def index(request): - + warehouses = Warehouse.objects.filter(parent=None) - + return render(request, 'stock/index.html', {'warehouses': warehouses}) diff --git a/InvenTree/supplier/admin.py b/InvenTree/supplier/admin.py index 9e9d53dfa4..cf19edd2b0 100644 --- a/InvenTree/supplier/admin.py +++ b/InvenTree/supplier/admin.py @@ -6,6 +6,7 @@ from .models import Supplier, SupplierPart, Customer, Manufacturer class CompanyAdmin(admin.ModelAdmin): list_display = ('name', 'URL', 'contact') + admin.site.register(Customer, CompanyAdmin) admin.site.register(Supplier, CompanyAdmin) admin.site.register(Manufacturer, CompanyAdmin) diff --git a/InvenTree/supplier/models.py b/InvenTree/supplier/models.py index bbd0f2df3f..bd5d20dc86 100644 --- a/InvenTree/supplier/models.py +++ b/InvenTree/supplier/models.py @@ -77,7 +77,7 @@ class SupplierPriceBreak(models.Model): def __str__(self): return "{mpn} - {cost}{currency} @ {quan}".format( - mpn=part.MPN, + mpn=self.part.MPN, cost=self.cost, currency=self.currency if self.currency else '', quan=self.quantity) diff --git a/InvenTree/supplier/tests.py b/InvenTree/supplier/tests.py index 7ce503c2dd..a79ca8be56 100644 --- a/InvenTree/supplier/tests.py +++ b/InvenTree/supplier/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +# from django.test import TestCase # Create your tests here. diff --git a/InvenTree/track/admin.py b/InvenTree/track/admin.py index 17a3aa6cb2..573e458878 100644 --- a/InvenTree/track/admin.py +++ b/InvenTree/track/admin.py @@ -6,4 +6,5 @@ from .models import UniquePart class UniquePartAdmin(admin.ModelAdmin): list_display = ('part', 'revision', 'serial', 'status', 'creation_date') + admin.site.register(UniquePart, UniquePartAdmin) diff --git a/InvenTree/track/tests.py b/InvenTree/track/tests.py index 7ce503c2dd..a79ca8be56 100644 --- a/InvenTree/track/tests.py +++ b/InvenTree/track/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +# from django.test import TestCase # Create your tests here. diff --git a/InvenTree/track/views.py b/InvenTree/track/views.py index 5986b94af1..0a26c7bf12 100644 --- a/InvenTree/track/views.py +++ b/InvenTree/track/views.py @@ -1,4 +1,3 @@ -from django.shortcuts import render, get_object_or_404 from django.http import HttpResponse diff --git a/Makefile b/Makefile index 307922603a..18b1a97499 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,10 @@ test: setup: # TODO: replace this with a proper setup.py pip install -U -r requirements/base.txt + migrate + +migrate: + python InvenTree/manage.py makemigrations python InvenTree/manage.py migrate --run-syncdb python InvenTree/manage.py check