perf: connectiontoken 添加 connect_options file_name_conflict_resolution参数 给koko处理冲冲突文件名 (#11535)

Co-authored-by: feng <1304903146@qq.com>
pull/11519/head^2
fit2bot 1 year ago committed by GitHub
parent 04e341a1bb
commit d7ca1a09d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,6 +24,8 @@ from orgs.mixins.api import RootOrgViewMixin
from perms.models import ActionChoices
from terminal.connect_methods import NativeClient, ConnectMethodUtil
from terminal.models import EndpointRule, Endpoint
from users.const import FileNameConflictResolution
from users.models import Preference
from ..models import ConnectionToken, date_expired_default
from ..serializers import (
ConnectionTokenSerializer, ConnectionTokenSecretSerializer,
@ -310,9 +312,20 @@ class ConnectionTokenViewSet(ExtraActionApiMixin, RootOrgViewMixin, JMSModelView
self.validate_serializer(serializer)
return super().perform_create(serializer)
def _insert_connect_options(self, data):
name = 'file_name_conflict_resolution'
connect_options = data.pop('connect_options', {})
preference = Preference.objects.filter(
name=name, user=self.request.user, category='koko'
).first()
value = preference.value if preference else FileNameConflictResolution.REPLACE
connect_options[name] = value
data['connect_options'] = connect_options
def validate_serializer(self, serializer):
data = serializer.validated_data
user = self.get_user(serializer)
self._insert_connect_options(data)
asset = data.get('asset')
account_name = data.get('account')
_data = self._validate(user, asset, account_name)

Loading…
Cancel
Save