diff --git a/common/auth.py b/common/auth.py index 57dcc6b38e..40b1dde10e 100644 --- a/common/auth.py +++ b/common/auth.py @@ -26,18 +26,15 @@ def init_user(user): # 添加到默认权限组 default_auth_group = SysConfig().get('default_auth_group', '') if default_auth_group: - try: - group = Group.objects.get(name=default_auth_group) - user.groups.add(group) - except Group.DoesNotExist: - logger.info(f'无name为[{default_auth_group}]的权限组,无法默认关联,请到系统设置进行配置') + default_auth_group = default_auth_group.split(',') + [user.groups.add(group) for group in Group.objects.filter(name__in=default_auth_group)] + # 添加到默认资源组 default_resource_group = SysConfig().get('default_resource_group', '') if default_resource_group: - try: - user.resource_group.add(ResourceGroup.objects.get(group_name=default_resource_group)) - except ResourceGroup.DoesNotExist: - logger.info(f'无name为[{default_resource_group}]的资源组,无法默认关联,请到系统设置进行配置') + default_resource_group = default_resource_group.split(',') + [user.resource_group.add(group) for group in + ResourceGroup.objects.filter(group_name__in=default_resource_group)] class ArcheryAuth(object): diff --git a/common/templates/config.html b/common/templates/config.html index 26735be3fa..060d3b4ac9 100755 --- a/common/templates/config.html +++ b/common/templates/config.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load format_tags %} {% block content %}
@@ -192,11 +193,19 @@
SQL上线
- +
@@ -387,11 +396,21 @@
注3:企业微信群机器人需要配置资源组webhoo
- +
@@ -711,22 +730,42 @@

其他配置

- +
- +
@@ -889,6 +928,9 @@
当前审批流程:').replace('\n', '
')) + return mark_safe(string.replace(',', '
').replace('\n', '
')) + + +# split +@register.filter +@stringfilter +def split(string, sep): + """Return the string split by sep. + Example usage: {{ value|split:"/" }} + """ + return string.split(sep) + + +# in +@register.filter +def is_in(var, args): + return True if str(var) in args.split(',') else False diff --git a/sql/views.py b/sql/views.py index 74011d62c2..2ab8df88bb 100644 --- a/sql/views.py +++ b/sql/views.py @@ -373,16 +373,17 @@ def config(request): """配置管理页面""" # 获取所有资源组名称 group_list = ResourceGroup.objects.all() - # 获取所有权限组 auth_group_list = Group.objects.all() + # 获取所有实例标签 + instance_tags = InstanceTag.objects.all() # 获取所有配置项 all_config = Config.objects.all().values('item', 'value') sys_config = {} for items in all_config: sys_config[items['item']] = items['value'] - context = {'group_list': group_list, 'auth_group_list': auth_group_list, + context = {'group_list': group_list, 'auth_group_list': auth_group_list, 'instance_tags': instance_tags, 'config': sys_config, 'WorkflowDict': WorkflowDict} return render(request, 'config.html', context)