26 lines
		
	
	
		
			868 B
		
	
	
	
		
			Python
		
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			868 B
		
	
	
	
		
			Python
		
	
	
	
| from django.shortcuts import render
 | |
| from rest_framework.viewsets import ModelViewSet
 | |
| 
 | |
| from apps.inm.models import WareHouse
 | |
| from apps.inm.serializers import WareHouseSerializer, WareHouseCreateUpdateSerializer
 | |
| from apps.system.mixins import CreateUpdateModelAMixin, OptimizationMixin
 | |
| 
 | |
| 
 | |
| # Create your views here.
 | |
| class WarehouseViewSet(CreateUpdateModelAMixin, ModelViewSet):
 | |
|     """
 | |
|     仓库-增删改查
 | |
|     """
 | |
|     perms_map = {'*': '*'}
 | |
|     queryset = WareHouse.objects.select_related('create_by').all()
 | |
|     serializer_class = WareHouseSerializer
 | |
|     search_fields = ['name', 'number', 'place']
 | |
|     filterset_fields = []
 | |
|     ordering_fields = ['create_time']
 | |
|     ordering = ['-create_time']
 | |
| 
 | |
|     def  get_serializer_class(self):
 | |
|         if self.action in ['create', 'update']:
 | |
|             return WareHouseCreateUpdateSerializer
 | |
|         return WareHouseSerializer
 |