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

Fixes #816: Redirect back to parent prefix view after deleting child prefixes

This commit is contained in:
Jeremy Stretch
2017-01-24 09:50:51 -05:00
parent 2d9c33c34f
commit ed8fdd9292
3 changed files with 4 additions and 3 deletions

View File

@ -437,6 +437,7 @@ def prefix(request, pk):
'parent_prefix_table': parent_prefix_table,
'child_prefix_table': child_prefix_table,
'duplicate_prefix_table': duplicate_prefix_table,
'return_url': prefix.get_absolute_url(),
})

View File

@ -3,7 +3,7 @@
{% if table.model|user_can_change:request.user or table.model|user_can_delete:request.user %}
<form method="post" class="form form-horizontal">
{% csrf_token %}
<input type="hidden" name="return_url" value="{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" />
<input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
{% if table.paginator.num_pages > 1 %}
<div id="select_all_box" class="hidden panel panel-default">
<div class="panel-body">

View File

@ -3,7 +3,7 @@ from django_tables2 import RequestConfig
from django.contrib import messages
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.db import transaction, IntegrityError
from django.db.models import ProtectedError
@ -590,7 +590,7 @@ class BulkDeleteView(View):
return redirect(return_url)
else:
form = form_cls(initial={'pk': pk_list})
form = form_cls(initial={'pk': pk_list, 'return_url': return_url})
selected_objects = self.cls.objects.filter(pk__in=pk_list)
if not selected_objects: