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

from apps.em.models import Equipment
from apps.em.serializers import EquipmentSerializer
from apps.system.mixins import CreateUpdateModelAMixin, OptimizationMixin


# Create your views here.
class EquipmentViewSet(CreateUpdateModelAMixin, OptimizationMixin, ModelViewSet):
    """
    设备台账-增删改查
    """
    perms_map = {'get': '*', 'post': 'equipment_create',
                 'put': 'equipment_update', 'delete': 'equipment_delete'}
    queryset = Equipment.objects.all()
    serializer_class = EquipmentSerializer
    search_fields = ['number', 'name', 'place']
    filterset_fields = ['belong_dept', 'keeper']
    ordering_fields = ['create_time']
    ordering = ['-create_time']
