mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-09 15:10:54 +00:00
Style fixes
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
from django.conf.urls import url, include
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.conf.urls import url, include
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
|
10
InvenTree/supplier/part_urls.py
Normal file
10
InvenTree/supplier/part_urls.py
Normal file
@ -0,0 +1,10 @@
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPartDetail.as_view(), name='supplierpart-detail'),
|
||||
|
||||
url(r'^\?.*/?$', views.SupplierPartList.as_view()),
|
||||
url(r'^$', views.SupplierPartList.as_view())
|
||||
]
|
10
InvenTree/supplier/price_urls.py
Normal file
10
InvenTree/supplier/price_urls.py
Normal file
@ -0,0 +1,10 @@
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPriceBreakDetail.as_view(), name='supplierpricebreak-detail'),
|
||||
|
||||
url(r'^\?.*/?$', views.SupplierPriceBreakList.as_view()),
|
||||
url(r'^$', views.SupplierPriceBreakList.as_view())
|
||||
]
|
@ -35,13 +35,13 @@ class SupplierPartSerializer(serializers.ModelSerializer):
|
||||
view_name='supplierpricebreak-detail')
|
||||
|
||||
part = serializers.HyperlinkedRelatedField(view_name='part-detail',
|
||||
queryset = Part.objects.all())
|
||||
queryset=Part.objects.all())
|
||||
|
||||
supplier = serializers.HyperlinkedRelatedField(view_name='supplier-detail',
|
||||
queryset = Supplier.objects.all())
|
||||
queryset=Supplier.objects.all())
|
||||
|
||||
manufacturer = serializers.HyperlinkedRelatedField(view_name='manufacturer-detail',
|
||||
queryset = Manufacturer.objects.all())
|
||||
queryset=Manufacturer.objects.all())
|
||||
|
||||
class Meta:
|
||||
model = SupplierPart
|
||||
|
@ -1,14 +1,7 @@
|
||||
from django.conf.urls import url, include
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
partpatterns = [
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPartDetail.as_view(), name='supplierpart-detail'),
|
||||
|
||||
url(r'^\?.*/?$', views.SupplierPartList.as_view()),
|
||||
url(r'^$', views.SupplierPartList.as_view())
|
||||
]
|
||||
|
||||
pricepatterns = [
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPriceBreakDetail.as_view(), name='supplierpricebreak-detail'),
|
||||
|
||||
@ -18,12 +11,6 @@ pricepatterns = [
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
# Supplier part information
|
||||
url(r'part/', include(partpatterns)),
|
||||
|
||||
# Supplier price information
|
||||
url(r'price/', include(pricepatterns)),
|
||||
|
||||
# Display details of a supplier
|
||||
url(r'^(?P<pk>[0-9]+)/$', views.SupplierDetail.as_view(), name='supplier-detail'),
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
from django_filters.rest_framework import FilterSet, DjangoFilterBackend
|
||||
from django_filters import NumberFilter
|
||||
|
||||
from rest_framework import generics, permissions
|
||||
|
||||
from .models import Supplier, SupplierPart, SupplierPriceBreak
|
||||
@ -58,28 +61,27 @@ class SupplierPartDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
||||
|
||||
|
||||
class SupplierPartFilter(FilterSet):
|
||||
|
||||
supplier = NumberFilter(name='supplier', lookup_expr='exact')
|
||||
|
||||
part = NumberFilter(name='part', lookup_expr='exact')
|
||||
|
||||
manufacturer = NumberFilter(name='manufacturer', lookup_expr='exact')
|
||||
|
||||
class Meta:
|
||||
model = SupplierPart
|
||||
fields = ['supplier', 'part', 'manufacturer']
|
||||
|
||||
|
||||
class SupplierPartList(generics.ListCreateAPIView):
|
||||
|
||||
queryset = SupplierPart.objects.all()
|
||||
serializer_class = SupplierPartSerializer
|
||||
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
||||
|
||||
def get_queryset(self):
|
||||
parts = SupplierPart.objects.all()
|
||||
params = self.request.query_params
|
||||
|
||||
supplier_id = params.get('supplier', None)
|
||||
if supplier_id:
|
||||
parts = parts.filter(supplier=supplier_id)
|
||||
|
||||
part_id = params.get('part', None)
|
||||
if part_id:
|
||||
parts = parts.filter(part=part_id)
|
||||
|
||||
manu_id = params.get('manufacturer', None)
|
||||
if manu_id:
|
||||
parts = parts.filter(manufacturer=manu_id)
|
||||
|
||||
return parts
|
||||
filter_backends = (DjangoFilterBackend,)
|
||||
filter_class = SupplierPartFilter
|
||||
|
||||
|
||||
class SupplierPriceBreakDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
@ -89,17 +91,20 @@ class SupplierPriceBreakDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
||||
|
||||
|
||||
class PriceBreakFilter(FilterSet):
|
||||
|
||||
part = NumberFilter(name='part', lookup_expr='exact')
|
||||
|
||||
class Meta:
|
||||
model = SupplierPriceBreak
|
||||
fields = ['part']
|
||||
|
||||
|
||||
class SupplierPriceBreakList(generics.ListCreateAPIView):
|
||||
|
||||
def get_queryset(self):
|
||||
prices = SupplierPriceBreak.objects.all()
|
||||
params = self.request.query_params
|
||||
|
||||
part_id = params.get('part', None)
|
||||
if part_id:
|
||||
prices = prices.filter(part=part_id)
|
||||
|
||||
return prices
|
||||
|
||||
queryset = SupplierPriceBreak.objects.all()
|
||||
serializer_class = SupplierPriceBreakSerializer
|
||||
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
||||
|
||||
filter_backends = (DjangoFilterBackend,)
|
||||
filter_class = PriceBreakFilter
|
||||
|
Reference in New Issue
Block a user