Tweaking URL patterns

This commit is contained in:
Oliver Walters 2017-04-14 21:44:01 +10:00
parent 146ad5e9ae
commit 858a7fe089
7 changed files with 52 additions and 60 deletions

View File

@ -17,13 +17,13 @@ def Inventree404(self):
urlpatterns = [
url(r'^stock/?', include('stock.urls')),
url(r'^part/?', include('part.urls')),
url(r'^supplier/?', include('supplier.urls')),
url(r'^track/?', include('track.urls')),
url(r'^project/?', include('project.urls')),
url(r'^admin/?', admin.site.urls),
url(r'^auth/?', include('rest_framework.urls', namespace='rest_framework')),
url(r'^stock/', include('stock.urls')),
url(r'^part/', include('part.urls')),
url(r'^supplier/', include('supplier.urls')),
url(r'^track/', include('track.urls')),
url(r'^project/', include('project.urls')),
url(r'^admin/', admin.site.urls),
url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')),
# Any other URL
url(r'', Inventree404)

View File

@ -10,26 +10,29 @@ from . import views
categorypatterns = [
# Part category detail
url(r'^(?P<pk>[0-9]+)/?$', views.PartCategoryDetail.as_view()),
url(r'^(?P<pk>[0-9]+)/?$', views.PartCategoryDetail.as_view(), name='part-category-detail'),
# List of top-level categories
url(r'^\?*[^/]*/?$', views.PartCategoryList.as_view())
url(r'^\?*.*/?$', views.PartCategoryList.as_view(), name='part-category-list'),
url(r'^$', views.PartCategoryList.as_view(), name='part-category-list')
]
partparampatterns = [
# Detail of a single part parameter
url(r'^(?P<pk>[0-9]+)/?$', views.PartParamDetail.as_view()),
url(r'^(?P<pk>[0-9]+)/?$', views.PartParamDetail.as_view(), name='part-parameter-detail'),
# Parameters associated with a particular part
url(r'^\?*[^/]*/?$', views.PartParamList.as_view()),
url(r'^\?.*/?$', views.PartParamList.as_view(), name='part-parameter-list'),
url(r'^$', views.PartParamList.as_view(), name='part-parameter-list'),
]
parttemplatepatterns = [
# Detail of a single part field template
url(r'^(?P<pk>[0-9]+)/?$', views.PartTemplateDetail.as_view()),
url(r'^(?P<pk>[0-9]+)/?$', views.PartTemplateDetail.as_view(), name='part-template-detail'),
# List all part field templates
url(r'^$', views.PartTemplateList.as_view())
url(r'^\?.*/?$', views.PartTemplateList.as_view(), name='part-template-list'),
url(r'^$', views.PartTemplateList.as_view(), name='part-template-list')
]
""" Top-level URL patterns for the Part app:
@ -40,17 +43,18 @@ parttemplatepatterns = [
"""
urlpatterns = [
# Individual part
url(r'^(?P<pk>[0-9]+)/?$', views.PartDetail.as_view()),
url(r'^(?P<pk>[0-9]+)/?$', views.PartDetail.as_view(), name='part-detail'),
# Part categories
url(r'^category/?', include(categorypatterns)),
url(r'^category/', include(categorypatterns)),
# Part parameters
url(r'^parameters/?', include(partparampatterns)),
url(r'^parameters/', include(partparampatterns)),
# Part templates
url(r'^templates/?', include(parttemplatepatterns)),
url(r'^templates/', include(parttemplatepatterns)),
# List parts with optional filters
url(r'^\?*[^/]*/?$', views.PartList.as_view()),
url(r'^\?.*/?$', views.PartList.as_view(), name='part-list'),
url(r'^$', views.PartList.as_view(), name='part-list'),
]

View File

@ -2,41 +2,35 @@ from django.conf.urls import url, include
from . import views
""" URL patterns associated with project
/project/<pk> -> Detail view of single project
/project/<pk>/parts -> Detail all parts associated with project
"""
projectdetailpatterns = [
# Single project detail
url(r'^$', views.ProjectDetail.as_view()),
]
projectpartpatterns = [
# Detail of a single project part
url(r'^(?P<pk>[0-9]+)/?$', views.ProjectPartDetail.as_view()),
url(r'^(?P<pk>[0-9]+)/?$', views.ProjectPartDetail.as_view(), name='project-part-detail'),
# List project parts, with optional filters
url(r'^\?*[^/]*/?$', views.ProjectPartsList.as_view()),
url(r'^\?.*/?$', views.ProjectPartsList.as_view(), name='project-part-list'),
url(r'^$', views.ProjectPartsList.as_view(), name='project-part-list'),
]
projectcategorypatterns = [
# Detail of a single project category
url(r'^(?P<pk>[0-9]+)/?$', views.ProjectCategoryDetail.as_view()),
url(r'^(?P<pk>[0-9]+)/?$', views.ProjectCategoryDetail.as_view(), name='project-category-detail'),
# List of project categories, with filters
url(r'^\?*[^/]*/?$', views.ProjectCategoryList.as_view()),
url(r'^\?.*/?$', views.ProjectCategoryList.as_view(), name='project-category-list'),
url(r'^$', views.ProjectCategoryList.as_view(), name='project-category-list'),
]
urlpatterns = [
# Individual project URL
url(r'^(?P<pk>[0-9]+)/?', include(projectdetailpatterns)),
url(r'^(?P<pk>[0-9]+)/?$', views.ProjectDetail.as_view(), name='project-detail'),
# List of all projects
url(r'^$', views.ProjectList.as_view()),
url(r'^\?.*/?$', views.ProjectList.as_view(), name='project-list'),
url(r'^$', views.ProjectList.as_view(), name='project-list'),
# Project parts
url(r'^parts/?', include(projectpartpatterns)),
url(r'^parts/', include(projectpartpatterns)),
# Project categories
url(r'^category/?', include(projectcategorypatterns)),
url(r'^category/', include(projectcategorypatterns)),
]

View File

@ -20,18 +20,7 @@ class StockItemSerializer(serializers.ModelSerializer):
'expected_arrival')
class LocationBriefSerializer(serializers.ModelSerializer):
""" Brief information about a stock location
"""
class Meta:
model = StockLocation
fields = ('pk',
'name',
'description')
class LocationDetailSerializer(serializers.ModelSerializer):
class LocationSerializer(serializers.ModelSerializer):
""" Detailed information about a stock location
"""

