1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fix form rendering; enable toggling of redirect to imported object

This commit is contained in:
Jeremy Stretch
2019-09-24 15:58:23 -04:00
parent 5049c6c0a1
commit 15b2a7eab0
3 changed files with 13 additions and 4 deletions

View File

@@ -440,7 +440,15 @@ class ObjectImportView(GetReturnURLMixin, View):
messages.success(request, mark_safe('Imported object: <a href="{}">{}</a>'.format(
obj.get_absolute_url(), obj
)))
return redirect(self.get_return_url(request))
if '_addanother' in request.POST:
return redirect(request.get_full_path())
return_url = form.cleaned_data.get('return_url')
if return_url is not None and is_safe_url(url=return_url, allowed_hosts=request.get_host()):
return redirect(return_url)
else:
return redirect(self.get_return_url(request, obj))
else:
# Replicate model form errors for display