Fixes #19990: add optional return_url parameter to "Add" button for missing prerequisites (#20128)

This commit is contained in:
Tomas Neuner 2025-08-20 18:04:00 +02:00 committed by GitHub
parent 9580ac2946
commit db1786c385
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 7 deletions

View File

@ -10,7 +10,7 @@
{% endblocktrans %} {% endblocktrans %}
</div> </div>
<div> <div>
{% add_button prerequisite_model %} {% add_button prerequisite_model request.path %}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,6 +1,6 @@
{% if url %} {% if url %}
{% load i18n %} {% load i18n %}
<a href="{{ url }}" type="button" class="btn btn-primary"> <a href="{{ url }}{% if return_url %}?return_url={{ return_url }}{% endif %}" type="button" class="btn btn-primary">
<i class="mdi mdi-plus-thick"></i> {% trans "Add" %} <i class="mdi mdi-plus-thick"></i> {% trans "Add" %}
</a> </a>
{% endif %} {% endif %}

View File

@ -146,7 +146,7 @@ def sync_button(instance):
# #
@register.inclusion_tag('buttons/add.html') @register.inclusion_tag('buttons/add.html')
def add_button(model, action='add'): def add_button(model, return_url=None, action='add'):
try: try:
url = reverse(get_viewname(model, action)) url = reverse(get_viewname(model, action))
except NoReverseMatch: except NoReverseMatch:
@ -154,6 +154,7 @@ def add_button(model, action='add'):
return { return {
'url': url, 'url': url,
'return_url': return_url,
} }