from django.shortcuts import render
from rest_framework.viewsets import ModelViewSet

from apps.pum.models import Vendor
from apps.pum.serializers import VendorSerializer
from apps.system.mixins import CreateUpdateModelAMixin, OptimizationMixin


# Create your views here.
class VendorViewSet(CreateUpdateModelAMixin, ModelViewSet):
    """
    供应商-增删改查
    """
    perms_map = {'get': '*', 'post': 'vendor_create',
                 'put': 'vendor_update', 'delete': 'vendor_delete'}
    queryset = Vendor.objects.all()
    serializer_class = VendorSerializer
    search_fields = ['name', 'contact']
    filterset_fields = []
    ordering_fields = ['create_time']
    ordering = ['-create_time']
