2016-04-22 13:36:38 +00:00
|
|
|
from django.shortcuts import redirect
|
|
|
|
from django.core.urlresolvers import reverse
|
|
|
|
|
2017-05-13 05:31:29 +00:00
|
|
|
from opennebula_api.serializers import VirtualMachineTemplateSerializer
|
|
|
|
from opennebula_api.models import OpenNebulaManager
|
|
|
|
|
2016-04-22 13:36:38 +00:00
|
|
|
|
|
|
|
class ProcessVMSelectionMixin(object):
|
|
|
|
|
|
|
|
def post(self, request, *args, **kwargs):
|
2017-05-13 05:31:29 +00:00
|
|
|
|
|
|
|
template_id = int(request.POST.get('vm_template_id'))
|
|
|
|
template = OpenNebulaManager().get_template(template_id)
|
|
|
|
data = VirtualMachineTemplateSerializer(template).data
|
|
|
|
request.session['template'] = data
|
|
|
|
|
2016-04-22 13:36:38 +00:00
|
|
|
if not request.user.is_authenticated():
|
2016-04-30 18:55:55 +00:00
|
|
|
request.session['next'] = reverse('hosting:payment')
|
2016-04-22 13:36:38 +00:00
|
|
|
return redirect(reverse('hosting:login'))
|
|
|
|
return redirect(reverse('hosting:payment'))
|