From ecc26d14e5d6d988a613ca70f98bfa9ce63302d1 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 24 Jun 2019 17:24:35 +0200 Subject: [PATCH] Show previous keys if exist in order confirmation --- .../templates/datacenterlight/order_detail.html | 9 +++++++++ datacenterlight/views.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index fa2ba7ca..1f01c201 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -151,6 +151,15 @@

 {% trans "Add your public SSH key" %}

+
+ {% if keys|length > 0 %} +
Previous keys
+ {% endif %} + {% for key in keys %} + +
+ {% endfor %} + {% for field in form %} {% bootstrap_field field %} {% endfor %} diff --git a/datacenterlight/views.py b/datacenterlight/views.py index f01766d1..7aa6d8a4 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -25,7 +25,7 @@ from utils.forms import ( BillingAddressForm, BillingAddressFormSignup, UserBillingAddressForm, BillingAddress ) -from utils.hosting_utils import get_vm_price_with_vat +from utils.hosting_utils import get_vm_price_with_vat, get_all_public_keys from utils.stripe_utils import StripeUtils from utils.tasks import send_plain_email_task from .cms_models import DCLCalculatorPluginModel @@ -575,6 +575,7 @@ class OrderConfirmationView(DetailView, FormView): context.update({ 'vm': request.session.get('specs'), 'form': UserHostingKeyForm(request=self.request), + 'keys': get_all_public_keys(self.request.user) }) context.update({ 'site_url': reverse('datacenterlight:index'), @@ -607,7 +608,6 @@ class OrderConfirmationView(DetailView, FormView): # We have a valid SSH key from the user, save it in opennebula and db # and proceed further form.save() - user_public_key = form.data["public_key"] if 'token' in request.session: card_details = stripe_utils.get_cards_details_from_token(