Fakultas Ilmu Komputer UI

Commit f52a6b29 authored by inez nabila's avatar inez nabila
Browse files

Merge branch 'coldfix-pbi9' into 'staging'

changed the fields in serializers

See merge request ppl-fasilkom-ui/itproject-2020/group-b/pilar-backend!91
parents 168482af 9fa68ac2
......@@ -156,8 +156,6 @@ class ReportProgramDonationSerializer(serializers.Serializer): # pylint: disable
class UserSerializer(serializers.ModelSerializer):
total_transactions = serializers.SerializerMethodField('get_total_transactions')
total_program_donations = serializers.SerializerMethodField('get_total_program_donations')
class Meta:
extra_kwargs = {'password': {'write_only': True}}
......@@ -173,20 +171,13 @@ class UserSerializer(serializers.ModelSerializer):
'urban_village',
'sub_district',
'profile_picture',
'total_transactions',
'total_program_donations',
'number_of_transactions',
'number_of_cash_donations',
'number_of_goods_donations',
]
model = models.User
read_only_fields = ['id']
def get_total_transactions(self, obj): # pylint: disable=no-self-use
total_transactions = obj.transactions.count()
return total_transactions
def get_total_program_donations(self, obj): # pylint: disable=no-self-use
total_program_donations = obj.program_donations.count()
return total_program_donations
def create(self, validated_data):
password = validated_data.pop('password', None)
instance = self.Meta.model(**validated_data)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment