Skip to content

add optional return_url parameter to "Add" button for missing prerequisites #20128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

9er-tom
Copy link
Contributor

@9er-tom 9er-tom commented Aug 19, 2025

Fixes: #19990

add optional return_url parameter to "Add" button, used in missing_prerequisites.html to return user back to initial page after adding an prerequisite object

…erequisites.html to return user back to initial page
@jnovinger jnovinger self-requested a review August 19, 2025 20:13
@jnovinger jnovinger modified the milestone: v4.3.7 Aug 19, 2025
Copy link
Member

@jnovinger jnovinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion on the change to add.html.

Comment on lines 1 to 10
{% if url %}
{% load i18n %}
<a href="{{ url }}" type="button" class="btn btn-primary">
<i class="mdi mdi-plus-thick"></i> {% trans "Add" %}
</a>
{% endif %}
{% load i18n %}
{% if return_url %}
<a href="{{ url }}?return_url={{ return_url }}" type="button" class="btn btn-primary">
{% else %}
<a href="{{ url }}" type="button" class="btn btn-primary">
{% endif %}
<i class="mdi mdi-plus-thick"></i> {% trans "Add" %}
</a>
{% endif %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to avoid repeating ourselves:

Suggested change
{% if url %}
{% load i18n %}
<a href="{{ url }}" type="button" class="btn btn-primary">
<i class="mdi mdi-plus-thick"></i> {% trans "Add" %}
</a>
{% endif %}
{% load i18n %}
{% if return_url %}
<a href="{{ url }}?return_url={{ return_url }}" type="button" class="btn btn-primary">
{% else %}
<a href="{{ url }}" type="button" class="btn btn-primary">
{% endif %}
<i class="mdi mdi-plus-thick"></i> {% trans "Add" %}
</a>
{% endif %}
{% if url %}
{% load i18n %}
<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" %}
</a>
{% endif %}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah of course, makes sense. django templates still feel a bit strange to me.
i commited the fix

@9er-tom 9er-tom requested a review from jnovinger August 20, 2025 07:22
Copy link
Member

@jnovinger jnovinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @9er-tom !

@jnovinger jnovinger merged commit db1786c into netbox-community:main Aug 20, 2025
7 checks passed
@9er-tom 9er-tom deleted the 19990-missing_prerequisite_return_url branch August 21, 2025 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add return_url to Add button for missing prerequisite.
2 participants