mirror of https://github.com/veops/cmdb.git
fix(api): common department edit method (#355)
This commit is contained in:
parent
99022bdabb
commit
5e79aab93d
|
@ -24,7 +24,15 @@ def get_all_department_list(to_dict=True):
|
||||||
*criterion
|
*criterion
|
||||||
).order_by(Department.department_id.asc())
|
).order_by(Department.department_id.asc())
|
||||||
results = query.all()
|
results = query.all()
|
||||||
return [r.to_dict() for r in results] if to_dict else results
|
if to_dict:
|
||||||
|
datas = []
|
||||||
|
for r in results:
|
||||||
|
d = r.to_dict()
|
||||||
|
if r.department_id == 0:
|
||||||
|
d['department_name'] = ErrFormat.company_wide
|
||||||
|
datas.append(d)
|
||||||
|
return datas
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
def get_all_employee_list(block=0, to_dict=True):
|
def get_all_employee_list(block=0, to_dict=True):
|
||||||
|
|
|
@ -85,7 +85,7 @@ class DepartmentIDView(APIView):
|
||||||
class DepartmentParentView(APIView):
|
class DepartmentParentView(APIView):
|
||||||
url_prefix = (f'{prefix}/allow_parent',)
|
url_prefix = (f'{prefix}/allow_parent',)
|
||||||
|
|
||||||
def get(self):
|
def put(self):
|
||||||
department_id = request.args.get('department_id', None)
|
department_id = request.args.get('department_id', None)
|
||||||
if department_id is None:
|
if department_id is None:
|
||||||
abort(400, ErrFormat.department_id_is_required)
|
abort(400, ErrFormat.department_id_is_required)
|
||||||
|
|
Loading…
Reference in New Issue