Fixing python errors

This commit is contained in:
Oliver 2017-04-11 17:21:05 +10:00
parent 1cddec1035
commit 338dcd3b72
19 changed files with 28 additions and 25 deletions

View File

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

View File

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

View File

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

View File

@ -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())

View File

@ -1,3 +1,3 @@
from django.test import TestCase
# from django.test import TestCase
# Create your tests here.

View File

@ -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()

View File

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

View File

@ -1,3 +1,3 @@
from django.test import TestCase
# from django.test import TestCase
# Create your tests here.

View File

@ -1,4 +1,3 @@
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse

View File

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

View File

@ -1,3 +1,3 @@
from django.test import TestCase
# from django.test import TestCase
# Create your tests here.

View File

@ -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})

View File

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

View File

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

View File

@ -1,3 +1,3 @@
from django.test import TestCase
# from django.test import TestCase
# Create your tests here.

View File

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

View File

@ -1,3 +1,3 @@
from django.test import TestCase
# from django.test import TestCase
# Create your tests here.

View File

@ -1,4 +1,3 @@
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse

View File

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