[uncloud_pay] add "prototype"

This commit is contained in:
Nico Schottelius 2020-02-27 11:21:38 +01:00
commit 1ca247148c
7 changed files with 157 additions and 0 deletions

View file

@ -0,0 +1,55 @@
from django.shortcuts import render
# Create your views here.
# to be implemented
class BalanceViewSet(viewsets.ModelViewSet):
# here we return a number
# number = sum(payments) - sum(bills)
bills = Bills.objects.filter(owner=self.request.user)
payments = Payment.objects.filter(owner=self.request.user)
# sum_paid = sum([ amount for amount payments..,. ]) # you get the picture
# sum_to_be_paid = sum([ amount for amount bills..,. ]) # you get the picture
class Bills(viewset.ModelViewSet):
def unpaid(self, request):
return Bills.objects.filter(owner=self.request.user, paid=False)
serializer_class = BillSerializer
permission_classes = [permissions.IsAuthenticated]
http_method_names = ['get']
def get_queryset(self):
return self.request.user.get_bills()