fix(backend): removed extra print log

pull/64/head
Angelo 2022-06-07 12:05:27 +08:00
parent aa9bd2ade3
commit 5ef2045eeb
2 changed files with 28 additions and 15 deletions

View File

@ -9,7 +9,7 @@ def is_tenants_mode():
判断是否为租户模式 判断是否为租户模式
:return: :return:
""" """
return hasattr(connection, 'tenant') and connection.tenant.schema_name return hasattr(connection, "tenant") and connection.tenant.schema_name
# ================================================= # # ================================================= #
@ -17,27 +17,37 @@ def is_tenants_mode():
# ================================================= # # ================================================= #
def _get_all_dictionary(): def _get_all_dictionary():
from dvadmin.system.models import Dictionary from dvadmin.system.models import Dictionary
queryset = Dictionary.objects.filter(status=True, is_value=False) queryset = Dictionary.objects.filter(status=True, is_value=False)
data = [] data = []
for instance in queryset: for instance in queryset:
data.append({ data.append(
{
"id": instance.id, "id": instance.id,
"value": instance.value, "value": instance.value,
"children": list(Dictionary.objects.filter(parent=instance.id).filter(status=1). "children": list(
values('label', 'value', 'type', 'color')) Dictionary.objects.filter(parent=instance.id)
}) .filter(status=1)
.values("label", "value", "type", "color")
),
}
)
return {ele.get("value"): ele for ele in data} return {ele.get("value"): ele for ele in data}
def _get_all_system_config(): def _get_all_system_config():
data = {} data = {}
from dvadmin.system.models import SystemConfig from dvadmin.system.models import SystemConfig
system_config_obj = SystemConfig.objects.filter(status=True, parent_id__isnull=False).values(
'parent__key', 'key', 'value', 'form_item_type').order_by('sort') system_config_obj = (
SystemConfig.objects.filter(status=True, parent_id__isnull=False)
.values("parent__key", "key", "value", "form_item_type")
.order_by("sort")
)
for system_config in system_config_obj: for system_config in system_config_obj:
value = system_config.get('value', '') value = system_config.get("value", "")
if value and system_config.get('form_item_type') == 7: if value and system_config.get("form_item_type") == 7:
value = value[0].get('url') value = value[0].get("url")
data[f"{system_config.get('parent__key')}.{system_config.get('key')}"] = value data[f"{system_config.get('parent__key')}.{system_config.get('key')}"] = value
return data return data
@ -50,12 +60,12 @@ def init_dictionary():
try: try:
if is_tenants_mode(): if is_tenants_mode():
from django_tenants.utils import tenant_context, get_tenant_model from django_tenants.utils import tenant_context, get_tenant_model
for tenant in get_tenant_model().objects.filter(): for tenant in get_tenant_model().objects.filter():
with tenant_context(tenant): with tenant_context(tenant):
settings.DICTIONARY_CONFIG[connection.tenant.schema_name] = _get_all_dictionary() settings.DICTIONARY_CONFIG[connection.tenant.schema_name] = _get_all_dictionary()
else: else:
settings.DICTIONARY_CONFIG = _get_all_dictionary() settings.DICTIONARY_CONFIG = _get_all_dictionary()
print("初始化字典配置完成")
except Exception as e: except Exception as e:
print("请先进行数据库迁移!") print("请先进行数据库迁移!")
return return
@ -71,11 +81,13 @@ def init_system_config():
if is_tenants_mode(): if is_tenants_mode():
from django_tenants.utils import tenant_context, get_tenant_model from django_tenants.utils import tenant_context, get_tenant_model
for tenant in get_tenant_model().objects.filter(): for tenant in get_tenant_model().objects.filter():
with tenant_context(tenant): with tenant_context(tenant):
settings.SYSTEM_CONFIG[connection.tenant.schema_name] = _get_all_system_config() 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()
if settings.SYSTEM_CONFIG:
print("初始化系统配置完成") print("初始化系统配置完成")
except Exception as e: except Exception as e:
print("请先进行数据库迁移!") print("请先进行数据库迁移!")
@ -89,6 +101,7 @@ def refresh_dictionary():
""" """
if is_tenants_mode(): if is_tenants_mode():
from django_tenants.utils import tenant_context, get_tenant_model from django_tenants.utils import tenant_context, get_tenant_model
for tenant in get_tenant_model().objects.filter(): for tenant in get_tenant_model().objects.filter():
with tenant_context(tenant): with tenant_context(tenant):
settings.DICTIONARY_CONFIG[connection.tenant.schema_name] = _get_all_dictionary() settings.DICTIONARY_CONFIG[connection.tenant.schema_name] = _get_all_dictionary()
@ -103,6 +116,7 @@ def refresh_system_config():
""" """
if is_tenants_mode(): if is_tenants_mode():
from django_tenants.utils import tenant_context, get_tenant_model from django_tenants.utils import tenant_context, get_tenant_model
for tenant in get_tenant_model().objects.filter(): for tenant in get_tenant_model().objects.filter():
with tenant_context(tenant): with tenant_context(tenant):
settings.SYSTEM_CONFIG[connection.tenant.schema_name] = _get_all_system_config() settings.SYSTEM_CONFIG[connection.tenant.schema_name] = _get_all_system_config()

View File

@ -26,7 +26,6 @@ def import_to_data(file_url, field_data):
array = {} array = {}
for index, ele in enumerate(field_data.keys()): for index, ele in enumerate(field_data.keys()):
cell_value = table.cell(row=row + 1, column=index + 2).value cell_value = table.cell(row=row + 1, column=index + 2).value
print(cell_value)
# 由于excel导入数字类型后会出现数字加 .0 的,进行处理 # 由于excel导入数字类型后会出现数字加 .0 的,进行处理
if type(cell_value) is float and str(cell_value).split(".")[1] == "0": if type(cell_value) is float and str(cell_value).split(".")[1] == "0":
cell_value = int(str(cell_value).split(".")[0]) cell_value = int(str(cell_value).split(".")[0])