From a3c3a5cd2e1bece294cd6b22bdce9e4c1fe544de Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 29 Jun 2017 13:04:13 +0530 Subject: [PATCH 01/13] Changed the way we get info in dcl order_detail template --- .../templates/datacenterlight/order_detail.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index cb412558..c2c15894 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -1,7 +1,8 @@ {% extends "hosting/base_short.html" %} {% load staticfiles bootstrap3 %} {% load i18n %} -{% block content %} +{% load custom_tags %} +{% block content %}
{% if messages %} @@ -27,15 +28,16 @@

{% trans "Billed To:"%}

- {{user.name}}
- {{order.billing_address.street_address}},{{order.billing_address.postal_code}}
- {{order.billing_address.city}}, {{order.billing_address.country}}. + {% with request.session.billing_address_data as billing_address %} + {{request.session.user.name}}
{{billing_address|get_value_from_dict:'street_address'}}, {{billing_address|get_value_from_dict:'postal_code'}}
+ {{billing_address|get_value_from_dict:'city'}}, {{billing_address|get_value_from_dict:'country'}}. + {% endwith %}
{% trans "Date"%}:
- {{order.created_at}}

+ {% now "jS F Y" %}

@@ -45,7 +47,7 @@
{% trans "Payment Method:"%}
{{order.cc_brand}} ending **** {{order.last4}}
- {{user.email}} + {{request.session.user.email}}
From 3313dab485979df7cc9f8fdf95e2a9a977dcdcf0 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 29 Jun 2017 13:05:06 +0530 Subject: [PATCH 02/13] Added get_value_from_dict filter to obtain values from a dict in templates --- datacenterlight/templatetags/custom_tags.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/datacenterlight/templatetags/custom_tags.py b/datacenterlight/templatetags/custom_tags.py index 915e68fe..e7b15b5b 100644 --- a/datacenterlight/templatetags/custom_tags.py +++ b/datacenterlight/templatetags/custom_tags.py @@ -21,4 +21,14 @@ def change_lang(context, lang=None, *args, **kwargs): activate(cur_language) - return "%s" % url \ No newline at end of file + return "%s" % url + +@register.filter('get_value_from_dict') +def get_value_from_dict(dict_data, key): + """ + usage example {{ your_dict|get_value_from_dict:your_key }} + """ + if key: + return dict_data.get(key) + else : + return None From a2153777e45c36307f8a1e9539c82e1521d14b49 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 29 Jun 2017 13:06:05 +0530 Subject: [PATCH 03/13] We do not have order created when in Order Confirmation page. So removed the id parameter in url --- datacenterlight/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datacenterlight/urls.py b/datacenterlight/urls.py index 65401b13..ca844278 100644 --- a/datacenterlight/urls.py +++ b/datacenterlight/urls.py @@ -9,7 +9,7 @@ urlpatterns = [ url(r'^/landing/?$', LandingProgramView.as_view(), name='landing'), url(r'^/pricing/?$', PricingView.as_view(), name='pricing'), url(r'^/payment/?$', PaymentOrderView.as_view(), name='payment'), - url(r'^/order-confirmation/(?P\d+)/?$', OrderConfirmationView.as_view(), name='order_confirmation'), + url(r'^/order-confirmation/?$', OrderConfirmationView.as_view(), name='order_confirmation'), url(r'^/order-success/?$', SuccessView.as_view(), name='order_success'), url(r'^/beta_access?$', BetaAccessView.as_view(), name='beta_access'), ] From cb6aeae1ae1e2a7f7c35cd61ed28ad84f4d9baa1 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 29 Jun 2017 13:08:24 +0530 Subject: [PATCH 04/13] Refactored the logic to OrderConfirmationView from the PaymentOrderView --- datacenterlight/views.py | 227 ++++++++++++++++++++------------------- 1 file changed, 115 insertions(+), 112 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index e4329b89..628d0c03 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -13,11 +13,12 @@ from django.core.exceptions import ValidationError from django.views.decorators.cache import cache_control from django.conf import settings from utils.forms import BillingAddressForm, UserBillingAddressForm +from utils.models import BillingAddress from membership.models import StripeCustomer from hosting.models import HostingOrder, HostingBill from utils.stripe_utils import StripeUtils from datetime import datetime -from membership.models import CustomUser, StripeCustomer +from membership.models import CustomUser, StripeCustomer, CreditCards from opennebula_api.models import OpenNebulaManager from opennebula_api.serializers import VirtualMachineTemplateSerializer, VirtualMachineSerializer @@ -322,13 +323,9 @@ class PaymentOrderView(FormView): if form.is_valid(): # Get billing address data billing_address_data = form.cleaned_data - context = self.get_context_data() - template = request.session.get('template') - specs = request.session.get('specs') - user = request.session.get('user') - vm_template_id = template.get('id', 1) - final_price = specs.get('price') token = form.cleaned_data.get('token') + user = request.session.get('user') + try: custom_user = CustomUser.objects.get(email=user.get('email')) except CustomUser.DoesNotExist: @@ -340,99 +337,20 @@ class PaymentOrderView(FormView): app='dcl', base_url=None, send_email=False) - # Get or create stripe customer customer = StripeCustomer.get_or_create(email=user.get('email'), - token=token) + token=token) if not customer: form.add_error("__all__", "Invalid credit card") return self.render_to_response(self.get_context_data(form=form)) # Create Billing Address billing_address = form.save() - - # Make stripe charge to a customer - stripe_utils = StripeUtils() - charge_response = stripe_utils.make_charge(amount=final_price, - customer=customer.stripe_id) - charge = charge_response.get('response_object') - - # Check if the payment was approved - if not charge: - context.update({ - 'paymentError': charge_response.get('error'), - 'form': form - }) - return render(request, self.template_name, context) - - charge = charge_response.get('response_object') - - # Create OpenNebulaManager - manager = OpenNebulaManager(email=settings.OPENNEBULA_USERNAME, - password=settings.OPENNEBULA_PASSWORD) - - # Create a vm using logged user - vm_id = manager.create_vm( - template_id=vm_template_id, - specs=specs, - vm_name="{email}-{template_name}-{date}".format( - email=user.get('email'), - template_name=template.get('name'), - date=int(datetime.now().strftime("%s"))) - ) - - # Create a Hosting Order - order = HostingOrder.create( - price=final_price, - vm_id=vm_id, - customer=customer, - billing_address=billing_address - ) - - # Create a Hosting Bill - bill = HostingBill.create( - customer=customer, billing_address=billing_address) - - # Create Billing Address for User if he does not have one - if not customer.user.billing_addresses.count(): - billing_address_data.update({ - 'user': customer.user.id - }) - billing_address_user_form = UserBillingAddressForm( - billing_address_data) - billing_address_user_form.is_valid() - billing_address_user_form.save() - - # Associate an order with a stripe payment - order.set_stripe_charge(charge) - - # If the Stripe payment was successed, set order status approved - order.set_approved() - - vm = VirtualMachineSerializer(manager.get_vm(vm_id)).data - - context = { - 'name': user.get('name'), - 'email': user.get('email'), - 'cores': specs.get('cpu'), - 'memory': specs.get('memory'), - 'storage': specs.get('disk_size'), - 'price': specs.get('price'), - 'template': template.get('name'), - 'vm.name': vm['name'], - 'vm.id': vm['vm_id'], - 'order.id': order.id - } - email_data = { - 'subject': "Data Center Light Order from %s" % context['email'], - 'from_email': '(Data Center Light) Data Center Light Support ', - 'to': ['info@ungleich.ch'], - 'body': "\n".join(["%s=%s" % (k, v) for (k, v) in context.items()]), - 'reply_to': [context['email']], - } - email = EmailMessage(**email_data) - email.send() - return HttpResponseRedirect(reverse('datacenterlight:order_confirmation', kwargs={'pk': order.id})) + request.session['billing_address_data'] = billing_address_data + request.session['billing_address'] = billing_address.id + request.session['token'] = token + request.session['customer'] = customer.id + return HttpResponseRedirect(reverse('datacenterlight:order_confirmation')) else: return self.form_invalid(form) @@ -440,25 +358,110 @@ class OrderConfirmationView(DetailView): template_name = "datacenterlight/order_detail.html" context_object_name = "order" model = HostingOrder - def get_context_data(self, **kwargs): - # Get context - context = super(DetailView, self).get_context_data(**kwargs) - obj = self.get_object() + + def get(self, request, *args, **kwargs): + if 'specs' not in request.session or 'user' not in request.session: + return HttpResponseRedirect(reverse('datacenterlight:index')) + print(request.session.get('billing_address_data')) + print(request.session.get('specs')) + stripe_customer_id = request.session.get('customer') + customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() + custom_user = CustomUser.objects.get(email=request.session.get('user').get('email')) + print(custom_user) + obj = CreditCards.objects.filter(user_id=custom_user.id).first() + print(obj) + return render(request, self.template_name, {}) + + def post(self, request, *args, **kwargs): + template = request.session.get('template') + specs = request.session.get('specs') + user = request.session.get('user') + customer = request.session.get('customer') + billing_address_data = request.session.get('billing_address_data') + billing_address_id = request.session.get('billing_address') + billing_address = BillingAddress.objects.filter(id=billing_address_id) + token = request.session.get('token') + vm_template_id = template.get('id', 1) + final_price = specs.get('price') + + # Make stripe charge to a customer + stripe_utils = StripeUtils() + charge_response = stripe_utils.make_charge(amount=final_price, + customer=customer.stripe_id) + charge = charge_response.get('response_object') + + # Check if the payment was approved + if not charge: + context.update({ + 'paymentError': charge_response.get('error'), + 'form': form + }) + return render(request, self.template_name, context) + + charge = charge_response.get('response_object') + + # Create OpenNebulaManager manager = OpenNebulaManager(email=settings.OPENNEBULA_USERNAME, password=settings.OPENNEBULA_PASSWORD) - try: - vm = manager.get_vm(obj.vm_id) - context['vm'] = VirtualMachineSerializer(vm).data - context['next_url'] = reverse('datacenterlight:order_success') - except WrongIdError: - messages.error(self.request, - 'The VM you are looking for is unavailable at the moment. \ - Please contact Data Center Light support.' - ) - self.kwargs['error'] = 'WrongIdError' - context['error'] = 'WrongIdError' - except ConnectionRefusedError: - messages.error(self.request, - 'In order to create a VM, you need to create/upload your SSH KEY first.' - ) - return context + + # Create a vm using logged user + vm_id = manager.create_vm( + template_id=vm_template_id, + specs=specs, + vm_name="{email}-{template_name}-{date}".format( + email=user.get('email'), + template_name=template.get('name'), + date=int(datetime.now().strftime("%s"))) + ) + + # Create a Hosting Order + order = HostingOrder.create( + price=final_price, + vm_id=vm_id, + customer=customer, + billing_address=billing_address + ) + + # Create a Hosting Bill + bill = HostingBill.create( + customer=customer, billing_address=billing_address) + + # Create Billing Address for User if he does not have one + if not customer.user.billing_addresses.count(): + billing_address_data.update({ + 'user': customer.user.id + }) + billing_address_user_form = UserBillingAddressForm( + billing_address_data) + billing_address_user_form.is_valid() + billing_address_user_form.save() + + # Associate an order with a stripe payment + order.set_stripe_charge(charge) + + # If the Stripe payment was successed, set order status approved + order.set_approved() + + vm = VirtualMachineSerializer(manager.get_vm(vm_id)).data + + context = { + 'name': user.get('name'), + 'email': user.get('email'), + 'cores': specs.get('cpu'), + 'memory': specs.get('memory'), + 'storage': specs.get('disk_size'), + 'price': specs.get('price'), + 'template': template.get('name'), + 'vm.name': vm['name'], + 'vm.id': vm['vm_id'], + 'order.id': order.id + } + email_data = { + 'subject': "Data Center Light Order from %s" % context['email'], + 'from_email': '(Data Center Light) Data Center Light Support ', + 'to': ['info@ungleich.ch'], + 'body': "\n".join(["%s=%s" % (k, v) for (k, v) in context.items()]), + 'reply_to': [context['email']], + } + email = EmailMessage(**email_data) + email.send() From d0376f35f8e1ab4f013fc72dd35fa8bb2ca156b5 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 30 Jun 2017 11:05:34 +0530 Subject: [PATCH 05/13] Now getting info in Order Confirmation from session and context --- .../datacenterlight/order_detail.html | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index c2c15894..1c3dd6b7 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -20,20 +20,20 @@ {% if not error %}
-
-

