Skip to content

Commit db1786c

Browse files
authored
Fixes #19990: add optional return_url parameter to "Add" button for missing prerequisites (#20128)
1 parent 9580ac2 commit db1786c

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

netbox/templates/inc/missing_prerequisites.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{% endblocktrans %}
1111
</div>
1212
<div>
13-
{% add_button prerequisite_model %}
13+
{% add_button prerequisite_model request.path %}
1414
</div>
1515
</div>
1616
</div>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% if url %}
2-
{% load i18n %}
3-
<a href="{{ url }}" type="button" class="btn btn-primary">
4-
<i class="mdi mdi-plus-thick"></i> {% trans "Add" %}
5-
</a>
6-
{% endif %}
2+
{% load i18n %}
3+
<a href="{{ url }}{% if return_url %}?return_url={{ return_url }}{% endif %}" type="button" class="btn btn-primary">
4+
<i class="mdi mdi-plus-thick"></i> {% trans "Add" %}
5+
</a>
6+
{% endif %}

netbox/utilities/templatetags/buttons.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,15 @@ def sync_button(instance):
146146
#
147147

148148
@register.inclusion_tag('buttons/add.html')
149-
def add_button(model, action='add'):
149+
def add_button(model, return_url=None, action='add'):
150150
try:
151151
url = reverse(get_viewname(model, action))
152152
except NoReverseMatch:
153153
url = None
154154

155155
return {
156156
'url': url,
157+
'return_url': return_url,
157158
}
158159

159160

0 commit comments

Comments
 (0)