mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 13:06:30 -06:00
Fix notice when form does not require user input
This commit is contained in:
parent
c562af3a13
commit
9c079ead4c
@ -404,3 +404,10 @@ class ScriptForm(BootstrapMixin, forms.Form):
|
|||||||
|
|
||||||
# Move _commit to the end of the form
|
# Move _commit to the end of the form
|
||||||
self.fields.move_to_end('_commit', True)
|
self.fields.move_to_end('_commit', True)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def requires_input(self):
|
||||||
|
"""
|
||||||
|
A boolean indicating whether the form requires user input (ignore the _commit field).
|
||||||
|
"""
|
||||||
|
return bool(len(self.fields) > 1)
|
||||||
|
@ -74,11 +74,13 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<form action="" method="post" class="form form-horizontal">
|
<form action="" method="post" class="form form-horizontal">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% if form %}
|
{% if not form.requires_input %}
|
||||||
{% render_form form %}
|
<div class="alert alert-info">
|
||||||
{% else %}
|
<i class="fa fa-exclamation-circle"></i>
|
||||||
<p>This script does not require any input to run.</p>
|
This script does not require any input to run.
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% render_form form %}
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<button type="submit" name="_run" class="btn btn-primary"{% if not perms.extras.run_script %} disabled="disabled"{% endif %}><i class="fa fa-play"></i> Run Script</button>
|
<button type="submit" name="_run" class="btn btn-primary"{% if not perms.extras.run_script %} disabled="disabled"{% endif %}><i class="fa fa-play"></i> Run Script</button>
|
||||||
<a href="{% url 'extras:script_list' %}" class="btn btn-default">Cancel</a>
|
<a href="{% url 'extras:script_list' %}" class="btn btn-default">Cancel</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user