Return error page if HostingBill is None
This commit is contained in:
parent
f871bb2aba
commit
b4ec750728
1 changed files with 10 additions and 2 deletions
|
@ -510,10 +510,18 @@ class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin, DetailV
|
|||
def get_object(self, queryset=None):
|
||||
#Get HostingBill for primary key (Select from customer users)
|
||||
pk = self.kwargs['pk']
|
||||
return HostingBill.objects.filter(customer__id=pk).first()
|
||||
object = HostingBill.objects.filter(customer__id=pk).first()
|
||||
if object is None:
|
||||
self.template_name = 'hosting/bill_error.html'
|
||||
return object
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
# Get context
|
||||
context = super(DetailView, self).get_context_data(**kwargs)
|
||||
# Get vms
|
||||
try:
|
||||
context['vms'] = self.get_object().get_vms()
|
||||
except:
|
||||
pass
|
||||
|
||||
return context
|
||||
|
|
Loading…
Reference in a new issue