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,
|
utils.send_registration_mail(self.request, email, next_url=self.next_url,
|
||||||
ou=self.ou, **self.token)
|
ou=self.ou, **self.token)
|
||||||
self.request.session['registered_email'] = email
|
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):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(BaseRegistrationView, self).get_context_data(**kwargs)
|
context = super(BaseRegistrationView, self).get_context_data(**kwargs)
|
||||||
|
@ -406,8 +406,10 @@ class RegistrationCompleteView(TemplateView):
|
||||||
template_name = 'registration/registration_complete.html'
|
template_name = 'registration/registration_complete.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
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(
|
return super(RegistrationCompleteView, self).get_context_data(
|
||||||
account_activation_days=settings.ACCOUNT_ACTIVATION_DAYS,
|
account_activation_days=settings.ACCOUNT_ACTIVATION_DAYS,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
|
|
||||||
registration_complete = RegistrationCompleteView.as_view()
|
registration_complete = RegistrationCompleteView.as_view()
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% url "auth_homepage" as homepage_url %}
|
|
||||||
{% blocktrans with email=request.session.registered_email %}
|
{% blocktrans with email=request.session.registered_email %}
|
||||||
<p>An email was sent to {{ email }}.</p>
|
<p>An email was sent to {{ email }}.</p>
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
|
@ -21,5 +20,5 @@
|
||||||
email will be valid during 24 hours.</p>
|
email will be valid during 24 hours.</p>
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p><a href="{{ homepage_url }}">{% trans "Back" %}</a></p>
|
<p><a href="{{ next_url }}">{% trans "Back" %}</a></p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -28,8 +28,15 @@ def test_registration(app, db, settings, mailoutbox, external_redirect):
|
||||||
response = response.form.submit()
|
response = response.form.submit()
|
||||||
|
|
||||||
assert urlparse(response['Location']).path == reverse('registration_complete')
|
assert urlparse(response['Location']).path == reverse('registration_complete')
|
||||||
|
if not good_next_url:
|
||||||
|
assert not urlparse(response['Location']).query
|
||||||
|
|
||||||
response = response.follow()
|
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 '2 days' in response.content
|
||||||
assert 'testbot@entrouvert.com' in response.content
|
assert 'testbot@entrouvert.com' in response.content
|
||||||
assert len(mailoutbox) == 1
|
assert len(mailoutbox) == 1
|
||||||
|
|
Loading…
Reference in New Issue