hosting view fix
This commit is contained in:
		
					parent
					
						
							
								5d8fb71215
							
						
					
				
			
			
				commit
				
					
						a792911dea
					
				
			
		
					 2 changed files with 28 additions and 23 deletions
				
			
		|  | @ -4,7 +4,7 @@ | |||
| {% load custom_tags %} | ||||
| 
 | ||||
| {% block content %} | ||||
| 
 | ||||
| {{order.pk}} | ||||
| <div id="order-detail{{order.pk}}" class="order-detail-container"> | ||||
|     {% if messages %} | ||||
|         <div class="alert alert-warning"> | ||||
|  | @ -25,10 +25,10 @@ | |||
|         </div> | ||||
|         <div class="order-details"> | ||||
|             {% if order %} | ||||
|             {% endif %} | ||||
|                 <p> | ||||
|                     <strong>{% trans "Order #" %} {{order.id}}</strong> | ||||
|                 </p> | ||||
|             {% endif %} | ||||
|             <p> | ||||
|                 <strong>{% trans "Invoice Date" %}:</strong> | ||||
|                 <span id="order-created_at"> | ||||
|  | @ -40,18 +40,17 @@ | |||
|                 </span> | ||||
|             </p> | ||||
|             {% if order %} | ||||
| 
 | ||||
|                 <p> | ||||
|                     <strong>{% trans "Status" %}: </strong> | ||||
|                     <strong> | ||||
|                         {% if order.status == 'Approved' %} | ||||
|                             <span class="vm-color-online">{% trans "Approved" %}</span> | ||||
|                         {% else %} | ||||
|                             <span class="vm-status-failed">{% trans "Declined" %}</span> | ||||
|                         {% endif %} | ||||
|                     </strong> | ||||
|                 </p> | ||||
|             {% endif %} | ||||
|             <p> | ||||
|                 <strong>{% trans "Status" %}: </strong> | ||||
|                 <strong> | ||||
|                     {% if order.status == 'Approved' %} | ||||
|                         <span class="vm-color-online">{% trans "Approved" %}</span> | ||||
|                     {% else %} | ||||
|                         <span class="vm-status-failed">{% trans "Declined" %}</span> | ||||
|                     {% endif %} | ||||
|                 </strong> | ||||
|             </p> | ||||
|             <hr> | ||||
|             <div> | ||||
|                 <address> | ||||
|  |  | |||
|  | @ -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: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue