Add forbidden_view method adds the message and redirects to the same path
This commit is contained in:
		
					parent
					
						
							
								9e8d930a3b
							
						
					
				
			
			
				commit
				
					
						167eaf2a0c
					
				
			
		
					 1 changed files with 12 additions and 0 deletions
				
			
		| 
						 | 
					@ -1136,3 +1136,15 @@ class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin,
 | 
				
			||||||
            bill.total_price += vm['price']
 | 
					            bill.total_price += vm['price']
 | 
				
			||||||
        context['vms'] = vms
 | 
					        context['vms'] = vms
 | 
				
			||||||
        return context
 | 
					        return context
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def forbidden_view(request, exception=None, reason=''):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    Handle 403 error
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    logger.error(str(exception) if exception else None)
 | 
				
			||||||
 | 
					    all_messages = messages.get_messages(request)
 | 
				
			||||||
 | 
					    messages.add_message(request, messages.ERROR, reason)
 | 
				
			||||||
 | 
					    return HttpResponseRedirect(
 | 
				
			||||||
 | 
					        request.get_full_path()
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue