PEP fixes

This commit is contained in:
Oliver Walters 2019-05-18 20:24:09 +10:00
parent a3d1591929
commit cdc55bb5d3
8 changed files with 87 additions and 89 deletions

View File

@ -20,4 +20,4 @@ class SupplierPriceBreakAdmin(ImportExportModelAdmin):
admin.site.register(Company, CompanyAdmin)
admin.site.register(SupplierPart, SupplierPartAdmin)
admin.site.register(SupplierPriceBreak, SupplierPriceBreakAdmin)
admin.site.register(SupplierPriceBreak, SupplierPriceBreakAdmin)

View File

@ -9,7 +9,7 @@ from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import filters
from rest_framework import generics, permissions
from django.conf.urls import url
from django.conf.urls import url, include
from .models import Company
from .models import SupplierPart, SupplierPriceBreak
@ -68,7 +68,85 @@ class CompanyDetail(generics.RetrieveUpdateDestroyAPIView):
]
class SupplierPartList(generics.ListCreateAPIView):
""" API endpoint for list view of SupplierPart object
- GET: Return list of SupplierPart objects
- POST: Create a new SupplierPart object
"""
queryset = SupplierPart.objects.all()
serializer_class = SupplierPartSerializer
permission_classes = [
permissions.IsAuthenticatedOrReadOnly,
]
filter_backends = [
DjangoFilterBackend,
filters.SearchFilter,
filters.OrderingFilter,
]
filter_fields = [
'part',
'supplier'
]
class SupplierPartDetail(generics.RetrieveUpdateDestroyAPIView):
""" API endpoint for detail view of SupplierPart object
- GET: Retrieve detail view
- PATCH: Update object
- DELETE: Delete objec
"""
queryset = SupplierPart.objects.all()
serializer_class = SupplierPartSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
read_only_fields = [
]
class SupplierPriceBreakList(generics.ListCreateAPIView):
""" API endpoint for list view of SupplierPriceBreak object
- GET: Retrieve list of SupplierPriceBreak objects
- POST: Create a new SupplierPriceBreak object
"""
queryset = SupplierPriceBreak.objects.all()
serializer_class = SupplierPriceBreakSerializer
permission_classes = [
permissions.IsAuthenticatedOrReadOnly,
]
filter_backends = [
DjangoFilterBackend,
]
filter_fields = [
'part',
]
supplier_part_api_urls = [
url(r'^(?P<pk>\d+)/?', SupplierPartDetail.as_view(), name='api-supplier-part-detail'),
# Catch anything else
url(r'^.*$', SupplierPartList.as_view(), name='api-part-supplier-list'),
]
company_api_urls = [
url(r'^part/', include(supplier_part_api_urls)),
url(r'^price-break/?', SupplierPriceBreakList.as_view(), name='api-part-supplier-price'),
url(r'^(?P<pk>\d+)/?', CompanyDetail.as_view(), name='api-company-detail'),

View File

@ -55,4 +55,4 @@ supplier_part_urls = [
url(r'^new/?', views.SupplierPartCreate.as_view(), name='supplier-part-create'),
url(r'^(?P<pk>\d+)/', include(supplier_part_detail_urls)),
]
]

View File

@ -16,6 +16,8 @@ from .models import Company
from .models import SupplierPart
from .models import SupplierPriceBreak
from part.models import Part
from .forms import EditCompanyForm
from .forms import CompanyImageForm
from .forms import EditSupplierPartForm

View File

@ -44,4 +44,3 @@ admin.site.register(PartCategory, PartCategoryAdmin)
admin.site.register(PartAttachment, PartAttachmentAdmin)
admin.site.register(PartStar, PartStarAdmin)
admin.site.register(BomItem, BomItemAdmin)

View File

