Skip to content

Commit

Permalink
实例编辑时隐藏密码信息 fix #851
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo committed Aug 30, 2020
1 parent ec97ead commit 5072c22
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sql/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# -*- 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, \
AliyunRdsConfig, CloudAccessKey, ResourceGroup, QueryPrivilegesApply, \
QueryPrivileges, InstanceAccount, InstanceDatabase, ArchiveConfig, \
Expand Down Expand Up @@ -56,12 +60,18 @@ 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')
search_fields = ['instance_name', 'host', 'port', 'user']
list_filter = ('db_type', 'type', 'instance_tag')

def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'password':
kwargs['widget'] = PasswordInput(render_value=True)
return super(InstanceAdmin, self).formfield_for_dbfield(db_field, **kwargs)

# 阿里云实例关系配置
class AliRdsConfigInline(admin.TabularInline):
model = AliyunRdsConfig
Expand Down

0 comments on commit 5072c22

Please sign in to comment.