fix: 修改playbook 创建的序列类 (#9639)

Co-authored-by: Aaron3S <chenyang@fit2cloud.com>
pull/9640/head
fit2bot 2023-02-20 15:50:43 +08:00 committed by GitHub
parent 90813d7690
commit d334b09fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -16,11 +16,10 @@ def parse_playbook_name(path):
class PlaybookSerializer(BulkOrgResourceModelSerializer):
creator = ReadableHiddenField(default=serializers.CurrentUserDefault())
path = serializers.FileField(required=False)
name = serializers.CharField(label=_('Name'), max_length=128, allow_blank=True, required=False)
def to_internal_value(self, data):
name = data.get('name', False)
if not name:
if not name and data.get('path'):
data['name'] = parse_playbook_name(data['path'].name)
return super().to_internal_value(data)