{% trans "Confirm Order"%}

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

-
-
-
-
-
+
+

{% trans "Confirm Order"%}

+
+
+
+
+

{% trans "Billed To:"%}

{% with request.session.billing_address_data as billing_address %} - {{request.session.user.name}}
{{billing_address|get_value_from_dict:'street_address'}}, {{billing_address|get_value_from_dict:'postal_code'}}
+ {{request.session.user.name}}
{{billing_address|get_value_from_dict:'street_address'}}, {{billing_address|get_value_from_dict:'postal_code'}}
{{billing_address|get_value_from_dict:'city'}}, {{billing_address|get_value_from_dict:'country'}}. {% endwith %} -
-
+
+
{% trans "Date"%}:
@@ -41,17 +41,17 @@
-
-
-
-
- {% trans "Payment Method:"%}
- {{order.cc_brand}} ending **** {{order.last4}}
- {{request.session.user.email}} -
-
-
-
+
+
+
+
+ {% trans "Payment Method:"%}
+ {{cc_brand}} ending **** {{cc_last4}}
+ {{request.session.user.email}} +
+
+
+
@@ -59,19 +59,21 @@

{% trans "Order summary"%}


-

{% trans "Cores"%} {{vm.cores}}

-
-

{% trans "Memory"%} {{vm.memory}} GB

