From 4883294acf25d35e6d36af182426697d2041975f Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 30 Jul 2017 20:41:11 +0530 Subject: [PATCH 1/2] Added condition to show Confirm Order only when ordering a VM, and Invoice when order details page --- hosting/templates/hosting/order_detail.html | 2 +- hosting/views.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html index 9231bca8..8a5f39f6 100644 --- a/hosting/templates/hosting/order_detail.html +++ b/hosting/templates/hosting/order_detail.html @@ -20,7 +20,7 @@
-

{% trans "Confirm Order"%}

{% trans "Order #"%} {{order.id}}

+

{{page_header_text}}

{% trans "Order #"%} {{order.id}}


diff --git a/hosting/views.py b/hosting/views.py index 520894ae..3c85d6fc 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -600,7 +600,7 @@ class PaymentVMView(LoginRequiredMixin, FormView): email = BaseEmail(**email_data) email.send() - return HttpResponseRedirect(reverse('hosting:orders', kwargs={'pk': order.id})) + return HttpResponseRedirect("{url}?{query_params}".format(url=reverse('hosting:orders', kwargs={'pk': order.id}), query_params='page=payment')) else: return self.form_invalid(form) @@ -619,6 +619,10 @@ class OrdersHostingDetailView(PermissionRequiredMixin, LoginRequiredMixin, Detai owner = self.request.user manager = OpenNebulaManager(email=owner.email, password=owner.password) + if self.request.GET.get('page', '') == 'payment': + context['page_header_text'] = _('Confirm Order') + else: + context['page_header_text'] = _('Invoice') try: vm = manager.get_vm(obj.vm_id) context['vm'] = VirtualMachineSerializer(vm).data From 8ec692e51b8ccc169263ad42ca36233f9e011d54 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Sun, 30 Jul 2017 18:03:16 +0200 Subject: [PATCH 2/2] Reformatted code --- hosting/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 3c85d6fc..f2c3913d 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -32,7 +32,6 @@ from opennebula_api.serializers import VirtualMachineSerializer, \ VirtualMachineTemplateSerializer from django.utils.translation import ugettext_lazy as _ - CONNECTION_ERROR = "Your VMs cannot be displayed at the moment due to a backend \ connection error. please try again in a few minutes." @@ -563,7 +562,7 @@ class PaymentVMView(LoginRequiredMixin, FormView): # Create a Hosting Bill HostingBill.create( - customer=customer, billing_address=billing_address) + customer=customer, billing_address=billing_address) # Create Billing Address for User if he does not have one if not customer.user.billing_addresses.count(): @@ -600,7 +599,9 @@ class PaymentVMView(LoginRequiredMixin, FormView): email = BaseEmail(**email_data) email.send() - return HttpResponseRedirect("{url}?{query_params}".format(url=reverse('hosting:orders', kwargs={'pk': order.id}), query_params='page=payment')) + return HttpResponseRedirect( + "{url}?{query_params}".format(url=reverse('hosting:orders', kwargs={'pk': order.id}), + query_params='page=payment')) else: return self.form_invalid(form)