Redirect users to invoice instead of orders

This commit is contained in:
PCoder 2019-04-16 00:15:37 +02:00
commit 6f08a0e7da
2 changed files with 15 additions and 2 deletions

View file

@ -1570,8 +1570,21 @@ class VirtualMachineView(LoginRequiredMixin, View):
'virtual_machine': serializer.data,
'order': HostingOrder.objects.get(
vm_id=serializer.data['vm_id']
)
),
'has_invoices': False
}
try:
bills = []
if hasattr(self.request.user, 'stripecustomer'):
bills = MonthlyHostingBill.objects.filter(
customer=self.request.user.stripecustomer
)
if len(bills) > 0:
context['has_invoices'] = True
except MonthlyHostingBill.DoesNotExist as dne:
logger.error("{}'s monthly hosting bill not imported ?".format(
self.request.user.email
))
except Exception as ex:
logger.debug("Exception generated {}".format(str(ex)))
messages.error(self.request,