Return error if HostingBill object does not exist
This commit is contained in:
		
					parent
					
						
							
								673e8a0c79
							
						
					
				
			
			
				commit
				
					
						6f252def5d
					
				
			
		
					 2 changed files with 20 additions and 2 deletions
				
			
		
							
								
								
									
										14
									
								
								hosting/templates/hosting/bill_error.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								hosting/templates/hosting/bill_error.html
									
										
									
									
									
										Normal 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 %} | ||||||
|  | 			 | ||||||
|  | @ -424,10 +424,14 @@ class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin, DetailV | ||||||
|         return HostingBill.objects.filter(customer__id=pk).first() |         return HostingBill.objects.filter(customer__id=pk).first() | ||||||
| 
 | 
 | ||||||
|     def get_context_data(self, **kwargs): |     def get_context_data(self, **kwargs): | ||||||
|         # Get User |  | ||||||
|         user_email = self.object.customer.user.email |  | ||||||
|         # Get context |         # Get context | ||||||
|         context = super(DetailView, self).get_context_data(**kwargs) |         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 |         # Add VMs to context | ||||||
|         context['vms'] = [] |         context['vms'] = [] | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue