Browse Source

refactor: 修改 ConnectionToken 表结构

pull/8991/head
Jiangjie.Bai 2 years ago
parent
commit
11eb505c78
  1. 29
      apps/authentication/migrations/0013_auto_20221025_1908.py
  2. 13
      apps/authentication/models.py

29
apps/authentication/migrations/0013_auto_20221025_1908.py

@ -0,0 +1,29 @@
# Generated by Django 3.2.14 on 2022-10-25 11:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('assets', '0111_alter_changesecretautomation_secret_strategy'),
('authentication', '0012_auto_20220816_1629'),
]
operations = [
migrations.RemoveField(
model_name='connectiontoken',
name='type',
),
migrations.AddField(
model_name='connectiontoken',
name='account_display',
field=models.CharField(default='', max_length=128, verbose_name='Account display'),
),
migrations.AlterField(
model_name='connectiontoken',
name='account',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='connection_tokens', to='assets.account', verbose_name='Account'),
),
]

13
apps/authentication/models.py

@ -63,13 +63,6 @@ def date_expired_default():
class ConnectionToken(OrgModelMixin, JMSBaseModel):
class Type(models.TextChoices):
asset = 'asset', _('Asset')
application = 'application', _('Application')
type = models.CharField(
max_length=16, default=Type.asset, choices=Type.choices, verbose_name=_("Type")
)
secret = models.CharField(max_length=64, default='', verbose_name=_("Secret"))
date_expired = models.DateTimeField(
default=date_expired_default, verbose_name=_("Date expired")
@ -85,7 +78,11 @@ class ConnectionToken(OrgModelMixin, JMSBaseModel):
related_name='connection_tokens', null=True, blank=True
)
asset_display = models.CharField(max_length=128, default='', verbose_name=_("Asset display"))
account = models.CharField(max_length=128, default='', verbose_name=_("Account"))
account = models.ForeignKey(
'assets.Account', on_delete=models.SET_NULL, verbose_name=_('Account'),
related_name='connection_tokens', null=True, blank=True
)
account_display = models.CharField(max_length=128, default='', verbose_name=_("Account display"))
class Meta:
ordering = ('-date_expired',)

Loading…
Cancel
Save