commit
				
					
						4c5cbe5bd9
					
				
			
		
					 3 changed files with 23 additions and 10 deletions
				
			
		|  | @ -51,6 +51,9 @@ class PricingView(TemplateView): | ||||||
| 
 | 
 | ||||||
|         request.session['template'] = VirtualMachineTemplateSerializer(template).data |         request.session['template'] = VirtualMachineTemplateSerializer(template).data | ||||||
| 
 | 
 | ||||||
|  |         if not request.user.is_authenticated(): | ||||||
|  |             request.session['next'] = reverse('hosting:payment') | ||||||
|  | 
 | ||||||
|         request.session['specs'] = {  |         request.session['specs'] = {  | ||||||
|             'cpu':cores, |             'cpu':cores, | ||||||
|             'memory': memory, |             'memory': memory, | ||||||
|  |  | ||||||
|  | @ -112,7 +112,6 @@ | ||||||
| </script> | </script> | ||||||
| {%endif%} | {%endif%} | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| {% if next_url %} | {% if next_url %} | ||||||
|     <script type="text/javascript">  |     <script type="text/javascript">  | ||||||
|         window.location.href = '{{next_url}}'; |         window.location.href = '{{next_url}}'; | ||||||
|  |  | ||||||
|  | @ -319,12 +319,22 @@ class GenerateVMSSHKeysView(LoginRequiredMixin, FormView): | ||||||
|         form.save() |         form.save() | ||||||
|         context = self.get_context_data() |         context = self.get_context_data() | ||||||
| 
 | 
 | ||||||
|  |         next_url = self.request.session.get( | ||||||
|  |             'next', | ||||||
|  |             reverse('hosting:create_virtual_machine') | ||||||
|  |         ) | ||||||
|  | 
 | ||||||
|  |         if 'next' in self.request.session: | ||||||
|  |             context.update({ | ||||||
|  |                 'next_url': next_url | ||||||
|  |             }) | ||||||
|  |             del (self.request.session['next']) | ||||||
|  | 
 | ||||||
|         if form.cleaned_data.get('private_key'): |         if form.cleaned_data.get('private_key'): | ||||||
|             context.update({ |             context.update({ | ||||||
|                 'private_key': form.cleaned_data.get('private_key'), |                 'private_key': form.cleaned_data.get('private_key'), | ||||||
|                 'key_name': form.cleaned_data.get('name'), |                 'key_name': form.cleaned_data.get('name'), | ||||||
|                 'form': UserHostingKeyForm(request=self.request), |                 'form': UserHostingKeyForm(request=self.request), | ||||||
|                 'next_url': reverse('hosting:create_virtual_machine') |  | ||||||
|             }) |             }) | ||||||
| 
 | 
 | ||||||
|         # return HttpResponseRedirect(reverse('hosting:key_pair')) |         # return HttpResponseRedirect(reverse('hosting:key_pair')) | ||||||
|  | @ -391,9 +401,6 @@ class PaymentVMView(LoginRequiredMixin, FormView): | ||||||
|         return context |         return context | ||||||
| 
 | 
 | ||||||
|     def get(self, request, *args, **kwargs): |     def get(self, request, *args, **kwargs): | ||||||
|         if 'next' in request.session: |  | ||||||
|             del request.session['next'] |  | ||||||
| 
 |  | ||||||
|         try: |         try: | ||||||
|             UserHostingKey.objects.get( |             UserHostingKey.objects.get( | ||||||
|                 user=self.request.user |                 user=self.request.user | ||||||
|  | @ -405,6 +412,9 @@ class PaymentVMView(LoginRequiredMixin, FormView): | ||||||
|             ) |             ) | ||||||
|             return HttpResponseRedirect(reverse('hosting:key_pair')) |             return HttpResponseRedirect(reverse('hosting:key_pair')) | ||||||
| 
 | 
 | ||||||
|  |         if 'next' in request.session: | ||||||
|  |             del request.session['next'] | ||||||
|  | 
 | ||||||
|         return self.render_to_response(self.get_context_data()) |         return self.render_to_response(self.get_context_data()) | ||||||
| 
 | 
 | ||||||
|     def post(self, request, *args, **kwargs): |     def post(self, request, *args, **kwargs): | ||||||
|  | @ -628,16 +638,17 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): | ||||||
| 
 | 
 | ||||||
|             context = { |             context = { | ||||||
|                 'templates': VirtualMachineTemplateSerializer(templates, many=True).data, |                 'templates': VirtualMachineTemplateSerializer(templates, many=True).data, | ||||||
|                 'configuration_options' : configuration_options, |                 'configuration_options': configuration_options, | ||||||
|             } |             } | ||||||
|         except: |         except: | ||||||
|             messages.error( request, |             messages.error( | ||||||
|  |                 request, | ||||||
|                 'We could not load the VM templates due to a backend connection \ |                 'We could not load the VM templates due to a backend connection \ | ||||||
|                 error. Please try again in a few minutes' |                 error. Please try again in a few minutes' | ||||||
|                 ) |             ) | ||||||
|             context = { |             context = { | ||||||
|                 'error' : 'connection' |                 'error': 'connection' | ||||||
|                     } |             } | ||||||
| 
 | 
 | ||||||
|         return render(request, self.template_name, context) |         return render(request, self.template_name, context) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue