mirror of https://github.com/jumpserver/jumpserver
Merge pull request #9373 from jumpserver/pr@dev@change_migrations
perf: 修改 database 的 cert model fieldpull/9374/head
commit
bebfe10d73
|
@ -2,6 +2,7 @@
|
|||
|
||||
import django.db
|
||||
from django.db import migrations, models
|
||||
import common.db.fields
|
||||
|
||||
|
||||
def migrate_to_host(apps, schema_editor):
|
||||
|
@ -120,9 +121,9 @@ class Migration(migrations.Migration):
|
|||
primary_key=True, serialize=False, to='assets.asset')),
|
||||
('db_name', models.CharField(blank=True, max_length=1024, verbose_name='Database')),
|
||||
('allow_invalid_cert', models.BooleanField(default=False, verbose_name='Allow invalid cert')),
|
||||
('ca_cert', models.TextField(blank=True, verbose_name='CA cert')),
|
||||
('client_cert', models.TextField(blank=True, verbose_name='Client cert')),
|
||||
('client_key', models.TextField(blank=True, verbose_name='Client key'),),
|
||||
('ca_cert', common.db.fields.EncryptTextField(blank=True, verbose_name='CA cert')),
|
||||
('client_cert', common.db.fields.EncryptTextField(blank=True, verbose_name='Client cert')),
|
||||
('client_key', common.db.fields.EncryptTextField(blank=True, verbose_name='Client key'),),
|
||||
('use_ssl', models.BooleanField(default=False, verbose_name='Use SSL'),),
|
||||
],
|
||||
options={
|
||||
|
|
|
@ -11,6 +11,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
from assets import const
|
||||
from common.utils import lazyproperty
|
||||
from common.db.fields import EncryptMixin
|
||||
from orgs.mixins.models import OrgManager, JMSOrgBaseModel
|
||||
from ..base import AbsConnectivity
|
||||
from ..platform import Platform
|
||||
|
@ -139,6 +140,7 @@ class Asset(NodesRelationMixin, AbsConnectivity, JMSOrgBaseModel):
|
|||
if not instance:
|
||||
return []
|
||||
specific_fields = self.get_specific_fields(instance)
|
||||
specific_fields = [i for i in specific_fields if not isinstance(i, EncryptMixin)]
|
||||
info = [
|
||||
{
|
||||
'label': i.verbose_name,
|
||||
|
|
|
@ -1,28 +1,21 @@
|
|||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from common.db.fields import EncryptTextField
|
||||
from .common import Asset
|
||||
|
||||
|
||||
class Database(Asset):
|
||||
db_name = models.CharField(max_length=1024, verbose_name=_("Database"), blank=True)
|
||||
use_ssl = models.BooleanField(default=False, verbose_name=_("Use SSL"))
|
||||
ca_cert = models.TextField(verbose_name=_("CA cert"), blank=True)
|
||||
client_cert = models.TextField(verbose_name=_("Client cert"), blank=True)
|
||||
client_key = models.TextField(verbose_name=_("Client key"), blank=True)
|
||||
ca_cert = EncryptTextField(verbose_name=_("CA cert"), blank=True)
|
||||
client_cert = EncryptTextField(verbose_name=_("Client cert"), blank=True)
|
||||
client_key = EncryptTextField(verbose_name=_("Client key"), blank=True)
|
||||
allow_invalid_cert = models.BooleanField(default=False, verbose_name=_('Allow invalid cert'))
|
||||
|
||||
def __str__(self):
|
||||
return '{}({}://{}/{})'.format(self.name, self.type, self.address, self.db_name)
|
||||
|
||||
@property
|
||||
def specific(self):
|
||||
return {
|
||||
'db_name': self.db_name,
|
||||
'use_ssl': self.use_ssl,
|
||||
'allow_invalid_cert': self.allow_invalid_cert,
|
||||
}
|
||||
|
||||
@property
|
||||
def ip(self):
|
||||
return self.address
|
||||
|
|
Loading…
Reference in New Issue