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

Add option to commit database changes

This commit is contained in:
Jeremy Stretch
2019-08-12 14:28:06 -04:00
parent 3e75da4307
commit 0d289d660d
5 changed files with 38 additions and 11 deletions

View File

@ -387,6 +387,12 @@ class ObjectChangeFilterForm(BootstrapMixin, forms.Form):
#
class ScriptForm(BootstrapMixin, forms.Form):
_commit = forms.BooleanField(
required=False,
initial=True,
label="Commit changes",
help_text="Commit changes to the database (uncheck for a dry-run)"
)
def __init__(self, vars, *args, **kwargs):
@ -395,3 +401,6 @@ class ScriptForm(BootstrapMixin, forms.Form):
# Dynamically populate fields for variables
for name, var in vars.items():
self.fields[name] = var.as_field()
# Move _commit to the end of the form
self.fields.move_to_end('_commit', True)