diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html index 49f7ba6b..3ee79eaa 100644 --- a/hosting/templates/hosting/order_detail.html +++ b/hosting/templates/hosting/order_detail.html @@ -4,7 +4,7 @@ {% load custom_tags %} {% block content %} - +{{order.pk}}
{% if messages %}
@@ -25,10 +25,10 @@
{% if order %} - {% endif %}

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

+ {% endif %}

{% trans "Invoice Date" %}: @@ -40,18 +40,17 @@

{% if order %} - +

+ {% trans "Status" %}: + + {% if order.status == 'Approved' %} + {% trans "Approved" %} + {% else %} + {% trans "Declined" %} + {% endif %} + +

{% endif %} -

- {% trans "Status" %}: - - {% if order.status == 'Approved' %} - {% trans "Approved" %} - {% else %} - {% trans "Declined" %} - {% endif %} - -


diff --git a/hosting/views.py b/hosting/views.py index cbb2be1f..13b9fd80 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -655,10 +655,13 @@ class OrdersHostingDetailView(LoginRequiredMixin, stripe_customer_id = self.request.session.get('customer') customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() stripe_utils = StripeUtils() - card_details = stripe_utils.get_card_details( - customer.stripe_id, - self.request.session.get('token') - ) + if customer: + card_details = stripe_utils.get_card_details( + customer.stripe_id, + self.request.session.get('token') + ) + else: + card_details = None if self.request.GET.get('page') == 'payment': context['page_header_text'] = _('Confirm Order') @@ -666,6 +669,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, context['page_header_text'] = _('Invoice') if obj is not None: + # invoice for previous order try: manager = OpenNebulaManager( email=owner.email, password=owner.password @@ -686,9 +690,11 @@ class OrdersHostingDetailView(LoginRequiredMixin, 'In order to create a VM, you need to create/upload your SSH KEY first.' ) elif not card_details.get('response_object'): + # new order, failed to get card details context['failed_payment'] = True context['card_details'] = card_details else: + # new order, confirm payment context['site_url'] = reverse('hosting:create_virtual_machine') context['cc_last4'] = card_details.get('response_object').get( 'last4') @@ -698,12 +704,12 @@ class OrdersHostingDetailView(LoginRequiredMixin, return context def get(self, request, *args, **kwargs): - if 'specs' not in self.request.session: - return HttpResponseRedirect( - reverse('hosting:create_virtual_machine') - ) - if 'token' not in self.request.session: - return HttpResponseRedirect(reverse('hosting:payment')) + # if 'specs' not in self.request.session: + # return HttpResponseRedirect( + # reverse('hosting:create_virtual_machine') + # ) + # if 'token' not in self.request.session: + # return HttpResponseRedirect(reverse('hosting:payment')) self.object = self.get_object() context = self.get_context_data(object=self.object) if 'failed_payment' in context: