mirror of https://github.com/jumpserver/jumpserver
perf: add default logo handling in IntegrationApplicationSerializer
parent
20070e0647
commit
8b9fe3c72b
|
@ -1,3 +1,4 @@
|
||||||
|
from django.templatetags.static import static
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
@ -27,13 +28,14 @@ class IntegrationApplicationSerializer(BulkOrgResourceModelSerializer):
|
||||||
'name': {'label': _('Name')},
|
'name': {'label': _('Name')},
|
||||||
'accounts_amount': {'label': _('Accounts amount')},
|
'accounts_amount': {'label': _('Accounts amount')},
|
||||||
'is_active': {'default': True},
|
'is_active': {'default': True},
|
||||||
|
'logo': {'required': False},
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def to_representation(self, instance):
|
||||||
super().__init__(*args, **kwargs)
|
data = super().to_representation(instance)
|
||||||
request_method = self.context.get('request').method
|
if not data.get('logo'):
|
||||||
if request_method == 'PUT':
|
data['logo'] = static('img/logo.png')
|
||||||
self.fields['logo'].required = False
|
return data
|
||||||
|
|
||||||
|
|
||||||
class IntegrationAccountSecretSerializer(serializers.Serializer):
|
class IntegrationAccountSecretSerializer(serializers.Serializer):
|
||||||
|
|
Loading…
Reference in New Issue