Browse Source

修复migrate bug

pull/8873/head
feng626 2 years ago
parent
commit
97c6e2c0b2
  1. 3
      apps/assets/migrations/0099_auto_20220426_1558.py
  2. 5
      apps/assets/serializers/account_template.py
  3. 3
      apps/assets/serializers/base.py
  4. 2
      apps/authentication/migrations/0012_auto_20220816_1629.py

3
apps/assets/migrations/0099_auto_20220426_1558.py

@ -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'},
]

5
apps/assets/serializers/account_template.py

@ -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

3
apps/assets/serializers/base.py

@ -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

2
apps/authentication/migrations/0012_auto_20220816_1629.py

@ -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)

Loading…
Cancel
Save