diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index ce47010cb1..ca3a620d37 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -4,14 +4,15 @@ from django.contrib import admin from rest_framework.documentation import include_docs_urls from part.urls import part_urls, part_cat_urls, part_param_urls, part_param_template_urls +from stock.urls import stock_urls, stock_loc_urls admin.site.site_header = "InvenTree Admin" apipatterns = [ # Stock URLs - url(r'^stock/', include('stock.urls')), - url(r'^stock-location/', include('stock.location_urls')), + url(r'^stock/', include(stock_urls)), + url(r'^stock-location/', include(stock_loc_urls)), # Part URLs url(r'^part/', include(part_urls)), diff --git a/InvenTree/stock/location_urls.py b/InvenTree/stock/location_urls.py deleted file mode 100644 index 9df7a53b28..0000000000 --- a/InvenTree/stock/location_urls.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.conf.urls import url -from . import views - -urlpatterns = [ - url(r'^(?P[0-9]+)/?$', views.LocationDetail.as_view(), name='stocklocation-detail'), - - url(r'^\?.*/?$', views.LocationList.as_view()), - - url(r'^$', views.LocationList.as_view()) -] diff --git a/InvenTree/stock/urls.py b/InvenTree/stock/urls.py index b2822682d5..bf58ddbb89 100644 --- a/InvenTree/stock/urls.py +++ b/InvenTree/stock/urls.py @@ -2,7 +2,7 @@ from django.conf.urls import url from . import views -urlpatterns = [ +stock_urls = [ # Detail for a single stock item url(r'^(?P[0-9]+)/?$', views.StockDetail.as_view(), name='stockitem-detail'), @@ -10,3 +10,11 @@ urlpatterns = [ url(r'^\?.*/?$', views.StockList.as_view()), url(r'^$', views.StockList.as_view()), ] + +stock_loc_urls = [ + url(r'^(?P[0-9]+)/?$', views.LocationDetail.as_view(), name='stocklocation-detail'), + + url(r'^\?.*/?$', views.LocationList.as_view()), + + url(r'^$', views.LocationList.as_view()) +] diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py index 27fa65bfbe..ad7742fd21 100644 --- a/InvenTree/stock/views.py +++ b/InvenTree/stock/views.py @@ -10,13 +10,24 @@ from .serializers import StockItemSerializer, LocationSerializer class StockDetail(generics.RetrieveUpdateDestroyAPIView): + """ + + get: + Return a single StockItem object + + post: + Update a StockItem + + delete: + Remove a StockItem + """ queryset = StockItem.objects.all() serializer_class = StockItemSerializer permission_classes = (permissions.IsAuthenticatedOrReadOnly,) -class StockFilter(django_filters.rest_framework.FilterSet): +class StockFilter(FilterSet): min_stock = NumberFilter(name='quantity', lookup_expr='gte') max_stock = NumberFilter(name='quantity', lookup_expr='lte') part = NumberFilter(name='part', lookup_expr='exact') @@ -28,6 +39,15 @@ class StockFilter(django_filters.rest_framework.FilterSet): class StockList(generics.ListCreateAPIView): + """ + + get: + Return a list of all StockItem objects + (with optional query filters) + + post: + Create a new StockItem + """ queryset = StockItem.objects.all() serializer_class = StockItemSerializer @@ -37,7 +57,17 @@ class StockList(generics.ListCreateAPIView): class LocationDetail(generics.RetrieveUpdateDestroyAPIView): - """ Return information on a specific stock location + """ + + get: + Return a single StockLocation object + + post: + Update a StockLocation object + + delete: + Remove a StockLocation object + """ queryset = StockLocation.objects.all() @@ -55,8 +85,15 @@ class StockLocationFilter(FilterSet): class LocationList(generics.ListCreateAPIView): - """ Return a list of top-level locations - Locations are considered "top-level" if they do not have a parent + """ + + get: + Return a list of all StockLocation objects + (with optional query filter) + + post: + Create a new StockLocation + """ queryset = StockLocation.objects.all()