Return error if HostingBill object does not exist

This commit is contained in:
Modulos 2017-05-06 15:16:10 +02:00
parent 673e8a0c79
commit 6f252def5d
2 changed files with 20 additions and 2 deletions

View file

@ -0,0 +1,14 @@
{% extends "hosting/base_short.html" %}
{% load staticfiles bootstrap3 %}
{% load i18n %}
{% block content %}
<div class="container">
<div class="container orders-container">
<h1>Error</h1>
<p> Could not get HostingBill object for client. </p>
<p> Please create a HostingBill object via the admin page </p>
</div>
</div>
{% endblock %}

View file

@ -424,10 +424,14 @@ class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin, DetailV
return HostingBill.objects.filter(customer__id=pk).first()
def get_context_data(self, **kwargs):
# Get User
user_email = self.object.customer.user.email
# Get context
context = super(DetailView, self).get_context_data(**kwargs)
# Get User
try:
user_email = self.object.customer.user.email
except AttributeError:
self.template_name = 'hosting/bill_error.html'
return context
# Add VMs to context
context['vms'] = []