-
-

{% trans "Disk space"%} {{vm.disk_size}} GB

-
-

{% trans "Total"%}

{{vm.price}} CHF

+ {% with request.session.specs as vm %} +

{% trans "Cores"%} {{vm.cpu}}

+
+

{% trans "Memory"%} {{vm.memory}} GB

+
+

{% trans "Disk space"%} {{vm.disk_size}} GB

+
+

{% trans "Total"%}

{{vm.price}} CHF

+ {% endwith %}

{% url 'datacenterlight:payment' as payment_url %} {% if payment_url in request.META.HTTP_REFERER %} {% endif %}
From 4c3d8627b161204e4c10e10f8f2f91e051fe2e12 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 30 Jun 2017 11:06:58 +0530 Subject: [PATCH 06/13] Added code to fetch cc data and put in context --- datacenterlight/views.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 628d0c03..8e8858c6 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -362,15 +362,15 @@ class OrderConfirmationView(DetailView): def get(self, request, *args, **kwargs): if 'specs' not in request.session or 'user' not in request.session: return HttpResponseRedirect(reverse('datacenterlight:index')) - print(request.session.get('billing_address_data')) - print(request.session.get('specs')) stripe_customer_id = request.session.get('customer') customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() - custom_user = CustomUser.objects.get(email=request.session.get('user').get('email')) - print(custom_user) - obj = CreditCards.objects.filter(user_id=custom_user.id).first() - print(obj) - return render(request, self.template_name, {}) + stripe_utils = StripeUtils() + card_details = stripe_utils.get_card_details(customer.stripe_id, request.session.get('token')) + context = { + 'cc_last4' : card_details.get('response_object').get('last4'), + 'cc_brand' : card_details.get('response_object').get('brand') + } + return render(request, self.template_name, context) def post(self, request, *args, **kwargs): template = request.session.get('template') From d161a285b8a26b47a3ff70e1bd9bde6e75440d16 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 30 Jun 2017 11:08:00 +0530 Subject: [PATCH 07/13] Added get_card_details function to stripe_utils --- utils/stripe_utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/stripe_utils.py b/utils/stripe_utils.py index 29b45d8e..3b20b708 100644 --- a/utils/stripe_utils.py +++ b/utils/stripe_utils.py @@ -77,6 +77,16 @@ class StripeUtils(object): } return new_card_data + @handleStripeError + def get_card_details(self, customer_id, token): + customer = stripe.Customer.retrieve(customer_id) + credit_card_raw_data = customer.sources.data.pop() + card_details = { + 'last4': credit_card_raw_data.last4, + 'brand': credit_card_raw_data.brand + } + return card_details + def check_customer(self, id, user, token): customers = self.stripe.Customer.all() if not customers.get('data'): From d32d2a89767f338b9daae8fedef6be5bc341b537 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 30 Jun 2017 12:06:41 +0530 Subject: [PATCH 08/13] Added a form in order confirmation page --- datacenterlight/templates/datacenterlight/order_detail.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index 1c3dd6b7..affb8ef5 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -70,12 +70,12 @@ {% endwith %}
- {% url 'datacenterlight:payment' as payment_url %} - {% if payment_url in request.META.HTTP_REFERER %} +
+ {% csrf_token %} - {% endif %} +
{% endif %} From 3eca55a32a89742bb1e0183f42d847a97f0b1420 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 30 Jun 2017 12:08:07 +0530 Subject: [PATCH 09/13] Fixed billing address bug. Fixed back button issues in the new flow --- datacenterlight/views.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 8e8858c6..cd2aa660 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -32,9 +32,14 @@ class SuccessView(TemplateView): def get(self, request, *args, **kwargs): if 'specs' not in request.session or 'user' not in request.session: return HttpResponseRedirect(reverse('datacenterlight:index')) - else : - del request.session['specs'] - del request.session['user'] + elif 'token' not in request.session: + return HttpResponseRedirect(reverse('datacenterlight:payment')) + elif 'order_confirmation' not in request.session: + return HttpResponseRedirect(reverse('datacenterlight:order_confirmation')) + else: + for session_var in ['specs', 'user', 'template', 'billing_address', 'billing_address_data', 'token', 'customer']: + if session_var in request.session: + del request.session[session_var] return render(request, self.template_name) class PricingView(TemplateView): @@ -356,12 +361,16 @@ class PaymentOrderView(FormView): class OrderConfirmationView(DetailView): template_name = "datacenterlight/order_detail.html" + payment_template_name = 'hosting/payment.html' context_object_name = "order" model = HostingOrder - + + @cache_control(no_cache=True, must_revalidate=True, no_store=True) def get(self, request, *args, **kwargs): if 'specs' not in request.session or 'user' not in request.session: return HttpResponseRedirect(reverse('datacenterlight:index')) + if 'token' not in request.session: + return HttpResponseRedirect(reverse('datacenterlight:payment')) stripe_customer_id = request.session.get('customer') customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() stripe_utils = StripeUtils() @@ -371,15 +380,16 @@ class OrderConfirmationView(DetailView): 'cc_brand' : card_details.get('response_object').get('brand') } return render(request, self.template_name, context) - + def post(self, request, *args, **kwargs): template = request.session.get('template') specs = request.session.get('specs') user = request.session.get('user') - customer = request.session.get('customer') + stripe_customer_id = request.session.get('customer') + customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() billing_address_data = request.session.get('billing_address_data') billing_address_id = request.session.get('billing_address') - billing_address = BillingAddress.objects.filter(id=billing_address_id) + billing_address = BillingAddress.objects.filter(id=billing_address_id).first() token = request.session.get('token') vm_template_id = template.get('id', 1) final_price = specs.get('price') @@ -393,10 +403,11 @@ class OrderConfirmationView(DetailView): # Check if the payment was approved if not charge: context.update({ - 'paymentError': charge_response.get('error'), - 'form': form + 'paymentError': charge_response.get('error') + # TODO add logic in payment form to autofill data + #'form': form }) - return render(request, self.template_name, context) + return render(request, self.payment_template_name, context) charge = charge_response.get('response_object') @@ -404,7 +415,7 @@ class OrderConfirmationView(DetailView): manager = OpenNebulaManager(email=settings.OPENNEBULA_USERNAME, password=settings.OPENNEBULA_PASSWORD) - # Create a vm using logged user + # Create a vm using oneadmin, also specify the name vm_id = manager.create_vm( template_id=vm_template_id, specs=specs, @@ -465,3 +476,5 @@ class OrderConfirmationView(DetailView): } email = EmailMessage(**email_data) email.send() + request.session['order_confirmation'] = True + return HttpResponseRedirect(reverse('datacenterlight:order_success')) From 1deeec4c3345c8d35af645bd637a511660990700 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 30 Jun 2017 12:18:31 +0530 Subject: [PATCH 10/13] Added the locale time code to new flow order detail --- .../templates/datacenterlight/order_detail.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index affb8ef5..00aa840f 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -37,7 +37,7 @@
{% trans "Date"%}:
- {% now "jS F Y" %}

