From 9ac89f2b58b22dd64f8ab0ca4aa48485a5576ea6 Mon Sep 17 00:00:00 2001 From: hhyo Date: Tue, 20 Oct 2020 23:28:36 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=A7=E9=81=93=E4=BF=A1=E6=81=AF=E5=9C=A8?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86=E7=BC=96=E8=BE=91=E6=97=B6?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/admin.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sql/admin.py b/sql/admin.py index 203c448c28..33355722b8 100755 --- a/sql/admin.py +++ b/sql/admin.py @@ -1,10 +1,8 @@ # -*- coding: UTF-8 -*- from django.contrib import admin -from django import forms from django.contrib.auth.admin import UserAdmin # Register your models here. -from django.db import models from django.forms import PasswordInput from .models import Users, Instance, SqlWorkflow, SqlWorkflowContent, QueryLog, DataMaskingColumns, DataMaskingRules, \ @@ -60,7 +58,6 @@ def get_readonly_fields(self, request, obj=None): # 实例管理 - @admin.register(Instance) class InstanceAdmin(admin.ModelAdmin): list_display = ('id', 'instance_name', 'db_type', 'type', 'host', 'port', 'user', 'create_time') @@ -81,13 +78,16 @@ class AliRdsConfigInline(admin.TabularInline): inlines = [AliRdsConfigInline] + # SSH隧道 @admin.register(Tunnel) class TunnelAdmin(admin.ModelAdmin): list_display = ('id', 'tunnel_name', 'host', 'port', 'create_time') list_display_links = ('id', 'tunnel_name',) search_fields = ('id', 'tunnel_name') - fieldsets = (None, {'fields': ('tunnel_name', 'host', 'port', 'user', 'password', 'pkey_path', 'pkey_password',), }), + fieldsets = ( + None, + {'fields': ('tunnel_name', 'host', 'port', 'user', 'password', 'pkey_path', 'pkey_password',), }), ordering = ('id',) # 添加页显示内容 add_fieldsets = ( @@ -95,10 +95,16 @@ class TunnelAdmin(admin.ModelAdmin): ('连接信息', {'fields': ('user', 'password', 'pkey_path', 'pkey_password')}), ) + def formfield_for_dbfield(self, db_field, **kwargs): + if db_field.name in ['password', 'pkey_password']: + kwargs['widget'] = PasswordInput(render_value=True) + return super(TunnelAdmin, self).formfield_for_dbfield(db_field, **kwargs) + # 不支持修改标签代码 def get_readonly_fields(self, request, obj=None): return ('id',) if obj else () + # SQL工单内容 class SqlWorkflowContentInline(admin.TabularInline): model = SqlWorkflowContent