Fixed a bug related to redirection to incorrect url on change of language. Still hardcoded (probably need a refactor of this)

This commit is contained in:
M.Ravi 2017-06-06 04:22:03 +05:30
parent 92fb72197d
commit 474e0ddc95
2 changed files with 8 additions and 66 deletions

View file

@ -76,14 +76,14 @@
<select class="selectpicker" data-width="fit" onchange="location = this.value;" style="margin-top:10px;">
{% if LANGUAGE_CODE == 'en-us'%}
<option selected="selected" value="{{base_url}}/en-us/datacenterlight/pricing-success/">English</option>
<option selected="selected" value="{{base_url}}/en-us/datacenterlight/order-success/">English</option>
{% else %}
<option value="{{base_url}}/en-us/datacenterlight/pricing-success/">English</option>
<option value="{{base_url}}/en-us/datacenterlight/order-success/">English</option>
{% endif %}
{% if LANGUAGE_CODE == 'de'%}
<option selected="selected" value="{{base_url}}/de/datacenterlight/pricing-success/">Deutsch</option>
<option selected="selected" value="{{base_url}}/de/datacenterlight/order-success/">Deutsch</option>
{% else %}
<option value="{{base_url}}/de/datacenterlight/pricing-success/">Deutsch</option>
<option value="{{base_url}}/de/datacenterlight/order-success/">Deutsch</option>
{% endif %}
</select>

View file

@ -60,24 +60,14 @@ class PricingView(TemplateView):
try:
name = name_field.clean(name)
except ValidationError as err:
messages.error( request,
'%(value) is not a proper name.'.format(name)
)
context = {
'error' : 'name'
}
return render(request, self.template_name, context)
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper name.'.format(name))
return reverse('datacenterlight:order')
try:
email = email_field.clean(email)
except ValidationError as err:
messages.error( request,
'%(value) is not a proper email.'.format(email)
)
context = {
'error' : 'email'
}
return render(request, self.template_name, context)
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper email.'.format(email))
return reverse('datacenterlight:order')
# We have valid email and name of the customer, hence send an
# email to the admin
@ -103,54 +93,6 @@ class PricingView(TemplateView):
return render(self.request, 'datacenterlight/success.html', {})
class OrderView(TemplateView):
template_name = "datacenterlight/order.html"
def get(self, request, *args, **kwargs):
try:
manager = OpenNebulaManager()
templates = manager.get_templates()
context = {
'templates': VirtualMachineTemplateSerializer(templates, many=True).data,
}
except:
messages.error( request,
'We could not load the VM templates due to a backend connection \
error. Please try again in a few minutes'
)
context = {
'error' : 'connection'
}
return render(request, self.template_name, context)
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'))
class BetaAccessView(FormView):
template_name = "datacenterlight/beta_access.html"