+ {% now "Y-m-d H:i" %}

@@ -80,4 +80,16 @@ {% endif %} + + + {%endblock%} From 2350247cdb145dd12d90ce3fb6451a8189308f9a Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 30 Jun 2017 12:27:18 +0530 Subject: [PATCH 11/13] Removed unused code --- datacenterlight/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index cd2aa660..49891730 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -18,7 +18,7 @@ from membership.models import StripeCustomer from hosting.models import HostingOrder, HostingBill from utils.stripe_utils import StripeUtils from datetime import datetime -from membership.models import CustomUser, StripeCustomer, CreditCards +from membership.models import CustomUser, StripeCustomer from opennebula_api.models import OpenNebulaManager from opennebula_api.serializers import VirtualMachineTemplateSerializer, VirtualMachineSerializer @@ -344,7 +344,7 @@ class PaymentOrderView(FormView): # Get or create stripe customer customer = StripeCustomer.get_or_create(email=user.get('email'), - token=token) + token=token) if not customer: form.add_error("__all__", "Invalid credit card") return self.render_to_response(self.get_context_data(form=form)) From 699326dc57275eac4dd6144658a77ea10d6cf867 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 30 Jun 2017 12:33:28 +0530 Subject: [PATCH 12/13] Made to return empty string for the template filter get_value_from_dict instead of None --- datacenterlight/templatetags/custom_tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datacenterlight/templatetags/custom_tags.py b/datacenterlight/templatetags/custom_tags.py index e7b15b5b..ed59af9a 100644 --- a/datacenterlight/templatetags/custom_tags.py +++ b/datacenterlight/templatetags/custom_tags.py @@ -31,4 +31,4 @@ def get_value_from_dict(dict_data, key): if key: return dict_data.get(key) else : - return None + return "" From 160df7685ca22bdeb7e802f2979bf720e7838738 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 30 Jun 2017 12:47:04 +0530 Subject: [PATCH 13/13] Refactored dcl text and support email --- datacenterlight/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 49891730..ffc16eb9 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -468,8 +468,8 @@ class OrderConfirmationView(DetailView): 'order.id': order.id } email_data = { - 'subject': "Data Center Light Order from %s" % context['email'], - 'from_email': '(Data Center Light) Data Center Light Support ', + 'subject': settings.DCL_TEXT + " Order from %s" % context['email'], + 'from_email': settings.DCL_SUPPORT_FROM_ADDRESS, 'to': ['info@ungleich.ch'], 'body': "\n".join(["%s=%s" % (k, v) for (k, v) in context.items()]), 'reply_to': [context['email']],