2020-02-27 11:38:04 +00:00
|
|
|
from django.contrib.auth import get_user_model
|
2020-02-27 10:59:28 +00:00
|
|
|
from rest_framework import serializers
|
2020-02-27 11:42:24 +00:00
|
|
|
from .models import Bill, Payment, Order
|
2020-02-27 10:59:28 +00:00
|
|
|
|
|
|
|
class BillSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Bill
|
2020-02-27 11:42:24 +00:00
|
|
|
fields = ['owner', 'amount', 'due_date', 'creation_date',
|
|
|
|
'starting_date', 'ending_date', 'paid']
|
2020-02-27 10:59:28 +00:00
|
|
|
|
|
|
|
class PaymentSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Payment
|
2020-02-27 11:10:26 +00:00
|
|
|
fields = ['owner', 'amount', 'source', 'timestamp']
|
2020-02-27 11:38:04 +00:00
|
|
|
|
2020-02-27 11:42:24 +00:00
|
|
|
class OrderSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Order
|
|
|
|
fields = ['owner', 'creation_date', 'starting_date', 'ending_date',
|
|
|
|
'bill', 'recurring_price', 'one_time_price', 'recurring_period']
|
|
|
|
|
2020-02-27 11:38:04 +00:00
|
|
|
class UserSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = get_user_model()
|
|
|
|
fields = ['username', 'email']
|
|
|
|
|
|
|
|
def get_balance(self, obj):
|
|
|
|
return 666
|