From 57311eda7314fb4342547d1f6c197fab4d264039 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Tue, 12 Dec 2017 12:14:39 +0100 Subject: [PATCH] Improve debug logs --- hosting/views.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 6c3461b4..c04bcf30 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -671,20 +671,28 @@ class OrdersHostingDetailView(LoginRequiredMixin, model = HostingOrder def get_object(self, queryset=None): - logger.debug("Within OrdersHostingDetailView get_object") - try: - hosting_order_obj = HostingOrder.objects.get( - pk=self.kwargs.get('pk') + order_id = self.kwargs.get('pk') + logger.debug( + "Within OrdersHostingDetailView get_object {order_id}".format( + order_id=order_id ) - logger.debug("Found HostingOrder obj") + ) + try: + hosting_order_obj = HostingOrder.objects.get(pk=order_id) + logger.debug("Found HostingOrder for id {order_id}".format( + order_id=order_id + )) except HostingOrder.DoesNotExist: - logger.debug("HostingOrder obj not found") + logger.debug("HostingOrder not found for id {order_id}".format( + order_id=order_id + )) hosting_order_obj = None if not self.request.user.has_perm(hosting_order_obj): logger.debug( - "User {user} has no perm on HostingOrder {order}".format( - user=self.request.email, - order=hosting_order_obj.id if hosting_order_obj else 'None' + "User {user} does not have permission on HostingOrder " + "{order_id}. Raising 404 error now.".format( + user=self.request.user.email, + order_id=order_id if hosting_order_obj else 'None' ) ) raise Http404