mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
peppa pig
This commit is contained in:
parent
14f60e1292
commit
b5dc22f33a
@ -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)
|
@ -11,7 +11,6 @@ class PartCategory(InvenTreeTree):
|
||||
""" PartCategory provides hierarchical organization of Part objects.
|
||||
"""
|
||||
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Part Category"
|
||||
verbose_name_plural = "Part Categories"
|
||||
@ -28,21 +27,18 @@ class Part(models.Model):
|
||||
units = models.CharField(max_length=20, default="pcs", blank=True)
|
||||
trackable = models.BooleanField(default=False)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
if self.IPN:
|
||||
return "{name} ({ipn})".format(
|
||||
ipn = self.IPN,
|
||||
name = self.name)
|
||||
ipn=self.IPN,
|
||||
name=self.name)
|
||||
else:
|
||||
return self.name
|
||||
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Part"
|
||||
verbose_name_plural = "Parts"
|
||||
|
||||
|
||||
@property
|
||||
def stock_list(self):
|
||||
""" Return a list of all stock objects associated with this part
|
||||
@ -50,7 +46,6 @@ class Part(models.Model):
|
||||
|
||||
return self.stockitem_set.all()
|
||||
|
||||
|
||||
@property
|
||||
def stock(self):
|
||||
""" Return the total stock quantity for this part.
|
||||
@ -64,7 +59,6 @@ class Part(models.Model):
|
||||
result = stocks.aggregate(total=Sum('quantity'))
|
||||
return result['total']
|
||||
|
||||
|
||||
@property
|
||||
def projects(self):
|
||||
""" Return a list of unique projects that this part is associated with
|
||||
@ -96,6 +90,5 @@ class PartRevision(models.Model):
|
||||
description = models.CharField(max_length=500)
|
||||
revision_date = models.DateField(auto_now_add = True)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
@ -9,21 +9,25 @@ 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()
|
||||
|
Loading…
Reference in New Issue
Block a user