mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Project API is hyperlinked
This commit is contained in:
parent
a1db0c90e4
commit
9e287d85d8
@ -3,38 +3,40 @@ from rest_framework import serializers
|
||||
from .models import ProjectCategory, Project, ProjectPart
|
||||
|
||||
|
||||
class ProjectPartSerializer(serializers.ModelSerializer):
|
||||
class ProjectPartSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = ProjectPart
|
||||
fields = ('pk',
|
||||
fields = ('url',
|
||||
'part',
|
||||
'project',
|
||||
'quantity',
|
||||
'output')
|
||||
|
||||
|
||||
class ProjectSerializer(serializers.ModelSerializer):
|
||||
""" Serializer for displaying brief overview of a project
|
||||
"""
|
||||
class ProjectSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Project
|
||||
fields = ('pk',
|
||||
fields = ('url',
|
||||
'name',
|
||||
'description',
|
||||
'category')
|
||||
|
||||
|
||||
class ProjectCategorySerializer(serializers.ModelSerializer):
|
||||
class ProjectCategorySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
children = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
|
||||
children = serializers.HyperlinkedRelatedField(many=True,
|
||||
read_only=True,
|
||||
view_name='projectcategory-detail')
|
||||
|
||||
projects = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
|
||||
projects = serializers.HyperlinkedRelatedField(many=True,
|
||||
read_only=True,
|
||||
view_name='project-detail')
|
||||
|
||||
class Meta:
|
||||
model = ProjectCategory
|
||||
fields = ('pk',
|
||||
fields = ('url',
|
||||
'name',
|
||||
'description',
|
||||
'parent',
|
||||
|
@ -4,20 +4,20 @@ from . import views
|
||||
|
||||
projectpartpatterns = [
|
||||
# Detail of a single project part
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.ProjectPartDetail.as_view(), name='project-part-detail'),
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.ProjectPartDetail.as_view(), name='projectpart-detail'),
|
||||
|
||||
# List project parts, with optional filters
|
||||
url(r'^\?.*/?$', views.ProjectPartsList.as_view(), name='project-part-list'),
|
||||
url(r'^$', views.ProjectPartsList.as_view(), name='project-part-list'),
|
||||
url(r'^\?.*/?$', views.ProjectPartsList.as_view()),
|
||||
url(r'^$', views.ProjectPartsList.as_view()),
|
||||
]
|
||||
|
||||
projectcategorypatterns = [
|
||||
# Detail of a single project category
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.ProjectCategoryDetail.as_view(), name='project-category-detail'),
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.ProjectCategoryDetail.as_view(), name='projectcategory-detail'),
|
||||
|
||||
# List of project categories, with filters
|
||||
url(r'^\?.*/?$', views.ProjectCategoryList.as_view(), name='project-category-list'),
|
||||
url(r'^$', views.ProjectCategoryList.as_view(), name='project-category-list'),
|
||||
url(r'^\?.*/?$', views.ProjectCategoryList.as_view()),
|
||||
url(r'^$', views.ProjectCategoryList.as_view()),
|
||||
]
|
||||
|
||||
urlpatterns = [
|
||||
@ -25,8 +25,8 @@ urlpatterns = [
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.ProjectDetail.as_view(), name='project-detail'),
|
||||
|
||||
# List of all projects
|
||||
url(r'^\?.*/?$', views.ProjectList.as_view(), name='project-list'),
|
||||
url(r'^$', views.ProjectList.as_view(), name='project-list'),
|
||||
url(r'^\?.*/?$', views.ProjectList.as_view()),
|
||||
url(r'^$', views.ProjectList.as_view()),
|
||||
|
||||
# Project parts
|
||||
url(r'^parts/', include(projectpartpatterns)),
|
||||
|
Loading…
Reference in New Issue
Block a user