@ -15,10 +15,6 @@ from rest_framework import generics, permissions
from django.conf.urls import url, include
from django.urls import reverse
from company.models import SupplierPart, SupplierPriceBreak
from company.serializers import SupplierPartSerializer, SupplierPriceBreakSerializer
from .models import Part, PartCategory, BomItem, PartStar
from .serializers import PartSerializer, BomItemSerializer
@ -235,71 +231,6 @@ class BomDetail(generics.RetrieveUpdateDestroyAPIView):
]
class SupplierPartList(generics.ListCreateAPIView):
""" API endpoint for list view of SupplierPart object
- GET: Return list of SupplierPart objects
- POST: Create a new SupplierPart object
"""
queryset = SupplierPart.objects.all()
serializer_class = SupplierPartSerializer
permission_classes = [
permissions.IsAuthenticatedOrReadOnly,
]
filter_backends = [
DjangoFilterBackend,
filters.SearchFilter,
filters.OrderingFilter,
]
filter_fields = [
'part',
'supplier'
]
class SupplierPartDetail(generics.RetrieveUpdateDestroyAPIView):
""" API endpoint for detail view of SupplierPart object
- GET: Retrieve detail view
- PATCH: Update object
- DELETE: Delete objec
"""
queryset = SupplierPart.objects.all()
serializer_class = SupplierPartSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
read_only_fields = [
]
class SupplierPriceBreakList(generics.ListCreateAPIView):
""" API endpoint for list view of SupplierPriceBreak object
- GET: Retrieve list of SupplierPriceBreak objects
- POST: Create a new SupplierPriceBreak object
"""
queryset = SupplierPriceBreak.objects.all()
serializer_class = SupplierPriceBreakSerializer
permission_classes = [
permissions.IsAuthenticatedOrReadOnly,
]
filter_backends = [
DjangoFilterBackend,
]
filter_fields = [
'part',
]
cat_api_urls = [
url(r'^(?P<pk>\d+)/?', CategoryDetail.as_view(), name='api-part-category-detail'),
@ -307,13 +238,6 @@ cat_api_urls = [
url(r'^$', CategoryList.as_view(), name='api-part-category-list'),
]
supplier_part_api_urls = [
url(r'^(?P<pk>\d+)/?', SupplierPartDetail.as_view(), name='api-supplier-part-detail'),
# Catch anything else
url(r'^.*$', SupplierPartList.as_view(), name='api-part-supplier-list'),
]
part_star_api_urls = [
url(r'^(?P<pk>\d+)/?', PartStarDetail.as_view(), name='api-part-star-detail'),
@ -322,21 +246,19 @@ part_star_api_urls = [
url(r'^.*$', PartStarList.as_view(), name='api-part-star-list'),
]
part_api_urls = [
url(r'^tree/?', PartCategoryTree.as_view(), name='api-part-tree'),
url(r'^category/', include(cat_api_urls)),
url(r'^supplier/', include(supplier_part_api_urls)),
url(r'^star/', include(part_star_api_urls)),
url(r'^price-break/?', SupplierPriceBreakList.as_view(), name='api-part-supplier-price'),
url(r'^(?P<pk>\d+)/', PartDetail.as_view(), name='api-part-detail'),
url(r'^.*$', PartList.as_view(), name='api-part-list'),
]
bom_api_urls = [
# BOM Item Detail
url('^(?P<pk>\d+)/', BomDetail.as_view(), name='api-bom-detail'),

View File

@ -7,8 +7,6 @@ from __future__ import unicode_literals
import os
import math
import tablib
from django.utils.translation import gettext_lazy as _
@ -617,7 +615,6 @@ class Part(models.Model):
return max_price
def deepCopy(self, other, **kwargs):
""" Duplicates non-field data from another part.
Does not alter the normal fields of this part,
@ -855,4 +852,3 @@ class BomItem(models.Model):
base_quantity = self.quantity * build_quantity
return base_quantity + self.get_overage_quantity(base_quantity)

View File

@ -12,11 +12,12 @@ from django.views.generic import DetailView, ListView
from django.forms.models import model_to_dict
from django.forms import HiddenInput, CheckboxInput
from company.models import Company
from .models import PartCategory, Part, PartAttachment
from .models import BomItem
from .models import match_part_names
from company.models import SupplierPart
from . import forms as part_forms
from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDeleteView