From 3704ad34dc0332791624bfabb265b63b461402eb Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 11 Apr 2017 23:07:02 +1000 Subject: [PATCH] Updated part API --- InvenTree/part/models.py | 3 +-- InvenTree/part/urls.py | 8 ++++---- InvenTree/part/views.py | 9 --------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index b664688bd8..c479037743 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -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): diff --git a/InvenTree/part/urls.py b/InvenTree/part/urls.py index c220617154..601e2d74ee 100644 --- a/InvenTree/part/urls.py +++ b/InvenTree/part/urls.py @@ -3,15 +3,15 @@ from django.conf.urls import url from . import views urlpatterns = [ - # Display part detail + # Single part detail url(r'^(?P[0-9]+)/$', views.PartDetail.as_view()), - # Display a single part category + # Part category detail url(r'^category/(?P[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()) ] diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index cc60db27b7..85451ef00e 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -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()