InvenTree/InvenTree/part/api.py
2018-04-23 21:18:35 +10:00

49 lines
903 B
Python

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import filters
from rest_framework import generics, permissions
from django.conf.urls import url
from .models import Part
from .serializers import PartSerializer
class PartList(generics.ListCreateAPIView):
queryset = Part.objects.all()
serializer_class = PartSerializer
permission_classes = [
permissions.IsAuthenticatedOrReadOnly,
]
filter_backends = [
DjangoFilterBackend,
filters.SearchFilter,
filters.OrderingFilter,
]
filter_fields = [
'category',
]
ordering_fields = [
'name',
]
ordering = 'name'
search_fields = [
'name',
'description',
]
part_api_urls = [
url(r'^.*$', PartList.as_view(), name='api-part-list'),
]