forked from uncloud/uncloud
[uncloud_pay] add "prototype"
This commit is contained in:
parent
c0bf4d96c4
commit
1ca247148c
7 changed files with 157 additions and 0 deletions
55
uncloud/uncloud_pay/views.py
Normal file
55
uncloud/uncloud_pay/views.py
Normal 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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue