mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
PEP fixes
This commit is contained in:
parent
a3d1591929
commit
cdc55bb5d3
@ -9,7 +9,7 @@ from django_filters.rest_framework import DjangoFilterBackend
|
|||||||
from rest_framework import filters
|
from rest_framework import filters
|
||||||
from rest_framework import generics, permissions
|
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 Company
|
||||||
from .models import SupplierPart, SupplierPriceBreak
|
from .models import SupplierPart, SupplierPriceBreak
|
||||||
@ -68,8 +68,86 @@ 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 = [
|
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'),
|
url(r'^(?P<pk>\d+)/?', CompanyDetail.as_view(), name='api-company-detail'),
|
||||||
|
|
||||||
url(r'^.*$', CompanyList.as_view(), name='api-company-list'),
|
url(r'^.*$', CompanyList.as_view(), name='api-company-list'),
|
||||||
|
@ -16,6 +16,8 @@ from .models import Company
|
|||||||
from .models import SupplierPart
|
from .models import SupplierPart
|
||||||
from .models import SupplierPriceBreak
|
from .models import SupplierPriceBreak
|
||||||
|
|
||||||
|
from part.models import Part
|
||||||
|
|
||||||
from .forms import EditCompanyForm
|
from .forms import EditCompanyForm
|
||||||
from .forms import CompanyImageForm
|
from .forms import CompanyImageForm
|
||||||
from .forms import EditSupplierPartForm
|
from .forms import EditSupplierPartForm
|
||||||
|
@ -44,4 +44,3 @@ admin.site.register(PartCategory, PartCategoryAdmin)
|
|||||||
admin.site.register(PartAttachment, PartAttachmentAdmin)
|
admin.site.register(PartAttachment, PartAttachmentAdmin)
|
||||||
admin.site.register(PartStar, PartStarAdmin)
|
admin.site.register(PartStar, PartStarAdmin)
|
||||||
admin.site.register(BomItem, BomItemAdmin)
|
admin.site.register(BomItem, BomItemAdmin)
|
||||||
|
|
||||||
|
@ -15,10 +15,6 @@ from rest_framework import generics, permissions
|
|||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
from django.urls import reverse
|
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 .models import Part, PartCategory, BomItem, PartStar
|
||||||
|
|
||||||
from .serializers import PartSerializer, BomItemSerializer
|
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 = [
|
cat_api_urls = [
|
||||||
|
|
||||||
url(r'^(?P<pk>\d+)/?', CategoryDetail.as_view(), name='api-part-category-detail'),
|
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'),
|
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 = [
|
part_star_api_urls = [
|
||||||
url(r'^(?P<pk>\d+)/?', PartStarDetail.as_view(), name='api-part-star-detail'),
|
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'),
|
url(r'^.*$', PartStarList.as_view(), name='api-part-star-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)),
|
||||||
url(r'^supplier/', include(supplier_part_api_urls)),
|
|
||||||
|
|
||||||
url(r'^star/', include(part_star_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'^(?P<pk>\d+)/', PartDetail.as_view(), name='api-part-detail'),
|
||||||
|
|
||||||
url(r'^.*$', PartList.as_view(), name='api-part-list'),
|
url(r'^.*$', PartList.as_view(), name='api-part-list'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
bom_api_urls = [
|
bom_api_urls = [
|
||||||
# BOM Item Detail
|
# BOM Item Detail
|
||||||
url('^(?P<pk>\d+)/', BomDetail.as_view(), name='api-bom-detail'),
|
url('^(?P<pk>\d+)/', BomDetail.as_view(), name='api-bom-detail'),
|
||||||
|
@ -7,8 +7,6 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import math
|
|
||||||
|
|
||||||
import tablib
|
import tablib
|
||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
@ -617,7 +615,6 @@ class Part(models.Model):
|
|||||||
|
|
||||||
return max_price
|
return max_price
|
||||||
|
|
||||||
|
|
||||||
def deepCopy(self, other, **kwargs):
|
def deepCopy(self, other, **kwargs):
|
||||||
""" Duplicates non-field data from another part.
|
""" Duplicates non-field data from another part.
|
||||||
Does not alter the normal fields of this part,
|
Does not alter the normal fields of this part,
|
||||||
@ -855,4 +852,3 @@ class BomItem(models.Model):
|
|||||||
base_quantity = self.quantity * build_quantity
|
base_quantity = self.quantity * build_quantity
|
||||||
|
|
||||||
return base_quantity + self.get_overage_quantity(base_quantity)
|
return base_quantity + self.get_overage_quantity(base_quantity)
|
||||||
|
|
||||||
|
@ -12,11 +12,12 @@ from django.views.generic import DetailView, ListView
|
|||||||
from django.forms.models import model_to_dict
|
from django.forms.models import model_to_dict
|
||||||
from django.forms import HiddenInput, CheckboxInput
|
from django.forms import HiddenInput, CheckboxInput
|
||||||
|
|
||||||
from company.models import Company
|
|
||||||
from .models import PartCategory, Part, PartAttachment
|
from .models import PartCategory, Part, PartAttachment
|
||||||
from .models import BomItem
|
from .models import BomItem
|
||||||
from .models import match_part_names
|
from .models import match_part_names
|
||||||
|
|
||||||
|
from company.models import SupplierPart
|
||||||
|
|
||||||
from . import forms as part_forms
|
from . import forms as part_forms
|
||||||
|
|
||||||
from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDeleteView
|
from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDeleteView
|
||||||
|
Loading…
Reference in New Issue
Block a user