mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 13:06:45 +00:00
ProjectPart API fix
When a new ProjectPart is added, the Project link is automatically set
This commit is contained in:
parent
56ba30eb52
commit
7acae4ea47
@ -16,6 +16,8 @@ class ProjectDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class ProjectList(generics.ListCreateAPIView):
|
class ProjectList(generics.ListCreateAPIView):
|
||||||
|
""" List all projects
|
||||||
|
"""
|
||||||
|
|
||||||
queryset = Project.objects.all()
|
queryset = Project.objects.all()
|
||||||
serializer_class = ProjectSerializer
|
serializer_class = ProjectSerializer
|
||||||
@ -30,6 +32,8 @@ class NewProjectCategory(generics.CreateAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class ProjectCategoryDetail(generics.RetrieveUpdateAPIView):
|
class ProjectCategoryDetail(generics.RetrieveUpdateAPIView):
|
||||||
|
""" Project details
|
||||||
|
"""
|
||||||
|
|
||||||
queryset = ProjectCategory.objects.all()
|
queryset = ProjectCategory.objects.all()
|
||||||
serializer_class = ProjectCategoryDetailSerializer
|
serializer_class = ProjectCategoryDetailSerializer
|
||||||
@ -37,6 +41,9 @@ class ProjectCategoryDetail(generics.RetrieveUpdateAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class ProjectCategoryList(generics.ListCreateAPIView):
|
class ProjectCategoryList(generics.ListCreateAPIView):
|
||||||
|
""" Top-level project categories.
|
||||||
|
Projects are considered top-level if they do not have a parent
|
||||||
|
"""
|
||||||
|
|
||||||
queryset = ProjectCategory.objects.filter(parent=None)
|
queryset = ProjectCategory.objects.filter(parent=None)
|
||||||
serializer_class = ProjectCategoryDetailSerializer
|
serializer_class = ProjectCategoryDetailSerializer
|
||||||
@ -44,6 +51,8 @@ class ProjectCategoryList(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class ProjectPartsList(generics.ListCreateAPIView):
|
class ProjectPartsList(generics.ListCreateAPIView):
|
||||||
|
""" List all parts associated with a particular project
|
||||||
|
"""
|
||||||
|
|
||||||
serializer_class = ProjectPartSerializer
|
serializer_class = ProjectPartSerializer
|
||||||
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
||||||
@ -51,3 +60,8 @@ class ProjectPartsList(generics.ListCreateAPIView):
|
|||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
project_id = self.kwargs['pk']
|
project_id = self.kwargs['pk']
|
||||||
return ProjectPart.objects.filter(project=project_id)
|
return ProjectPart.objects.filter(project=project_id)
|
||||||
|
|
||||||
|
def create(self, request, *args, **kwargs):
|
||||||
|
# Ensure project link is set correctly
|
||||||
|
request.data['project'] = self.kwargs['pk']
|
||||||
|
return super(ProjectPartsList, self).create(request, *args, **kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user