views fix
This commit is contained in:
parent
111df859dd
commit
9d37e3f58c
1 changed files with 26 additions and 14 deletions
|
@ -79,7 +79,8 @@ class PricingView(TemplateView):
|
||||||
manager = OpenNebulaManager()
|
manager = OpenNebulaManager()
|
||||||
template = manager.get_template(template_id)
|
template = manager.get_template(template_id)
|
||||||
|
|
||||||
request.session['template'] = VirtualMachineTemplateSerializer(template).data
|
request.session['template'] = VirtualMachineTemplateSerializer(
|
||||||
|
template).data
|
||||||
|
|
||||||
if not request.user.is_authenticated():
|
if not request.user.is_authenticated():
|
||||||
request.session['next'] = reverse('hosting:payment')
|
request.session['next'] = reverse('hosting:payment')
|
||||||
|
@ -131,7 +132,8 @@ class BetaAccessView(FormView):
|
||||||
email = BaseEmail(**email_data)
|
email = BaseEmail(**email_data)
|
||||||
email.send()
|
email.send()
|
||||||
|
|
||||||
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
messages.add_message(
|
||||||
|
self.request, messages.SUCCESS, self.success_message)
|
||||||
return render(self.request, 'datacenterlight/beta_success.html', {})
|
return render(self.request, 'datacenterlight/beta_success.html', {})
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,7 +185,8 @@ class BetaProgramView(CreateView):
|
||||||
email = BaseEmail(**email_data)
|
email = BaseEmail(**email_data)
|
||||||
email.send()
|
email.send()
|
||||||
|
|
||||||
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
messages.add_message(
|
||||||
|
self.request, messages.SUCCESS, self.success_message)
|
||||||
return HttpResponseRedirect(self.get_success_url())
|
return HttpResponseRedirect(self.get_success_url())
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,7 +230,8 @@ class IndexView(CreateView):
|
||||||
storage_field = forms.IntegerField(validators=[self.validate_storage])
|
storage_field = forms.IntegerField(validators=[self.validate_storage])
|
||||||
price = request.POST.get('total')
|
price = request.POST.get('total')
|
||||||
template_id = int(request.POST.get('config'))
|
template_id = int(request.POST.get('config'))
|
||||||
template = VMTemplate.objects.filter(opennebula_vm_template_id=template_id).first()
|
template = VMTemplate.objects.filter(
|
||||||
|
opennebula_vm_template_id=template_id).first()
|
||||||
template_data = VMTemplateSerializer(template).data
|
template_data = VMTemplateSerializer(template).data
|
||||||
|
|
||||||
name = request.POST.get('name')
|
name = request.POST.get('name')
|
||||||
|
@ -239,35 +243,40 @@ class IndexView(CreateView):
|
||||||
cores = cores_field.clean(cores)
|
cores = cores_field.clean(cores)
|
||||||
except ValidationError as err:
|
except ValidationError as err:
|
||||||
msg = '{} : {}.'.format(cores, str(err))
|
msg = '{} : {}.'.format(cores, str(err))
|
||||||
messages.add_message(self.request, messages.ERROR, msg, extra_tags='cores')
|
messages.add_message(
|
||||||
|
self.request, messages.ERROR, msg, extra_tags='cores')
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
memory = memory_field.clean(memory)
|
memory = memory_field.clean(memory)
|
||||||
except ValidationError as err:
|
except ValidationError as err:
|
||||||
msg = '{} : {}.'.format(memory, str(err))
|
msg = '{} : {}.'.format(memory, str(err))
|
||||||
messages.add_message(self.request, messages.ERROR, msg, extra_tags='memory')
|
messages.add_message(
|
||||||
|
self.request, messages.ERROR, msg, extra_tags='memory')
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
storage = storage_field.clean(storage)
|
storage = storage_field.clean(storage)
|
||||||
except ValidationError as err:
|
except ValidationError as err:
|
||||||
msg = '{} : {}.'.format(storage, str(err))
|
msg = '{} : {}.'.format(storage, str(err))
|
||||||
messages.add_message(self.request, messages.ERROR, msg, extra_tags='storage')
|
messages.add_message(
|
||||||
|
self.request, messages.ERROR, msg, extra_tags='storage')
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
name = name_field.clean(name)
|
name = name_field.clean(name)
|
||||||
except ValidationError as err:
|
except ValidationError as err:
|
||||||
msg = '{} {}.'.format(name, _('is not a proper name'))
|
msg = '{} {}.'.format(name, _('is not a proper name'))
|
||||||
messages.add_message(self.request, messages.ERROR, msg, extra_tags='name')
|
messages.add_message(
|
||||||
|
self.request, messages.ERROR, msg, extra_tags='name')
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
email = email_field.clean(email)
|
email = email_field.clean(email)
|
||||||
except ValidationError as err:
|
except ValidationError as err:
|
||||||
msg = '{} {}.'.format(email, _('is not a proper email'))
|
msg = '{} {}.'.format(email, _('is not a proper email'))
|
||||||
messages.add_message(self.request, messages.ERROR, msg, extra_tags='email')
|
messages.add_message(
|
||||||
|
self.request, messages.ERROR, msg, extra_tags='email')
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
||||||
|
|
||||||
specs = {
|
specs = {
|
||||||
|
@ -332,7 +341,8 @@ class IndexView(CreateView):
|
||||||
email = BaseEmail(**email_data)
|
email = BaseEmail(**email_data)
|
||||||
email.send()
|
email.send()
|
||||||
|
|
||||||
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
messages.add_message(
|
||||||
|
self.request, messages.SUCCESS, self.success_message)
|
||||||
return super(IndexView, self).form_valid(form)
|
return super(IndexView, self).form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
@ -370,8 +380,8 @@ class PaymentOrderView(FormView):
|
||||||
|
|
||||||
@cache_control(no_cache=True, must_revalidate=True, no_store=True)
|
@cache_control(no_cache=True, must_revalidate=True, no_store=True)
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
# if 'specs' not in request.session or 'user' not in request.session:
|
if 'specs' not in request.session or 'user' not in request.session:
|
||||||
# return HttpResponseRedirect(reverse('datacenterlight:index'))
|
return HttpResponseRedirect(reverse('datacenterlight:index'))
|
||||||
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):
|
||||||
|
@ -425,7 +435,8 @@ class OrderConfirmationView(DetailView):
|
||||||
stripe_customer_id = request.session.get('customer')
|
stripe_customer_id = request.session.get('customer')
|
||||||
customer = StripeCustomer.objects.filter(id=stripe_customer_id).first()
|
customer = StripeCustomer.objects.filter(id=stripe_customer_id).first()
|
||||||
stripe_utils = StripeUtils()
|
stripe_utils = StripeUtils()
|
||||||
card_details = stripe_utils.get_card_details(customer.stripe_id, request.session.get('token'))
|
card_details = stripe_utils.get_card_details(
|
||||||
|
customer.stripe_id, request.session.get('token'))
|
||||||
context = {
|
context = {
|
||||||
'site_url': reverse('datacenterlight:index'),
|
'site_url': reverse('datacenterlight:index'),
|
||||||
'cc_last4': card_details.get('response_object').get('last4'),
|
'cc_last4': card_details.get('response_object').get('last4'),
|
||||||
|
@ -441,7 +452,8 @@ class OrderConfirmationView(DetailView):
|
||||||
customer = StripeCustomer.objects.filter(id=stripe_customer_id).first()
|
customer = StripeCustomer.objects.filter(id=stripe_customer_id).first()
|
||||||
billing_address_data = request.session.get('billing_address_data')
|
billing_address_data = request.session.get('billing_address_data')
|
||||||
billing_address_id = request.session.get('billing_address')
|
billing_address_id = request.session.get('billing_address')
|
||||||
billing_address = BillingAddress.objects.filter(id=billing_address_id).first()
|
billing_address = BillingAddress.objects.filter(
|
||||||
|
id=billing_address_id).first()
|
||||||
vm_template_id = template.get('id', 1)
|
vm_template_id = template.get('id', 1)
|
||||||
final_price = specs.get('price')
|
final_price = specs.get('price')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue