mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
PEP fixes for /part
This commit is contained in:
parent
76b0d17b11
commit
cf374252c1
@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from django_filters.rest_framework import DjangoFilterBackend
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
from rest_framework import filters
|
from rest_framework import filters
|
||||||
from rest_framework import generics, permissions, mixins
|
from rest_framework import generics, permissions
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
|
||||||
@ -17,6 +17,7 @@ from .serializers import CategorySerializer
|
|||||||
from InvenTree.views import TreeSerializer
|
from InvenTree.views import TreeSerializer
|
||||||
from InvenTree.serializers import DraftRUDView
|
from InvenTree.serializers import DraftRUDView
|
||||||
|
|
||||||
|
|
||||||
class PartCategoryTree(TreeSerializer):
|
class PartCategoryTree(TreeSerializer):
|
||||||
|
|
||||||
title = "Parts"
|
title = "Parts"
|
||||||
@ -33,7 +34,7 @@ class CategoryList(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
filter_backends = [
|
filter_backends = [
|
||||||
DjangoFilterBackend,
|
DjangoFilterBackend,
|
||||||
#filters.SearchFilter,
|
# filters.SearchFilter,
|
||||||
filters.OrderingFilter,
|
filters.OrderingFilter,
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ class PartDetail(DraftRUDView):
|
|||||||
permissions.IsAuthenticatedOrReadOnly,
|
permissions.IsAuthenticatedOrReadOnly,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class PartList(generics.ListCreateAPIView):
|
class PartList(generics.ListCreateAPIView):
|
||||||
|
|
||||||
queryset = Part.objects.all()
|
queryset = Part.objects.all()
|
||||||
@ -133,13 +135,12 @@ class SupplierPartList(generics.ListAPIView):
|
|||||||
'supplier'
|
'supplier'
|
||||||
]
|
]
|
||||||
|
|
||||||
cat_api_urls = [
|
|
||||||
|
|
||||||
|
cat_api_urls = [
|
||||||
url(r'^$', CategoryList.as_view(), name='api-part-category-list'),
|
url(r'^$', CategoryList.as_view(), name='api-part-category-list'),
|
||||||
]
|
]
|
||||||
|
|
||||||
part_api_urls = [
|
part_api_urls = [
|
||||||
|
|
||||||
url(r'^tree/?', PartCategoryTree.as_view(), name='api-part-tree'),
|
url(r'^tree/?', PartCategoryTree.as_view(), name='api-part-tree'),
|
||||||
|
|
||||||
url(r'^category/', include(cat_api_urls)),
|
url(r'^category/', include(cat_api_urls)),
|
||||||
|
@ -7,7 +7,6 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Sum
|
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
|
|
||||||
from django.db.models.signals import pre_delete
|
from django.db.models.signals import pre_delete
|
||||||
@ -250,7 +249,6 @@ class Part(models.Model):
|
|||||||
self.allocated_build_count,
|
self.allocated_build_count,
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stock_entries(self):
|
def stock_entries(self):
|
||||||
return [loc for loc in self.locations.all() if loc.in_stock]
|
return [loc for loc in self.locations.all() if loc.in_stock]
|
||||||
@ -263,7 +261,6 @@ class Part(models.Model):
|
|||||||
|
|
||||||
return sum([loc.quantity for loc in self.stock_entries])
|
return sum([loc.quantity for loc in self.stock_entries])
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_bom(self):
|
def has_bom(self):
|
||||||
return self.bom_count > 0
|
return self.bom_count > 0
|
||||||
|
@ -5,6 +5,7 @@ from .models import SupplierPart
|
|||||||
|
|
||||||
from company.serializers import CompanyBriefSerializer
|
from company.serializers import CompanyBriefSerializer
|
||||||
|
|
||||||
|
|
||||||
class CategorySerializer(serializers.ModelSerializer):
|
class CategorySerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user