mirror of https://github.com/veops/cmdb.git
Merge branch 'master' into dev_ui_240103_2
This commit is contained in:
commit
64c5e8126d
|
@ -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):
|
||||||
|
@ -101,6 +109,7 @@ class DepartmentTree(object):
|
||||||
employees = self.get_employees_by_d_id(department_id)
|
employees = self.get_employees_by_d_id(department_id)
|
||||||
|
|
||||||
top_d['employees'] = employees
|
top_d['employees'] = employees
|
||||||
|
top_d['department_name'] = ErrFormat.company_wide
|
||||||
if len(sub_deps) == 0:
|
if len(sub_deps) == 0:
|
||||||
top_d[sub_departments_column_name] = []
|
top_d[sub_departments_column_name] = []
|
||||||
d_list.append(top_d)
|
d_list.append(top_d)
|
||||||
|
@ -313,6 +322,7 @@ class DepartmentCRUD(object):
|
||||||
tree_list = []
|
tree_list = []
|
||||||
|
|
||||||
for top_d in top_deps:
|
for top_d in top_deps:
|
||||||
|
top_d['department_name'] = ErrFormat.company_wide
|
||||||
tree = Tree()
|
tree = Tree()
|
||||||
identifier_root = top_d['department_id']
|
identifier_root = top_d['department_id']
|
||||||
tree.create_node(
|
tree.create_node(
|
||||||
|
@ -383,6 +393,9 @@ class DepartmentCRUD(object):
|
||||||
|
|
||||||
d['employee_count'] = len(list(filter(lambda e: e['department_id'] in d_ids, all_employee_list)))
|
d['employee_count'] = len(list(filter(lambda e: e['department_id'] in d_ids, all_employee_list)))
|
||||||
|
|
||||||
|
if int(department_parent_id) == -1:
|
||||||
|
d['department_name'] = ErrFormat.company_wide
|
||||||
|
|
||||||
return all_departments, department_id_list
|
return all_departments, department_id_list
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -296,6 +296,8 @@ class EmployeeCRUD(object):
|
||||||
for r in pagination.items:
|
for r in pagination.items:
|
||||||
d = r.Employee.to_dict()
|
d = r.Employee.to_dict()
|
||||||
d['department_name'] = r.Department.department_name if r.Department else ''
|
d['department_name'] = r.Department.department_name if r.Department else ''
|
||||||
|
if r.Employee.department_id == 0:
|
||||||
|
d['department_name'] = ErrFormat.company_wide
|
||||||
employees.append(d)
|
employees.append(d)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -66,7 +66,7 @@ class ErrFormat(CommonErrFormat):
|
||||||
notice_platform_existed = _l("Notice platform {} existed") # {} 已存在
|
notice_platform_existed = _l("Notice platform {} existed") # {} 已存在
|
||||||
notice_not_existed = _l("Notice {} not existed") # {} 配置项不存在
|
notice_not_existed = _l("Notice {} not existed") # {} 配置项不存在
|
||||||
notice_please_config_messenger_first = _l("Notice please config messenger first") # 请先配置messenger URL
|
notice_please_config_messenger_first = _l("Notice please config messenger first") # 请先配置messenger URL
|
||||||
notice_bind_err_with_empty_mobile = _l("Notice bind err with empty mobile") # 绑定错误,手机号为空
|
notice_bind_err_with_empty_mobile = _l("Notice bind err with empty mobile") # 绑定错误,手机号为空
|
||||||
notice_bind_failed = _l("Notice bind failed: {}") # 绑定失败: {}
|
notice_bind_failed = _l("Notice bind failed: {}") # 绑定失败: {}
|
||||||
notice_bind_success = _l("Notice bind success") # 绑定成功
|
notice_bind_success = _l("Notice bind success") # 绑定成功
|
||||||
notice_remove_bind_success = _l("Notice remove bind success") # 解绑成功
|
notice_remove_bind_success = _l("Notice remove bind success") # 解绑成功
|
||||||
|
@ -78,3 +78,5 @@ class ErrFormat(CommonErrFormat):
|
||||||
ldap_test_unknown_error = _l("LDAP test unknown error: {}") # LDAP测试未知错误: {}
|
ldap_test_unknown_error = _l("LDAP test unknown error: {}") # LDAP测试未知错误: {}
|
||||||
common_data_not_support_auth_type = _l("Common data not support auth type: {}") # 通用数据不支持auth类型: {}
|
common_data_not_support_auth_type = _l("Common data not support auth type: {}") # 通用数据不支持auth类型: {}
|
||||||
ldap_test_username_required = _l("LDAP test username required") # LDAP测试用户名必填
|
ldap_test_username_required = _l("LDAP test username required") # LDAP测试用户名必填
|
||||||
|
|
||||||
|
company_wide = _l("Company wide") # 全公司
|
||||||
|
|
Binary file not shown.
|
@ -7,7 +7,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PROJECT VERSION\n"
|
"Project-Id-Version: PROJECT VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
"POT-Creation-Date: 2023-12-26 09:41+0800\n"
|
"POT-Creation-Date: 2024-01-03 11:39+0800\n"
|
||||||
"PO-Revision-Date: 2023-12-25 20:21+0800\n"
|
"PO-Revision-Date: 2023-12-25 20:21+0800\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language: zh\n"
|
"Language: zh\n"
|
||||||
|
@ -688,6 +688,10 @@ msgstr "通用数据不支持auth类型: {}"
|
||||||
msgid "LDAP test username required"
|
msgid "LDAP test username required"
|
||||||
msgstr "LDAP测试用户名必填"
|
msgstr "LDAP测试用户名必填"
|
||||||
|
|
||||||
|
#: api/lib/common_setting/resp_format.py:82
|
||||||
|
msgid "Company wide"
|
||||||
|
msgstr "全公司"
|
||||||
|
|
||||||
#: api/lib/perm/acl/resp_format.py:9
|
#: api/lib/perm/acl/resp_format.py:9
|
||||||
msgid "login successful"
|
msgid "login successful"
|
||||||
msgstr "登录成功"
|
msgstr "登录成功"
|
||||||
|
|
|
@ -62,7 +62,7 @@ class DepartmentView(APIView):
|
||||||
class DepartmentIDView(APIView):
|
class DepartmentIDView(APIView):
|
||||||
url_prefix = (f'{prefix}/<int:_id>',)
|
url_prefix = (f'{prefix}/<int:_id>',)
|
||||||
|
|
||||||
def get(self, _id):
|
def put(self, _id):
|
||||||
form = DepartmentForm(MultiDict(request.json))
|
form = DepartmentForm(MultiDict(request.json))
|
||||||
if not form.validate():
|
if not form.validate():
|
||||||
abort(400, ','.join(['{}: {}'.format(filed, ','.join(msg))
|
abort(400, ','.join(['{}: {}'.format(filed, ','.join(msg))
|
||||||
|
|
|
@ -14,6 +14,7 @@ services:
|
||||||
- db-data:/var/lib/mysql
|
- db-data:/var/lib/mysql
|
||||||
- ./docs/mysqld.cnf:/etc/mysql/conf.d/mysqld.cnf
|
- ./docs/mysqld.cnf:/etc/mysql/conf.d/mysqld.cnf
|
||||||
- ./docs/cmdb.sql:/docker-entrypoint-initdb.d/cmdb.sql
|
- ./docs/cmdb.sql:/docker-entrypoint-initdb.d/cmdb.sql
|
||||||
|
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||||
networks:
|
networks:
|
||||||
new:
|
new:
|
||||||
aliases:
|
aliases:
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
## 本地搭建: 环境和依赖
|
## 本地搭建: 环境和依赖
|
||||||
|
|
||||||
- 存储: mysql, redis
|
- 存储: mysql, redis
|
||||||
- python 版本: >=python3.7
|
- python 版本: 3.8 <= python <= 3.11
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
- 启动 mysql 服务, redis 服务
|
- 启动 mysql 服务, redis 服务
|
||||||
> mysql一定要设置sql_mode, root进入mysql执行:
|
> mysql一定要设置sql_mode, root进入mysql执行:
|
||||||
>
|
>
|
||||||
> `set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';`
|
> `set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';`
|
||||||
>
|
>
|
||||||
> `set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';`
|
> `set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';`
|
||||||
|
|
||||||
- 创建数据库 cmdb
|
- 创建数据库 cmdb
|
||||||
- 拉取代码
|
- 拉取代码
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
### Install
|
### Install
|
||||||
|
|
||||||
|
- python version: 3.8 <= python <= 3.11
|
||||||
|
|
||||||
|
|
||||||
- Start mysql, redis
|
- Start mysql, redis
|
||||||
> mysql must set sql_mode, and root enters mysql to execute:
|
> mysql must set sql_mode, and root enters mysql to execute:
|
||||||
>
|
>
|
||||||
> `set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';`
|
> `set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';`
|
||||||
>
|
>
|
||||||
> `set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';`
|
> `set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';`
|
||||||
|
|
||||||
- Create mysql database: cmdb
|
- Create mysql database: cmdb
|
||||||
- Pull code
|
- Pull code
|
||||||
|
|
Loading…
Reference in New Issue