utils: allow overriding REDIRECT_FIELD_NAME in select_next_url() (#32140)
A view can have different next_url depending on its final state (cancel, ok, etc..)
This commit is contained in:
parent
279788672a
commit
16aa682aa1
|
@ -889,9 +889,10 @@ def good_next_url(request, next_url):
|
|||
return False
|
||||
|
||||
|
||||
def get_next_url(params):
|
||||
def get_next_url(params, field_name=None):
|
||||
field_name = field_name or REDIRECT_FIELD_NAME
|
||||
'''Extract and decode a next_url field'''
|
||||
next_url = params.get(REDIRECT_FIELD_NAME)
|
||||
next_url = params.get(field_name)
|
||||
if not next_url:
|
||||
return None
|
||||
try:
|
||||
|
@ -903,9 +904,9 @@ def get_next_url(params):
|
|||
return next_url
|
||||
|
||||
|
||||
def select_next_url(request, default, include_post=False):
|
||||
def select_next_url(request, default, field_name=None, include_post=False, replace=None):
|
||||
'''Select the first valid next URL'''
|
||||
next_url = (include_post and get_next_url(request.POST)) or get_next_url(request.GET)
|
||||
next_url = (include_post and get_next_url(request.POST, field_name=field_name)) or get_next_url(request.GET, field_name=field_name)
|
||||
if good_next_url(request, next_url):
|
||||
return next_url
|
||||
return default
|
||||
|
|
Loading…
Reference in New Issue