Added View to render payment page, Added Payment and summary forms, Added Payment.js library to request stripe token , Added jQuery validator for handling payment form errors

This commit is contained in:
Levi 2016-04-22 08:36:38 -05:00
commit 38801abed7
13 changed files with 480 additions and 71 deletions

View file

@ -3,32 +3,32 @@ from django.shortcuts import get_object_or_404, render
from django.core.urlresolvers import reverse_lazy, reverse
from django.views.generic import View, CreateView, FormView
from django.shortcuts import redirect
from django.http import HttpResponseRedirect
from django.contrib.auth import authenticate, login
from django.conf import settings
from membership.forms import PaymentForm
from membership.models import CustomUser
from .models import RailsBetaUser, VirtualMachineType
from .forms import HostingUserSignupForm, HostingUserLoginForm
from .mixins import ProcessVMSelectionMixin
class VMPricingView(View):
template_name = "hosting/pricing.html"
def get(self, request, *args, **kwargs):
return render(request, self.template_name, request)
class DjangoHostingView(View):
class DjangoHostingView(ProcessVMSelectionMixin, View):
template_name = "hosting/django.html"
def get_context_data(self, **kwargs):
context = {}
context["hosting"] = "django"
context["hosting_long"] = "Django"
context["domain"] = "django-hosting.ch"
context["google_analytics"] = "UA-62285904-6"
context["email"] = "info@django-hosting.ch"
context["vm_types"] = VirtualMachineType.get_serialized_vm_types()
context = {
'hosting': "django",
'hosting_long': "Django",
'domain': "django-hosting.ch",
'google_analytics': "UA-62285904-6",
'email': "info@django-hosting.ch",
'vm_types': VirtualMachineType.get_serialized_vm_types(),
}
return context
def get(self, request, *args, **kwargs):
@ -36,17 +36,18 @@ class DjangoHostingView(View):
return render(request, self.template_name, context)
class RailsHostingView(View):
class RailsHostingView(ProcessVMSelectionMixin, View):
template_name = "hosting/rails.html"
def get_context_data(self, **kwargs):
context = {}
context["hosting"] = "rails"
context["hosting_long"] = "Ruby On Rails"
context["domain"] = "rails-hosting.ch"
context["google_analytics"] = "UA-62285904-5"
context["email"] = "info@rails-hosting.ch"
context["vm_types"] = VirtualMachineType.get_serialized_vm_types()
context = {
'hosting': "rails",
'hosting_long': "Ruby On Rails",
'domain': "rails-hosting.ch",
'google_analytics': "UA-62285904-5",
'email': "info@rails-hosting.ch",
'vm_types': VirtualMachineType.get_serialized_vm_types(),
}
return context
def get(self, request, *args, **kwargs):
@ -54,17 +55,18 @@ class RailsHostingView(View):
return render(request, self.template_name, context)
class NodeJSHostingView(View):
class NodeJSHostingView(ProcessVMSelectionMixin, View):
template_name = "hosting/nodejs.html"
def get_context_data(self, **kwargs):
context = {}
context["hosting"] = "nodejs"
context["hosting_long"] = "NodeJS"
context["domain"] = "node-hosting.ch"
context["google_analytics"] = "UA-62285904-7"
context["email"] = "info@node-hosting.ch"
context["vm_types"] = VirtualMachineType.get_serialized_vm_types()
context = {
'hosting': "nodejs",
'hosting_long': "NodeJS",
'domain': "node-hosting.ch",
'google_analytics': "UA-62285904-7",
'email': "info@node-hosting.ch",
'vm_types': VirtualMachineType.get_serialized_vm_types(),
}
return context
def get(self, request, *args, **kwargs):
@ -76,13 +78,14 @@ class IndexView(View):
template_name = "hosting/index.html"
def get_context_data(self, **kwargs):
context = {}
context["hosting"] = "nodejs"
context["hosting_long"] = "NodeJS"
context["domain"] = "node-hosting.ch"
context["google_analytics"] = "UA-62285904-7"
context["email"] = "info@node-hosting.ch"
context["vm_types"] = VirtualMachineType.get_serialized_vm_types()
context = {
'hosting': "nodejs",
'hosting_long': "NodeJS",
'domain': "node-hosting.ch",
'google_analytics': "UA-62285904-7",
'email': "info@node-hosting.ch",
'vm_types': VirtualMachineType.get_serialized_vm_types(),
}
return context
def get(self, request, *args, **kwargs):
@ -124,6 +127,22 @@ class SignupView(CreateView):
return HttpResponseRedirect(self.get_success_url())
class PaymentVMView(FormView):
template_name = 'hosting/payment.html'
form_class = PaymentForm
def get_context_data(self, **kwargs):
context = super(PaymentVMView, self).get_context_data(**kwargs)
context.update({
'stripe_key': settings.STRIPE_API_PUBLIC_KEY
})
return context
# moodel = CustomUser
# def get(self, request, *args, **kwargs):
# return render(request, self.template_name, self.context)
# class RailsBetaUserForm(ModelForm):
# required_css_class = 'form-control'