forked from uncloud/uncloud
14 lines
461 B
Python
14 lines
461 B
Python
from django.contrib.auth import get_user_model
|
|
from rest_framework import serializers
|
|
from uncloud_pay.models import get_balance_for_user
|
|
|
|
class UserSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = get_user_model()
|
|
fields = ['username', 'email', 'balance']
|
|
|
|
# Display current 'balance'
|
|
balance = serializers.SerializerMethodField('get_balance')
|
|
|
|
def get_balance(self, user):
|
|
return get_balance_for_user(user)
|