Skip to content

Commit

Permalink
HA-190 - Update ConsumerSerializer fields
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoMoreta committed Jun 24, 2024
1 parent d5cda9c commit 0ec77e9
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions api/serializers/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@

class ConsumerSerializer(AccountSerializer):

name = serializers.CharField(source='first_name')
surname = serializers.CharField(source='last_name')
nif = serializers.CharField(source='cif')
profile_thumbnail = serializers.CharField(source='profile_image')
name = serializers.StringRelatedField(source='first_name')
surname = serializers.StringRelatedField(source='last_name')
nif = serializers.ReadOnlyField(source='cif')
profile_image = serializers.StringRelatedField(source='profile_image.name')
profile_thumbnail = serializers.StringRelatedField(source='profile_image.name')

class Meta:
model = Consumer
exclude = ["polymorphic_ctype"]

def to_representation(self, instance):
representation = super().to_representation(instance)
if representation['profile_image'] is None:
representation['profile_image'] = ''
return representation

0 comments on commit 0ec77e9

Please sign in to comment.