Merge pull request #19015 from netbox-community/18738-script-list-ignoring-script-order

Fixes #18738: Ensure ScriptList respects script_order option
This commit is contained in:
bctiemann 2025-04-01 10:09:39 -04:00 committed by GitHub
commit bad820001d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -117,6 +117,15 @@ class ScriptModule(PythonModuleMixin, JobsMixin, ManagedFile):
def __str__(self):
return self.python_name
@property
def ordered_scripts(self):
script_objects = {s.name: s for s in self.scripts.all()}
ordered = [
script_objects.pop(sc) for sc in self.module_scripts.keys() if sc in script_objects
]
ordered.extend(script_objects.items())
return ordered
@property
def module_scripts(self):

View File

@ -37,7 +37,7 @@
{% endif %}
</div>
</h2>
{% with scripts=module.scripts.all %}
{% with scripts=module.ordered_scripts %}
{% if scripts %}
<table class="table table-hover scripts">
<thead>