Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): common department edit method #356

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmdb-api/api/lib/common_setting/department.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ def get_all_department_list(to_dict=True):
*criterion
).order_by(Department.department_id.asc())
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):
Expand Down
2 changes: 1 addition & 1 deletion cmdb-api/api/views/common_setting/department.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def post(self):
class DepartmentIDView(APIView):
url_prefix = (f'{prefix}/<int:_id>',)

def get(self, _id):
def put(self, _id):
form = DepartmentForm(MultiDict(request.json))
if not form.validate():
abort(400, ','.join(['{}: {}'.format(filed, ','.join(msg))
Expand Down
Loading