mirror of https://github.com/jumpserver/jumpserver
perf: account remove protocol
parent
9d4a828c53
commit
497204d777
|
@ -0,0 +1,35 @@
|
||||||
|
# Generated by Django 3.2.14 on 2022-08-11 05:58
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('assets', '0105_auto_20220810_1449'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='AccountTemplate',
|
||||||
|
fields=[
|
||||||
|
('created_by', models.CharField(blank=True, max_length=32, null=True, verbose_name='Created by')),
|
||||||
|
('updated_by', models.CharField(blank=True, max_length=32, null=True, verbose_name='Updated by')),
|
||||||
|
('date_created', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Date created')),
|
||||||
|
('date_updated', models.DateTimeField(auto_now=True, verbose_name='Date updated')),
|
||||||
|
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='account',
|
||||||
|
name='protocol',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='historicalaccount',
|
||||||
|
name='protocol',
|
||||||
|
),
|
||||||
|
]
|
|
@ -3,22 +3,17 @@ from django.utils.translation import gettext_lazy as _
|
||||||
from simple_history.models import HistoricalRecords
|
from simple_history.models import HistoricalRecords
|
||||||
|
|
||||||
from common.db.models import JMSBaseModel
|
from common.db.models import JMSBaseModel
|
||||||
from .protocol import ProtocolMixin
|
|
||||||
from .base import BaseUser, AbsConnectivity
|
from .base import BaseUser, AbsConnectivity
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['Account']
|
__all__ = ['Account']
|
||||||
|
|
||||||
|
|
||||||
class Account(BaseUser, AbsConnectivity, ProtocolMixin):
|
class Account(BaseUser, AbsConnectivity):
|
||||||
class Type(models.TextChoices):
|
class Type(models.TextChoices):
|
||||||
common = 'common', _('Common user')
|
common = 'common', _('Common user')
|
||||||
admin = 'admin', _('Admin user')
|
admin = 'admin', _('Admin user')
|
||||||
|
|
||||||
protocol = models.CharField(
|
|
||||||
max_length=16, choices=ProtocolMixin.Protocol.choices,
|
|
||||||
default='ssh', verbose_name=_('Protocol')
|
|
||||||
)
|
|
||||||
type = models.CharField(max_length=16, choices=Type.choices, default=Type.common, verbose_name=_("Type"))
|
type = models.CharField(max_length=16, choices=Type.choices, default=Type.common, verbose_name=_("Type"))
|
||||||
asset = models.ForeignKey('assets.Asset', on_delete=models.CASCADE, verbose_name=_('Asset'))
|
asset = models.ForeignKey('assets.Asset', on_delete=models.CASCADE, verbose_name=_('Asset'))
|
||||||
version = models.IntegerField(default=0, verbose_name=_('Version'))
|
version = models.IntegerField(default=0, verbose_name=_('Version'))
|
||||||
|
@ -35,7 +30,7 @@ class Account(BaseUser, AbsConnectivity, ProtocolMixin):
|
||||||
]
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '{}://{}@{}'.format(self.protocol, self.username, self.asset.hostname)
|
return '{}@{}'.format(self.username, self.asset.hostname)
|
||||||
|
|
||||||
|
|
||||||
class AccountTemplate(JMSBaseModel):
|
class AccountTemplate(JMSBaseModel):
|
||||||
|
|
|
@ -25,7 +25,7 @@ class AccountSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
|
||||||
model = Account
|
model = Account
|
||||||
fields_mini = [
|
fields_mini = [
|
||||||
'id', 'type', 'username', 'ip', 'hostname',
|
'id', 'type', 'username', 'ip', 'hostname',
|
||||||
'platform', 'protocol', 'version'
|
'platform', 'version'
|
||||||
]
|
]
|
||||||
fields_write_only = ['password', 'private_key', 'public_key', 'passphrase']
|
fields_write_only = ['password', 'private_key', 'public_key', 'passphrase']
|
||||||
fields_other = ['date_created', 'date_updated', 'connectivity', 'date_verified', 'comment']
|
fields_other = ['date_created', 'date_updated', 'connectivity', 'date_verified', 'comment']
|
||||||
|
|
Loading…
Reference in New Issue