manager: accept a cancel_url parameter on UserAddView (#32140)
This commit is contained in:
parent
bddada5acd
commit
354a215ab3
|
@ -144,7 +144,10 @@ class UserAddView(BaseAddView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UserAddView, self).get_context_data(**kwargs)
|
||||
context['cancel_url'] = select_next_url(self.request, default='../..', include_post=True)
|
||||
context['cancel_url'] = select_next_url(
|
||||
self.request,
|
||||
default='../..',
|
||||
field_name='cancel')
|
||||
context['next'] = select_next_url(self.request, default=None, include_post=True)
|
||||
context['ou'] = self.ou
|
||||
return context
|
||||
|
|
|
@ -735,13 +735,24 @@ def test_return_on_logout(superuser, app):
|
|||
|
||||
|
||||
def test_manager_create_user_next(superuser_or_admin, app, ou1):
|
||||
login(app, superuser_or_admin, '/manage/')
|
||||
|
||||
next_url = u'/example.nowhere.null/'
|
||||
url = u'/manage/users/%s/add/?next=%s' % (ou1.pk, next_url)
|
||||
login(app, superuser_or_admin, '/manage/')
|
||||
response = app.get(url)
|
||||
|
||||
# cancel if not handled through form submission
|
||||
assert response.pyquery.remove_namespaces()('a.cancel').attr('href') == next_url
|
||||
# cancel is not handled through form submission, it's a link
|
||||
# next without cancel, no cancel button
|
||||
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/'
|
||||
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)
|
||||
|
||||
assert response.pyquery.remove_namespaces()('a.cancel').attr('href') == cancel_url
|
||||
assert response.pyquery.remove_namespaces()('input[name="next"]').attr('value') == next_url
|
||||
|
||||
form = response.form
|
||||
form.set('first_name', 'John')
|
||||
|
|
Loading…
Reference in New Issue