| 
									
										
										
										
											2016-04-22 08:36:38 -05:00
										 |  |  | from django.shortcuts import redirect | 
					
						
							|  |  |  | from django.core.urlresolvers import reverse | 
					
						
							| 
									
										
										
										
											2016-06-30 01:23:14 -05:00
										 |  |  | from .models import VirtualMachinePlan | 
					
						
							| 
									
										
										
										
											2016-04-22 08:36:38 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ProcessVMSelectionMixin(object): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def post(self, request, *args, **kwargs): | 
					
						
							| 
									
										
										
										
											2016-06-30 01:23:14 -05:00
										 |  |  |         hosting = request.POST.get('configuration') | 
					
						
							|  |  |  |         configuration_detail = dict(VirtualMachinePlan.VM_CONFIGURATION).get(hosting) | 
					
						
							| 
									
										
										
										
											2016-04-22 08:36:38 -05:00
										 |  |  |         vm_specs = { | 
					
						
							|  |  |  |             'cores': request.POST.get('cores'), | 
					
						
							|  |  |  |             'memory': request.POST.get('memory'), | 
					
						
							|  |  |  |             'disk_size': request.POST.get('disk_space'), | 
					
						
							|  |  |  |             'hosting_company': request.POST.get('hosting_company'), | 
					
						
							| 
									
										
										
										
											2016-06-07 00:29:22 -05:00
										 |  |  |             'location_code': request.POST.get('location_code'), | 
					
						
							| 
									
										
										
										
											2016-06-30 01:23:14 -05:00
										 |  |  |             'configuration': hosting, | 
					
						
							|  |  |  |             'configuration_detail': configuration_detail, | 
					
						
							| 
									
										
										
										
											2016-04-22 08:36:38 -05:00
										 |  |  |             'final_price': request.POST.get('final_price') | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         request.session['vm_specs'] = vm_specs | 
					
						
							|  |  |  |         if not request.user.is_authenticated(): | 
					
						
							|  |  |  |             request.session['vm_specs'] = vm_specs | 
					
						
							| 
									
										
										
										
											2016-04-30 13:55:55 -05:00
										 |  |  |             request.session['next'] = reverse('hosting:payment') | 
					
						
							| 
									
										
										
										
											2016-04-22 08:36:38 -05:00
										 |  |  |             return redirect(reverse('hosting:login')) | 
					
						
							|  |  |  |         return redirect(reverse('hosting:payment')) |