diff --git a/docs/customization/custom-scripts.md b/docs/customization/custom-scripts.md index 3811474d2b1..b2112fee7bc 100644 --- a/docs/customization/custom-scripts.md +++ b/docs/customization/custom-scripts.md @@ -42,7 +42,7 @@ Defining script variables is optional: You may create a script with only a `run( Any output generated by the script during its execution will be displayed under the "output" tab in the UI. -By default, scripts within a module are ordered alphabetically in the scripts list page. To return scripts in a specific order, you can define the `script_order` variable at the end of your module. The `script_order` variable is a tuple which contains each Script class in the desired order. Any scripts that are omitted from this list will be listed last. +By default, scripts within a module are ordered alphabetically in the scripts list page. To return scripts in a specific order, you can define the `script_order` variable at the end of your module. The `script_order` variable is a tuple which contains each Script class in the desired order. Any scripts that are omitted from this list will be listed last. To omit scripts from display entirely, define the `script_hide` variable at the end of your module. Scripts listed in this tuple will be ommitted from the unordered script listing. ```python from extras.scripts import Script @@ -54,6 +54,7 @@ class AnotherCustomScript(Script): ... script_order = (MyCustomScript, AnotherCustomScript) +script_hide = (MyHiddenScript,) ``` ## Module Attributes diff --git a/netbox/extras/models/scripts.py b/netbox/extras/models/scripts.py index 122f56f2065..f94b895d9ff 100644 --- a/netbox/extras/models/scripts.py +++ b/netbox/extras/models/scripts.py @@ -67,11 +67,12 @@ def _get_name(cls): scripts = {} ordered = getattr(module, 'script_order', []) + hide = getattr(module, 'script_hide', []) for cls in ordered: scripts[_get_name(cls)] = cls for name, cls in inspect.getmembers(module, is_script): - if cls not in ordered: + if cls not in ordered and cls not in hide: scripts[_get_name(cls)] = cls return scripts