Merge pull request #54 from levivm/feature/vm_pricing

Added redirect urls after signup/login
This commit is contained in:
Levi Velázquez 2016-04-30 13:57:11 -05:00
commit 03ec41b8e2
2 changed files with 14 additions and 9 deletions

View file

@ -16,5 +16,6 @@ class ProcessVMSelectionMixin(object):
request.session['vm_specs'] = vm_specs request.session['vm_specs'] = vm_specs
if not request.user.is_authenticated(): if not request.user.is_authenticated():
request.session['vm_specs'] = vm_specs request.session['vm_specs'] = vm_specs
request.session['next'] = reverse('hosting:payment')
return redirect(reverse('hosting:login')) return redirect(reverse('hosting:login'))
return redirect(reverse('hosting:payment')) return redirect(reverse('hosting:payment'))

View file

@ -110,13 +110,16 @@ class LoginView(FormView):
form_class = HostingUserLoginForm form_class = HostingUserLoginForm
moodel = CustomUser moodel = CustomUser
def get_success_url(self):
next_url = self.request.session.get('next', self.success_url)
return next_url
def form_valid(self, form): def form_valid(self, form):
email = form.cleaned_data.get('email') email = form.cleaned_data.get('email')
password = form.cleaned_data.get('password') password = form.cleaned_data.get('password')
auth_user = authenticate(email=email, password=password) auth_user = authenticate(email=email, password=password)
if auth_user: if auth_user:
login(self.request, auth_user) login(self.request, auth_user)
return HttpResponseRedirect(self.get_success_url()) return HttpResponseRedirect(self.get_success_url())
@ -129,7 +132,8 @@ class SignupView(CreateView):
moodel = CustomUser moodel = CustomUser
def get_success_url(self): def get_success_url(self):
return reverse_lazy('hosting:signup') next_url = self.request.session.get('next', reverse_lazy('hosting:signup'))
return next_url
def form_valid(self, form): def form_valid(self, form):
@ -217,6 +221,7 @@ class PaymentVMView(FormView):
else: else:
return self.form_invalid(form) return self.form_invalid(form)
class InvoiceVMView(LoginRequiredMixin, View): class InvoiceVMView(LoginRequiredMixin, View):
template_name = "hosting/invoice.html" template_name = "hosting/invoice.html"
login_url = reverse_lazy('hosting:login') login_url = reverse_lazy('hosting:login')
@ -242,7 +247,6 @@ class InvoiceVMView(LoginRequiredMixin, View):
} }
return context return context
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
context = self.get_context_data() context = self.get_context_data()