PEP fixes for /part

This commit is contained in:
Oliver Walters 2019-04-14 09:25:46 +10:00
parent 76b0d17b11
commit cf374252c1
3 changed files with 7 additions and 8 deletions

View File

@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django_filters.rest_framework import DjangoFilterBackend
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
@ -17,6 +17,7 @@ from .serializers import CategorySerializer
from InvenTree.views import TreeSerializer
from InvenTree.serializers import DraftRUDView
class PartCategoryTree(TreeSerializer):
title = "Parts"
@ -33,7 +34,7 @@ class CategoryList(generics.ListCreateAPIView):
filter_backends = [
DjangoFilterBackend,
#filters.SearchFilter,
# filters.SearchFilter,
filters.OrderingFilter,
]
@ -61,6 +62,7 @@ class PartDetail(DraftRUDView):
permissions.IsAuthenticatedOrReadOnly,
]
class PartList(generics.ListCreateAPIView):
queryset = Part.objects.all()
@ -133,13 +135,12 @@ class SupplierPartList(generics.ListAPIView):
'supplier'
]
cat_api_urls = [
cat_api_urls = [
url(r'^$', CategoryList.as_view(), name='api-part-category-list'),
]
part_api_urls = [
url(r'^tree/?', PartCategoryTree.as_view(), name='api-part-tree'),
url(r'^category/', include(cat_api_urls)),

View File

@ -7,7 +7,6 @@ from django.utils.translation import gettext_lazy as _
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import Sum
from django.core.validators import MinValueValidator
from django.db.models.signals import pre_delete
@ -250,7 +249,6 @@ class Part(models.Model):
self.allocated_build_count,
])
@property
def stock_entries(self):
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])
@property
def has_bom(self):
return self.bom_count > 0

View File

@ -5,6 +5,7 @@ from .models import SupplierPart
from company.serializers import CompanyBriefSerializer
class CategorySerializer(serializers.ModelSerializer):
url = serializers.CharField(source='get_absolute_url', read_only=True)
@ -99,4 +100,4 @@ class SupplierPartSerializer(serializers.ModelSerializer):
'SKU',
'manufacturer',
'MPN',
]
]