Updated part API

This commit is contained in:
Oliver 2017-04-11 23:07:02 +10:00
parent 15582369d2
commit 3704ad34dc
3 changed files with 5 additions and 15 deletions

View File

@ -16,8 +16,7 @@ class PartCategory(InvenTreeTree):
@property
def parts(self):
parts_list = self.part_set.all()
return parts_list
return self.part_set.all()
class Part(models.Model):

View File

@ -3,15 +3,15 @@ from django.conf.urls import url
from . import views
urlpatterns = [
# Display part detail
# Single part detail
url(r'^(?P<pk>[0-9]+)/$', views.PartDetail.as_view()),
# Display a single part category
# Part category detail
url(r'^category/(?P<pk>[0-9]+)/$', views.PartCategoryDetail.as_view()),
# Display a list of top-level categories
# List of top-level categories
url(r'^category/$', views.PartCategoryList.as_view()),
# Display list of all parts
# List of all parts
url(r'^$', views.PartList.as_view())
]

View File

@ -1,4 +1,3 @@
from django.http import HttpResponse
from rest_framework import generics
from .models import PartCategory, Part
@ -6,14 +5,6 @@ from .serializers import PartBriefSerializer, PartDetailSerializer
from .serializers import PartCategoryBriefSerializer, PartCategoryDetailSerializer
def part_index(request):
return HttpResponse("Hello world. This is the parts page")
def category_index(request):
return HttpResponse("This is the category page")
class PartDetail(generics.RetrieveAPIView):
queryset = Part.objects.all()