forked from uncloud/uncloud
++dev
This commit is contained in:
parent
caedf874e4
commit
8bbcc5df5f
3 changed files with 24 additions and 3 deletions
|
@ -57,7 +57,7 @@ router.register(r'v1/admin/vpnreservation', netviews.VPNNetworkReservationViewSe
|
|||
|
||||
|
||||
# Pay
|
||||
router.register(r'v1/my/address', payviews.BillingAddressViewSet, basename='address')
|
||||
router.register(r'v1/my/address', payviews.BillingAddressViewSet, basename='billingaddress')
|
||||
router.register(r'v1/my/bill', payviews.BillViewSet, basename='bill')
|
||||
router.register(r'v1/my/order', payviews.OrderViewSet, basename='order')
|
||||
router.register(r'v1/my/payment', payviews.PaymentViewSet, basename='payment')
|
||||
|
|
|
@ -8,6 +8,7 @@ from django.core.exceptions import ValidationError
|
|||
from .views import *
|
||||
from .models import *
|
||||
|
||||
from uncloud_pay.models import BillingAddress, Order
|
||||
|
||||
class VPNTests(TestCase):
|
||||
def setUp(self):
|
||||
|
@ -61,12 +62,19 @@ class VPNTests(TestCase):
|
|||
})
|
||||
force_authenticate(request, user=self.user)
|
||||
|
||||
# we don't have a billing address
|
||||
# we don't have a billing address -> raises error
|
||||
with self.assertRaises(ValidationError):
|
||||
response = view(request)
|
||||
|
||||
ba = BillingAddress.objects.create(owner=self.user)
|
||||
|
||||
# This should work now
|
||||
response = view(request)
|
||||
|
||||
# Verify that an order was created successfully - there should only be one order at
|
||||
# this point in time
|
||||
order = Order.objects.get(owner=self.user)
|
||||
|
||||
#print(response)
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
|
|
|
@ -623,10 +623,23 @@ class Order(models.Model):
|
|||
blank=True,
|
||||
null=True)
|
||||
|
||||
def active_before(self, ending_date):
|
||||
# Was this order started before the specified ending date?
|
||||
if self.starting_date <= ending_date:
|
||||
if self.ending_date:
|
||||
if self.ending_date > ending_date:
|
||||
|
||||
@property
|
||||
def is_recurring(self):
|
||||
return not self.recurring_period == RecurringPeriod.ONE_TIME
|
||||
|
||||
@property
|
||||
def is_terminated(self):
|
||||
return self.ending_date != None and self.ending_date < timezone.now()
|
||||
|
||||
def is_terminated_at(self, a_date):
|
||||
return self.ending_date != None and self.ending_date < timezone.now()
|
||||
|
||||
def terminate(self):
|
||||
if not self.is_terminated:
|
||||
self.ending_date = timezone.now()
|
||||
|
|
Loading…
Reference in a new issue