manager: replace $UUID pattern in next parameter of UserAddView (fixes #32140)

This commit is contained in:
Benjamin Dauvergne 2019-04-10 12:15:10 +02:00
parent 354a215ab3
commit 52edd31e3f
2 changed files with 8 additions and 3 deletions

View File

@ -140,7 +140,10 @@ class UserAddView(BaseAddView):
return select_next_url(
self.request,
default=reverse('a2-manager-user-detail', kwargs={'pk': self.object.pk}),
include_post=True)
include_post=True,
replace={
'$UUID': self.object.uuid,
})
def get_context_data(self, **kwargs):
context = super(UserAddView, self).get_context_data(**kwargs)

View File

@ -746,7 +746,7 @@ def test_manager_create_user_next(superuser_or_admin, app, ou1):
assert response.pyquery.remove_namespaces()('a.cancel').attr('href') == '../..'
assert response.pyquery.remove_namespaces()('input[name="next"]').attr('value') == next_url
next_url = u'/example.nowhere.null/'
next_url = u'/example.nowhere.null/$UUID/'
cancel_url = u'/example.nowhere.cancel/'
url = u'/manage/users/%s/add/?next=%s&cancel=%s' % (ou1.pk, next_url, cancel_url)
response = app.get(url)
@ -760,7 +760,9 @@ def test_manager_create_user_next(superuser_or_admin, app, ou1):
form.set('email', 'john.doe@gmail.com')
form.set('password1', 'ABcd1234')
form.set('password2', 'ABcd1234')
assert urlparse(form.submit().location).path == next_url
response = form.submit()
user = User.objects.latest('id')
assert urlparse(response.location).path == next_url.replace('$UUID', str(user.uuid))
def test_manager_create_user_next_form_error(superuser_or_admin, app, ou1):