def sort_depts_in_dept(self, depts, parent_dept): ''' 调整一批部门在父部门中的排序 ''' for dept in depts: if dept.parent != parent_dept: raise ValidationError({'node': ['unrelated']}) Dept.sort_as(depts)
def put(self, request, uid): dept_ids = request.data.get('dept_ids', []) depts = Dept.get_from_pks(pks=dept_ids, pk_name='id', raise_exception=True, is_del=False) Dept.sort_as(depts) return Response({'error_code': 0})