View File

@ -3,18 +3,21 @@ from django.conf.urls import url, include
from . import views
locpatterns = [
url(r'^(?P<pk>[0-9]+)/?$', views.LocationDetail.as_view()),
url(r'^(?P<pk>[0-9]+)/?$', views.LocationDetail.as_view(), name='location-detail'),
url(r'^\?*[^/]*/?$', views.LocationList.as_view())
url(r'^\?.*/?$', views.LocationList.as_view(), name='location-list'),
url(r'^$', views.LocationList.as_view(), name='location-list')
]
urlpatterns = [
# Stock location urls
url(r'^location/?', include(locpatterns)),
url(r'^location/', include(locpatterns)),
# Detail for a single stock item
url(r'^(?P<pk>[0-9]+)$', views.StockDetail.as_view()),
url(r'^(?P<pk>[0-9]+)/?$', views.StockDetail.as_view(), name='stock-detail'),
# List all stock items, with optional filters
url(r'^\?*[^/]*/?$', views.StockList.as_view()),
url(r'^\?.*/?$', views.StockList.as_view(), name='stock-list'),
url(r'^$', views.StockList.as_view(), name='stock-list'),
]

View File

@ -3,7 +3,7 @@ import django_filters
from InvenTree.models import FilterChildren
from .models import StockLocation, StockItem
from .serializers import StockItemSerializer, LocationDetailSerializer
from .serializers import StockItemSerializer, LocationSerializer
class StockDetail(generics.RetrieveUpdateDestroyAPIView):
@ -51,7 +51,7 @@ class LocationDetail(generics.RetrieveUpdateDestroyAPIView):
"""
queryset = StockLocation.objects.all()
serializer_class = LocationDetailSerializer
serializer_class = LocationSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
@ -69,5 +69,5 @@ class LocationList(generics.ListCreateAPIView):
return locations
serializer_class = LocationDetailSerializer
serializer_class = LocationSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

View File

@ -3,17 +3,19 @@ from django.conf.urls import url, include
from . import views
infopatterns = [
url(r'^(?P<pk>[0-9]+)/?$', views.PartTrackingDetail.as_view()),
url(r'^(?P<pk>[0-9]+)/?$', views.PartTrackingDetail.as_view(), name='tracking-detail'),
url(r'^\?*[^/]*/?$', views.PartTrackingList.as_view())
url(r'^\?.*/?$', views.PartTrackingList.as_view(), name='tracking-list'),
url(r'^$', views.PartTrackingList.as_view(), name='tracking-list')
]
urlpatterns = [
url(r'info/?', include(infopatterns)),
url(r'info/', include(infopatterns)),
# Detail for a single unique part
url(r'^(?P<pk>[0-9]+)$', views.UniquePartDetail.as_view()),
url(r'^(?P<pk>[0-9]+)/?$', views.UniquePartDetail.as_view(), name='unique-detail'),
# List all unique parts, with optional filters
url(r'^\?*[^/]*/?$', views.UniquePartList.as_view()),
url(r'^\?.*/?$', views.UniquePartList.as_view(), name='unique-list'),
url(r'^$', views.UniquePartList.as_view(), name='unique-list'),
]