diff --git a/apps/assets/migrations/0106_auto_20220811_1358.py b/apps/assets/migrations/0106_auto_20220811_1358.py new file mode 100644 index 000000000..640dd8adb --- /dev/null +++ b/apps/assets/migrations/0106_auto_20220811_1358.py @@ -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', + ), + ] diff --git a/apps/assets/models/account.py b/apps/assets/models/account.py index 31e43fddc..654ce2cf5 100644 --- a/apps/assets/models/account.py +++ b/apps/assets/models/account.py @@ -3,22 +3,17 @@ from django.utils.translation import gettext_lazy as _ from simple_history.models import HistoricalRecords from common.db.models import JMSBaseModel -from .protocol import ProtocolMixin from .base import BaseUser, AbsConnectivity __all__ = ['Account'] -class Account(BaseUser, AbsConnectivity, ProtocolMixin): +class Account(BaseUser, AbsConnectivity): class Type(models.TextChoices): common = 'common', _('Common 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")) asset = models.ForeignKey('assets.Asset', on_delete=models.CASCADE, verbose_name=_('Asset')) version = models.IntegerField(default=0, verbose_name=_('Version')) @@ -35,7 +30,7 @@ class Account(BaseUser, AbsConnectivity, ProtocolMixin): ] def __str__(self): - return '{}://{}@{}'.format(self.protocol, self.username, self.asset.hostname) + return '{}@{}'.format(self.username, self.asset.hostname) class AccountTemplate(JMSBaseModel): diff --git a/apps/assets/serializers/account.py b/apps/assets/serializers/account.py index 33632d0c9..2d6de8bc8 100644 --- a/apps/assets/serializers/account.py +++ b/apps/assets/serializers/account.py @@ -25,7 +25,7 @@ class AccountSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer): model = Account fields_mini = [ 'id', 'type', 'username', 'ip', 'hostname', - 'platform', 'protocol', 'version' + 'platform', 'version' ] fields_write_only = ['password', 'private_key', 'public_key', 'passphrase'] fields_other = ['date_created', 'date_updated', 'connectivity', 'date_verified', 'comment']