功能变化: 初始化优化

treebeard
李强 2022-05-17 09:23:36 +08:00
parent 4177c03abb
commit e8404ba8b9
5 changed files with 15 additions and 38552 deletions

1
backend/.gitignore vendored
View File

@ -96,3 +96,4 @@ conf/
db.sqlite3 db.sqlite3
media/ media/
__pypackages__/ __pypackages__/
package-lock.json

View File

@ -57,7 +57,7 @@ def init_dictionary():
else: else:
settings.DICTIONARY_CONFIG = _get_all_dictionary() settings.DICTIONARY_CONFIG = _get_all_dictionary()
print("初始化字典配置完成") print("初始化字典配置完成")
except ProgrammingError as e: except Exception as e:
print("请先进行数据库迁移!") print("请先进行数据库迁移!")
return return
@ -78,7 +78,7 @@ def init_system_config():
else: else:
settings.SYSTEM_CONFIG = _get_all_system_config() settings.SYSTEM_CONFIG = _get_all_system_config()
print("初始化系统配置完成") print("初始化系统配置完成")
except ProgrammingError as e: except Exception as e:
print("请先进行数据库迁移!") print("请先进行数据库迁移!")
return return
@ -89,9 +89,10 @@ def refresh_dictionary():
:return: :return:
""" """
if is_tenants_mode(): if is_tenants_mode():
from django_tenants.utils import schema_context from django_tenants.utils import tenant_context, get_tenant_model
with schema_context(connection.tenant.schema_name): for tenant in get_tenant_model().objects.filter():
settings.DICTIONARY_CONFIG[connection.tenant.schema_name] = _get_all_dictionary() with tenant_context(tenant):
settings.DICTIONARY_CONFIG[connection.tenant.schema_name] = _get_all_dictionary()
else: else:
settings.DICTIONARY_CONFIG = _get_all_dictionary() settings.DICTIONARY_CONFIG = _get_all_dictionary()
@ -102,9 +103,10 @@ def refresh_system_config():
:return: :return:
""" """
if is_tenants_mode(): if is_tenants_mode():
from django_tenants.utils import schema_context from django_tenants.utils import tenant_context, get_tenant_model
with schema_context(connection.tenant.schema_name): for tenant in get_tenant_model().objects.filter():
settings.SYSTEM_CONFIG[connection.tenant.schema_name] = _get_all_system_config() with tenant_context(tenant):
settings.SYSTEM_CONFIG[connection.tenant.schema_name] = _get_all_system_config()
else: else:
settings.SYSTEM_CONFIG = _get_all_system_config() settings.SYSTEM_CONFIG = _get_all_system_config()

View File

@ -35,8 +35,8 @@ from dvadmin.system.views.system_config import InitSettingsViewSet
from dvadmin.utils.swagger import CustomOpenAPISchemaGenerator from dvadmin.utils.swagger import CustomOpenAPISchemaGenerator
# =========== 初始化系统配置 ================= # =========== 初始化系统配置 =================
# dispatch.init_system_config() dispatch.init_system_config()
# dispatch.init_dictionary() dispatch.init_dictionary()
# =========== 初始化系统配置 ================= # =========== 初始化系统配置 =================
schema_view = get_schema_view( schema_view = get_schema_view(

2
web/.gitignore vendored
View File

@ -1,7 +1,7 @@
.DS_Store .DS_Store
node_modules node_modules
/dist /dist
package-lock.json
# local env files # local env files
.env.local .env.local
.env.*.local .env.*.local

38540
web/package-lock.json generated

File diff suppressed because it is too large Load Diff