修复migrate bug

pull/8873/head
feng626 2022-08-22 18:48:07 +08:00
parent a7d193464e
commit 97c6e2c0b2
4 changed files with 10 additions and 3 deletions

View File

@ -18,6 +18,9 @@ def create_app_platform(apps, *args):
{'name': 'MongoDB', 'category': 'database', 'type': 'mongodb'},
{'name': 'Redis', 'category': 'database', 'type': 'redis'},
{'name': 'Chrome', 'category': 'remote_app', 'type': 'chrome'},
{'name': 'MysqlWorkbench', 'category': 'remote_app', 'type': 'mysql_workbench'},
{'name': 'VmwareClient', 'category': 'remote_app', 'type': 'vmware_client'},
{'name': 'General', 'category': 'remote_app', 'type': 'general_remote_app'},
{'name': 'Kubernetes', 'category': 'cloud', 'type': 'k8s'},
]

View File

@ -8,12 +8,15 @@ from .account import AccountSerializer
class AccountTemplateSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
class Meta:
model = AccountTemplate
fields_mini = ['id', 'privileged', 'username']
fields_mini = ['id', 'privileged', 'username', 'name']
fields_write_only = AccountSerializer.Meta.fields_write_only
fields_other = AccountSerializer.Meta.fields_other
fields = fields_mini + fields_write_only + fields_other
extra_kwargs = AccountSerializer.Meta.extra_kwargs
def validate(self, attrs):
print(attrs)
raise ValueError('test')
attrs = self._validate_gen_key(attrs)
return attrs

View File

@ -75,7 +75,8 @@ class AuthSerializerMixin(serializers.ModelSerializer):
validated_data.pop(field, None)
validated_data.pop('passphrase', None)
def _validate_gen_key(self, attrs):
@staticmethod
def _validate_gen_key(attrs):
private_key = attrs.get('private_key')
if not private_key:
return attrs

View File

@ -10,7 +10,7 @@ def migrate_system_user_to_account(apps, schema_editor):
while True:
connection_tokens = connection_token_model.objects \
.prefetch_related('system_users')[count:bulk_size]
.prefetch_related('system_user')[count:bulk_size]
if not connection_tokens:
break
count += len(connection_tokens)