mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
commit
f6b3dde1bb
@ -7,4 +7,4 @@ before_install:
|
||||
|
||||
script:
|
||||
# TODO - Only perform PEP8 checks on files that have been changed in this push / PR
|
||||
- find . -name \*.py -exec pep8 --ignore=E402,W293 {} +
|
||||
- find . -name \*.py -exec pep8 --ignore=E402,W293,E501 {} +
|
@ -4,6 +4,7 @@ from django.db import models
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
|
||||
class Company(models.Model):
|
||||
""" Abstract model representing an external company
|
||||
"""
|
||||
@ -26,6 +27,7 @@ class Company(models.Model):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class InvenTreeTree(models.Model):
|
||||
""" Provides an abstracted self-referencing tree model for data categories.
|
||||
- Each Category has one parent Category, which can be blank (for a top-level Category).
|
||||
@ -41,7 +43,6 @@ class InvenTreeTree(models.Model):
|
||||
on_delete=models.CASCADE,
|
||||
blank=True,
|
||||
null=True)
|
||||
#limit_choices_to={id: getAcceptableParents})
|
||||
|
||||
def getUniqueChildren(self, unique=None):
|
||||
""" Return a flat set of all child items that exist under this node.
|
||||
@ -120,7 +121,8 @@ class InvenTreeTree(models.Model):
|
||||
"""
|
||||
|
||||
if attrname == 'parent_id':
|
||||
# If current ID is None, continue (as this object is just being created)
|
||||
# If current ID is None, continue
|
||||
# - This object is just being created
|
||||
if self.id is None:
|
||||
pass
|
||||
# Parent cannot be set to same ID (this would cause looping)
|
||||
|
@ -2,15 +2,15 @@ from django.contrib import admin
|
||||
|
||||
from .models import PartCategory, Part
|
||||
|
||||
|
||||
class PartAdmin(admin.ModelAdmin):
|
||||
|
||||
list_display = ('name', 'IPN', 'stock', 'category')
|
||||
|
||||
# Custom form for PartCategory
|
||||
|
||||
class PartCategoryAdmin(admin.ModelAdmin):
|
||||
|
||||
list_display = ('name', 'path', 'description')
|
||||
|
||||
|
||||
admin.site.register(Part, PartAdmin)
|
||||
admin.site.register(PartCategory, PartCategoryAdmin)
|
@ -6,6 +6,7 @@ from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from InvenTree.models import InvenTreeTree
|
||||
|
||||
|
||||
class PartCategory(InvenTreeTree):
|
||||
""" PartCategory provides hierarchical organization of Part objects.
|
||||
"""
|
||||
@ -14,6 +15,7 @@ class PartCategory(InvenTreeTree):
|
||||
verbose_name = "Part Category"
|
||||
verbose_name_plural = "Part Categories"
|
||||
|
||||
|
||||
class Part(models.Model):
|
||||
""" Represents a """
|
||||
|
||||
@ -74,6 +76,7 @@ class Part(models.Model):
|
||||
|
||||
return projects
|
||||
|
||||
|
||||
class PartRevision(models.Model):
|
||||
""" A PartRevision represents a change-notification to a Part
|
||||
A Part may go through several revisions in its lifetime,
|
||||
|
@ -2,6 +2,7 @@ from rest_framework import serializers
|
||||
|
||||
from .models import Part, PartCategory
|
||||
|
||||
|
||||
class PartSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Part
|
||||
@ -11,6 +12,7 @@ class PartSerializer(serializers.ModelSerializer):
|
||||
'category',
|
||||
'stock')
|
||||
|
||||
|
||||
class PartCategorySerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = PartCategory
|
||||
|
@ -6,24 +6,29 @@ from rest_framework import generics
|
||||
from .models import PartCategory, Part
|
||||
from .serializers import PartSerializer, PartCategorySerializer
|
||||
|
||||
|
||||
def index(request):
|
||||
return HttpResponse("Hello world. This is the parts page")
|
||||
|
||||
|
||||
class PartDetail(generics.RetrieveAPIView):
|
||||
|
||||
queryset = Part.objects.all()
|
||||
serializer_class = PartSerializer
|
||||
|
||||
|
||||
class PartList(generics.ListAPIView):
|
||||
|
||||
queryset = Part.objects.all()
|
||||
serializer_class = PartSerializer
|
||||
|
||||
|
||||
class PartCategoryDetail(generics.RetrieveAPIView):
|
||||
|
||||
queryset = PartCategory.objects.all()
|
||||
serializer_class = PartCategorySerializer
|
||||
|
||||
|
||||
class PartCategoryList(generics.ListAPIView):
|
||||
|
||||
queryset = PartCategory.objects.all()
|
||||
|
@ -2,12 +2,15 @@ from django.contrib import admin
|
||||
|
||||
from .models import ProjectCategory, Project, ProjectPart
|
||||
|
||||
|
||||
class ProjectCategoryAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'path', 'description')
|
||||
|
||||
|
||||
class ProjectAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'description', 'category')
|
||||
|
||||
|
||||
class ProjectPartAdmin(admin.ModelAdmin):
|
||||
list_display = ('part', 'project', 'quantity')
|
||||
|
||||
|
@ -5,6 +5,7 @@ from django.db import models
|
||||
from InvenTree.models import InvenTreeTree
|
||||
from part.models import Part
|
||||
|
||||
|
||||
class ProjectCategory(InvenTreeTree):
|
||||
""" ProjectCategory provides hierarchical organization of Project objects.
|
||||
Each ProjectCategory can contain zero-or-more child categories,
|
||||
@ -15,6 +16,7 @@ class ProjectCategory(InvenTreeTree):
|
||||
verbose_name = "Project Category"
|
||||
verbose_name_plural = "Project Categories"
|
||||
|
||||
|
||||
class Project(models.Model):
|
||||
""" A Project takes multiple Part objects.
|
||||
A project can output zero-or-more Part objects
|
||||
@ -33,6 +35,7 @@ class Project(models.Model):
|
||||
"""
|
||||
return self.projectpart_set.all()
|
||||
|
||||
|
||||
class ProjectPart(models.Model):
|
||||
""" A project part associates a single part with a project
|
||||
The quantity of parts required for a single-run of that project is stored.
|
||||
|
@ -1,5 +1,6 @@
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.http import HttpResponse
|
||||
|
||||
|
||||
def index(request):
|
||||
return HttpResponse("This is the Projects page")
|
@ -2,9 +2,11 @@ from django.contrib import admin
|
||||
|
||||
from .models import Warehouse, StockItem
|
||||
|
||||
|
||||
class WarehouseAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'path', 'description')
|
||||
|
||||
|
||||
class StockItemAdmin(admin.ModelAdmin):
|
||||
list_display = ('part', 'quantity', 'location', 'status', 'updated')
|
||||
|
||||
|
@ -5,9 +5,11 @@ from django.db import models
|
||||
from part.models import Part
|
||||
from InvenTree.models import InvenTreeTree
|
||||
|
||||
|
||||
class Warehouse(InvenTreeTree):
|
||||
pass
|
||||
|
||||
|
||||
class StockItem(models.Model):
|
||||
part = models.ForeignKey(Part,
|
||||
on_delete=models.CASCADE)
|
||||
|
@ -3,10 +3,9 @@ from django.http import HttpResponse
|
||||
|
||||
from .models import Warehouse, StockItem
|
||||
|
||||
|
||||
def index(request):
|
||||
|
||||
warehouses = Warehouse.objects.filter(parent=None)
|
||||
|
||||
return render(request, 'stock/index.html',
|
||||
{'warehouses': warehouses
|
||||
})
|
||||
return render(request, 'stock/index.html', {'warehouses': warehouses})
|
||||
|
@ -2,6 +2,7 @@ from django.contrib import admin
|
||||
|
||||
from .models import Supplier, SupplierPart, Customer
|
||||
|
||||
|
||||
class CompanyAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'URL', 'contact')
|
||||
|
||||
|
@ -14,6 +14,8 @@ class Supplier(Company):
|
||||
|
||||
|
||||
class Customer(Company):
|
||||
""" Represents a customer
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@ -31,8 +33,7 @@ class SupplierPart(models.Model):
|
||||
|
||||
MPN = models.CharField(max_length=100)
|
||||
URL = models.URLField(blank=True)
|
||||
description = models.CharField(max_length=250,
|
||||
blank=True)
|
||||
description = models.CharField(max_length=250, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return "{mpn} - {supplier}".format(
|
||||
|
@ -3,9 +3,11 @@ from django.http import HttpResponse
|
||||
|
||||
from .models import Supplier
|
||||
|
||||
|
||||
def index(request):
|
||||
return HttpResponse("This is the suppliers page")
|
||||
|
||||
|
||||
def supplierDetail(request, supplier_id):
|
||||
supplier = get_object_or_404(Supplier, pk=supplier_id)
|
||||
|
||||
|
@ -2,6 +2,7 @@ from django.contrib import admin
|
||||
|
||||
from .models import UniquePart
|
||||
|
||||
|
||||
class UniquePartAdmin(admin.ModelAdmin):
|
||||
list_display = ('part', 'revision', 'serial', 'creation_date')
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.http import HttpResponse
|
||||
|
||||
|
||||
def index(request):
|
||||
return HttpResponse("This is the Tracking page")
|
Loading…
x
Reference in New Issue
Block a user