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 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():
from dvadmin.system.models import Dictionary
queryset = Dictionary.objects.filter(status=True, is_value=False)
data = []
for instance in queryset:
data.append({
"id": instance.id,
"value": instance.value,
"children": list(Dictionary.objects.filter(parent=instance.id).filter(status=1).
values('label', 'value', 'type', 'color'))
})
data.append(
{
"id": instance.id,
"value": instance.value,
"children": list(
Dictionary.objects.filter(parent=instance.id)
.filter(status=1)
.values("label", "value", "type", "color")
),
}
)
return {ele.get("value"): ele for ele in data}
def _get_all_system_config():
data = {}
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:
value = system_config.get('value', '')
if value and system_config.get('form_item_type') == 7:
value = value[0].get('url')
value = system_config.get("value", "")
if value and system_config.get("form_item_type") == 7:
value = value[0].get("url")
data[f"{system_config.get('parent__key')}.{system_config.get('key')}"] = value
return data
@ -50,12 +60,12 @@ def init_dictionary():
try:
if is_tenants_mode():
from django_tenants.utils import tenant_context, get_tenant_model
for tenant in get_tenant_model().objects.filter():
with tenant_context(tenant):
settings.DICTIONARY_CONFIG[connection.tenant.schema_name] = _get_all_dictionary()
else:
settings.DICTIONARY_CONFIG = _get_all_dictionary()
print("初始化字典配置完成")
except Exception as e:
print("请先进行数据库迁移!")
return
@ -71,12 +81,14 @@ def init_system_config():
if is_tenants_mode():
from django_tenants.utils import tenant_context, get_tenant_model
for tenant in get_tenant_model().objects.filter():
with tenant_context(tenant):
settings.SYSTEM_CONFIG[connection.tenant.schema_name] = _get_all_system_config()
else:
settings.SYSTEM_CONFIG = _get_all_system_config()
print("初始化系统配置完成")
if settings.SYSTEM_CONFIG:
print("初始化系统配置完成")
except Exception as e:
print("请先进行数据库迁移!")
return
@ -89,6 +101,7 @@ def refresh_dictionary():
"""
if is_tenants_mode():
from django_tenants.utils import tenant_context, get_tenant_model
for tenant in get_tenant_model().objects.filter():
with tenant_context(tenant):
settings.DICTIONARY_CONFIG[connection.tenant.schema_name] = _get_all_dictionary()
@ -103,6 +116,7 @@ def refresh_system_config():
"""
if is_tenants_mode():
from django_tenants.utils import tenant_context, get_tenant_model
for tenant in get_tenant_model().objects.filter():
with tenant_context(tenant):
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 = {}
for index, ele in enumerate(field_data.keys()):
cell_value = table.cell(row=row + 1, column=index + 2).value
print(cell_value)
# 由于excel导入数字类型后会出现数字加 .0 的,进行处理
if type(cell_value) is float and str(cell_value).split(".")[1] == "0":
cell_value = int(str(cell_value).split(".")[0])