added redirect after create vm ssh key
This commit is contained in:
parent
c59fcd4b16
commit
ee80181a55
3 changed files with 24 additions and 10 deletions
|
@ -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,
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
</script>
|
||||
{%endif%}
|
||||
|
||||
|
||||
{{next_url}}
|
||||
{% if next_url %}
|
||||
<script type="text/javascript">
|
||||
window.location.href = '{{next_url}}';
|
||||
|
|
|
@ -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'
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue