Merge pull request #273 from levivm/develop

Develop
This commit is contained in:
Levi Velázquez 2017-05-24 11:10:30 -05:00 committed by GitHub
commit 4c5cbe5bd9
3 changed files with 23 additions and 10 deletions

View file

@ -51,6 +51,9 @@ class PricingView(TemplateView):
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,

View file

@ -112,7 +112,6 @@
</script>
{%endif%}
{% if next_url %}
<script type="text/javascript">
window.location.href = '{{next_url}}';

View file

@ -319,12 +319,22 @@ class GenerateVMSSHKeysView(LoginRequiredMixin, FormView):
form.save()
context = self.get_context_data()
next_url = self.request.session.get(
'next',
reverse('hosting:create_virtual_machine')
)
if 'next' in self.request.session:
context.update({
'next_url': next_url
})
del (self.request.session['next'])
if form.cleaned_data.get('private_key'):
context.update({
'private_key': form.cleaned_data.get('private_key'),
'key_name': form.cleaned_data.get('name'),
'form': UserHostingKeyForm(request=self.request),
'next_url': reverse('hosting:create_virtual_machine')
})
# return HttpResponseRedirect(reverse('hosting:key_pair'))
@ -391,9 +401,6 @@ class PaymentVMView(LoginRequiredMixin, FormView):
return context
def get(self, request, *args, **kwargs):
if 'next' in request.session:
del request.session['next']
try:
UserHostingKey.objects.get(
user=self.request.user
@ -405,6 +412,9 @@ class PaymentVMView(LoginRequiredMixin, FormView):
)
return HttpResponseRedirect(reverse('hosting:key_pair'))
if 'next' in request.session:
del request.session['next']
return self.render_to_response(self.get_context_data())
def post(self, request, *args, **kwargs):
@ -631,7 +641,8 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View):
'configuration_options': configuration_options,
}
except:
messages.error( request,
messages.error(
request,
'We could not load the VM templates due to a backend connection \
error. Please try again in a few minutes'
)