Added code for proper return when name/email are not good
This commit is contained in:
parent
e4cfcbf618
commit
0c969946f7
1 changed files with 10 additions and 10 deletions
|
@ -12,6 +12,7 @@ from django import forms
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.views.decorators.cache import cache_control
|
from django.views.decorators.cache import cache_control
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from utils.forms import BillingAddressForm, UserBillingAddressForm
|
from utils.forms import BillingAddressForm, UserBillingAddressForm
|
||||||
from utils.models import BillingAddress
|
from utils.models import BillingAddress
|
||||||
from membership.models import StripeCustomer
|
from membership.models import StripeCustomer
|
||||||
|
@ -194,12 +195,9 @@ class IndexView(CreateView):
|
||||||
|
|
||||||
@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' in request.session :
|
for session_var in ['specs', 'user', 'billing_address_data']:
|
||||||
del request.session['specs']
|
if session_var in request.session:
|
||||||
if 'user' in request.session :
|
del request.session[session_var]
|
||||||
del request.session['user']
|
|
||||||
if 'billing_address_data' in request.session :
|
|
||||||
del request.session['billing_address_data']
|
|
||||||
try:
|
try:
|
||||||
manager = OpenNebulaManager()
|
manager = OpenNebulaManager()
|
||||||
templates = manager.get_templates()
|
templates = manager.get_templates()
|
||||||
|
@ -233,14 +231,16 @@ class IndexView(CreateView):
|
||||||
try:
|
try:
|
||||||
name = name_field.clean(name)
|
name = name_field.clean(name)
|
||||||
except ValidationError as err:
|
except ValidationError as err:
|
||||||
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper name.'.format(name))
|
msg='{} {}.'.format(name, _('is not a proper name'))
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:index'))
|
messages.add_message(self.request, messages.ERROR, msg, extra_tags='name')
|
||||||
|
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:
|
||||||
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper email.'.format(email))
|
msg='{} {}.'.format(email, _('is not a proper email'))
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:index'))
|
messages.add_message(self.request, messages.ERROR, msg, extra_tags='email')
|
||||||
|
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
||||||
|
|
||||||
specs = {
|
specs = {
|
||||||
'cpu': cores,
|
'cpu': cores,
|
||||||
|
|
Loading…
Reference in a new issue