Exemple #1
0
    def post(self, request):

        cores = request.POST.get('cpu')
        memory = request.POST.get('ram')
        storage = request.POST.get('storage')
        price = request.POST.get('total')

        template_id = int(request.POST.get('config'))
        manager = OpenNebulaManager()
        template = manager.get_template(template_id)

        request.session['template'] = VirtualMachineTemplateSerializer(
            template).data

        if not request.user.is_authenticated():
            request.session['next'] = reverse('hosting:payment')

        request.session['specs'] = {
            'cpu': cores,
            'memory': memory,
            'disk_size': storage,
            'price': price,
        }

        return redirect(reverse('hosting:payment'))
Exemple #2
0
    def post(self, request):

        cores = request.POST.get('cpu')
        memory = request.POST.get('ram')
        storage = request.POST.get('storage')
        price = request.POST.get('total')

        template_id = int(request.POST.get('config'))

        manager = OpenNebulaManager()
        template = manager.get_template(template_id)

        request.session['template'] = VirtualMachineTemplateSerializer(template).data

        if not request.user.is_authenticated():
            request.session['next'] = reverse('hosting:payment')

        request.session['specs'] = { 
            'cpu':cores,
            'memory': memory,
            'disk_size': storage,
            'price': price,
        }

        return redirect(reverse('hosting:payment'))
Exemple #3
0
    def post(self, request):
        manager = OpenNebulaManager()
        template_id = request.POST.get('vm_template_id')
        template = manager.get_template(template_id)
        configuration_id = int(request.POST.get('configuration'))
        configuration = HostingPlan.objects.get(id=configuration_id)
        request.session['template'] = VirtualMachineTemplateSerializer(
            template).data

        request.session['specs'] = configuration.serialize()
        return redirect(reverse('hosting:payment'))
Exemple #4
0
    def post(self, request):
        manager = OpenNebulaManager()
        template_id = request.POST.get('vm_template_id')
        template = manager.get_template(template_id)
        configuration_id = int(request.POST.get('configuration'))
        configuration = HostingPlan.objects.get(id=configuration_id)
        request.session['template'] = VirtualMachineTemplateSerializer(
            template).data

        request.session['specs'] = configuration.serialize()
        return redirect(reverse('hosting:payment'))
Exemple #5
0
    def post(self, request):
        cores = request.POST.get('cpu')
        memory = request.POST.get('ram')
        storage = request.POST.get('storage')
        price = request.POST.get('total')
        template_id = int(request.POST.get('config'))
        manager = OpenNebulaManager()
        template = manager.get_template(template_id)
        template_data = VirtualMachineTemplateSerializer(template).data

        name = request.POST.get('name')
        email = request.POST.get('email')
        name_field = forms.CharField()
        email_field = forms.EmailField()
        try:
            name = name_field.clean(name)
        except ValidationError as err:
            messages.add_message(self.request, messages.ERROR,
                                 '%(value) is not a proper name.'.format(name))
            return HttpResponseRedirect(reverse('datacenterlight:index'))

        try:
            email = email_field.clean(email)
        except ValidationError as err:
            messages.add_message(
                self.request, messages.ERROR,
                '%(value) is not a proper email.'.format(email))
            return HttpResponseRedirect(reverse('datacenterlight:index'))

        context = {
            'name': name,
            'email': email,
            'cores': cores,
            'memory': memory,
            'storage': storage,
            'price': price,
            'template': template_data['name'],
        }
        email_data = {
            'subject': "Data Center Light Order from %s" % context['email'],
            'from_email':
            '(datacenterlight) datacenterlight Support <*****@*****.**>',
            'to': ['*****@*****.**'],
            'body':
            "\n".join(["%s=%s" % (k, v) for (k, v) in context.items()]),
            'reply_to': [context['email']],
        }
        email = EmailMessage(**email_data)
        email.send()

        return HttpResponseRedirect(reverse('datacenterlight:order_success'))
Exemple #6
0
    def post(self, request):
        cores = request.POST.get('cpu')
        memory = request.POST.get('ram')
        storage = request.POST.get('storage')
        price = request.POST.get('total')
        template_id = int(request.POST.get('config'))
        manager = OpenNebulaManager()
        template = manager.get_template(template_id)
        template_data = VirtualMachineTemplateSerializer(template).data

        name = request.POST.get('name')
        email = request.POST.get('email')
        name_field = forms.CharField()
        email_field = forms.EmailField()
        try:
            name = name_field.clean(name)
        except ValidationError as err:
            msg = '{} {}.'.format(name, _('is not a proper name'))
            messages.add_message(self.request,
                                 messages.ERROR,
                                 msg,
                                 extra_tags='name')
            return HttpResponseRedirect(
                reverse('datacenterlight:index') + "#order_form")

        try:
            email = email_field.clean(email)
        except ValidationError as err:
            msg = '{} {}.'.format(email, _('is not a proper email'))
            messages.add_message(self.request,
                                 messages.ERROR,
                                 msg,
                                 extra_tags='email')
            return HttpResponseRedirect(
                reverse('datacenterlight:index') + "#order_form")

        specs = {
            'cpu': cores,
            'memory': memory,
            'disk_size': storage,
            'price': price
        }

        this_user = {'name': name, 'email': email}

        request.session['specs'] = specs
        request.session['template'] = template_data
        request.session['user'] = this_user
        return HttpResponseRedirect(reverse('datacenterlight:payment'))
Exemple #7
0
    def post(self, request):
        cores = request.POST.get('cpu')
        memory = request.POST.get('ram')
        storage = request.POST.get('storage')
        price = request.POST.get('total')
        template_id = int(request.POST.get('config'))
        manager = OpenNebulaManager()
        template = manager.get_template(template_id)
        template_data = VirtualMachineTemplateSerializer(template).data
        
        name = request.POST.get('name')
        email = request.POST.get('email')
        name_field = forms.CharField()
        email_field = forms.EmailField()
        try:
            name = name_field.clean(name)
        except ValidationError as err:
            messages.add_message(self.request, messages.ERROR, '%(value) is not a proper name.'.format(name))
            return HttpResponseRedirect(reverse('datacenterlight:index'))

        try:    
            email = email_field.clean(email)
        except ValidationError as err:
            messages.add_message(self.request, messages.ERROR, '%(value) is not a proper email.'.format(email))
            return HttpResponseRedirect(reverse('datacenterlight:index'))

        context = {
            'name': name,
            'email': email,
            'cores': cores,
            'memory': memory,
            'storage': storage,
            'price': price,
            'template': template_data['name'],
        }
        email_data = {
            'subject': "Data Center Light Order from %s" % context['email'],
            'from_email': '(datacenterlight) datacenterlight Support <*****@*****.**>',
            'to': ['*****@*****.**'],
            'body': "\n".join(["%s=%s" % (k, v) for (k, v) in context.items()]),
            'reply_to': [context['email']],
        }
        email = EmailMessage(**email_data)
        email.send()        

        return HttpResponseRedirect(reverse('datacenterlight:order_success'))