fix update user data bug
This commit is contained in:
@@ -101,6 +101,7 @@ class UserViewSet(ModelViewSet):
|
||||
serializer = self.serializer_class(data=request.data)
|
||||
if serializer.is_valid():
|
||||
user = serializer.update(self.queryset.get(id=pk), validated_data=request.data)
|
||||
|
||||
if 'organization' in request.data.keys(): # noqa
|
||||
organization = CustomOperations().custom_update( # update organization for user
|
||||
request=request,
|
||||
|
||||
@@ -97,6 +97,12 @@ class UserSerializer(serializers.ModelSerializer):
|
||||
extra_kwargs = {
|
||||
'password': {
|
||||
'required': False
|
||||
},
|
||||
'username': {
|
||||
'required': False
|
||||
},
|
||||
"national_code": {
|
||||
'required': False
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,15 +110,16 @@ class UserSerializer(serializers.ModelSerializer):
|
||||
""" Custom output """
|
||||
|
||||
representation = super().to_representation(instance)
|
||||
if instance.bank_information.all():
|
||||
representation['bank_account'] = BankAccountSerializer(
|
||||
instance.bank_information.all(), many=True
|
||||
).data
|
||||
if isinstance(instance, User):
|
||||
if instance.bank_information.filter().exists():
|
||||
representation['bank_account'] = BankAccountSerializer(
|
||||
instance.bank_information.all(), many=True
|
||||
).data
|
||||
|
||||
if instance.city:
|
||||
representation['city_name'] = instance.city.name
|
||||
if instance.province:
|
||||
representation['province_name'] = instance.province.name
|
||||
if instance.city:
|
||||
representation['city_name'] = instance.city.name
|
||||
if instance.province:
|
||||
representation['province_name'] = instance.province.name
|
||||
|
||||
return representation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user