views: thread ?next= through pre-registration views (fixes #29242)
This commit is contained in:
parent
c39e847d36
commit
29eb8217f8
|
@ -88,7 +88,7 @@ class BaseRegistrationView(FormView):
|
|||
utils.send_registration_mail(self.request, email, next_url=self.next_url,
|
||||
ou=self.ou, **self.token)
|
||||
self.request.session['registered_email'] = email
|
||||
return redirect(self.request, 'registration_complete')
|
||||
return redirect(self.request, 'registration_complete', params={REDIRECT_FIELD_NAME: self.next_url})
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(BaseRegistrationView, self).get_context_data(**kwargs)
|
||||
|
@ -406,8 +406,10 @@ class RegistrationCompleteView(TemplateView):
|
|||
template_name = 'registration/registration_complete.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs['next_url'] = utils.select_next_url(self.request, settings.LOGIN_REDIRECT_URL)
|
||||
return super(RegistrationCompleteView, self).get_context_data(
|
||||
account_activation_days=settings.ACCOUNT_ACTIVATION_DAYS,
|
||||
**kwargs)
|
||||
|
||||
|
||||
registration_complete = RegistrationCompleteView.as_view()
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% url "auth_homepage" as homepage_url %}
|
||||
{% blocktrans with email=request.session.registered_email %}
|
||||
<p>An email was sent to {{ email }}.</p>
|
||||
{% endblocktrans %}
|
||||
|
@ -21,5 +20,5 @@
|
|||
email will be valid during 24 hours.</p>
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
<p><a href="{{ homepage_url }}">{% trans "Back" %}</a></p>
|
||||
<p><a href="{{ next_url }}">{% trans "Back" %}</a></p>
|
||||
{% endblock %}
|
||||
|
|
|
@ -28,8 +28,15 @@ def test_registration(app, db, settings, mailoutbox, external_redirect):
|
|||
response = response.form.submit()
|
||||
|
||||
assert urlparse(response['Location']).path == reverse('registration_complete')
|
||||
if not good_next_url:
|
||||
assert not urlparse(response['Location']).query
|
||||
|
||||
response = response.follow()
|
||||
if good_next_url:
|
||||
assert response.pyquery('a[href="%s"]' % next_url)
|
||||
else:
|
||||
assert response.pyquery('a[href="/"]')
|
||||
|
||||
assert '2 days' in response.content
|
||||
assert 'testbot@entrouvert.com' in response.content
|
||||
assert len(mailoutbox) == 1
|
||||
|
|
Loading…
Reference in New Issue