From 42985c28f17c9eb316e48373252606dbb2dbabeb Mon Sep 17 00:00:00 2001
From: Arvind Tiwari <tiwariav@gmail.com>
Date: Tue, 26 Sep 2017 22:58:56 +0530
Subject: [PATCH] using data.redirect to set redirect path on success

---
 hosting/static/hosting/js/virtual_machine_detail.js | 6 +++---
 hosting/views.py                                    | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/hosting/static/hosting/js/virtual_machine_detail.js b/hosting/static/hosting/js/virtual_machine_detail.js
index ca79df56..01a58127 100644
--- a/hosting/static/hosting/js/virtual_machine_detail.js
+++ b/hosting/static/hosting/js/virtual_machine_detail.js
@@ -93,14 +93,14 @@ $(document).ready(function() {
                     // $('.modal-header > .close').removeClass('hidden');
                     $('#createvm-modal-title').text(data.msg_title);
                     $('#createvm-modal-body').text(data.msg_body);
-                    $('#createvm-modal-done-btn').removeClass('hide');
+                    $('#createvm-modal-done-btn')
+                        .attr('href', data.redirect)
+                        .removeClass('hide');
                 }
             },
             error: function (xmlhttprequest, textstatus, message) {
                     fa_icon = $('.modal-icon > .fa');
                     fa_icon.attr('class', 'fa fa-close');
-                    // $('.modal-header > .close').attr('class', 'close');
-                    // $('.modal-text').addClass('hide');
                     if (typeof(create_vm_error_message) !== 'undefined') {
                         $('#createvm-modal-text').text(create_vm_error_message);
                     }
diff --git a/hosting/views.py b/hosting/views.py
index 183d95c3..1c007780 100644
--- a/hosting/views.py
+++ b/hosting/views.py
@@ -804,6 +804,7 @@ class OrdersHostingDetailView(LoginRequiredMixin,
 
         response = {
             'status': True,
+            'redirect': reverse('hosting:virtual_machines'),
             'msg_title': str(_('Thank you for the order.')),
             'msg_body': str(_('Your VM will be up and running in a few moments.'
                               ' We will send you a confirmation email as soon as'