Skip to content

Commit 39a96dd

Browse files
committed
Fixes #18738: Ensure ScriptList respects script_order option
1 parent be26f86 commit 39a96dd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

netbox/extras/models/scripts.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ def get_absolute_url(self):
117117
def __str__(self):
118118
return self.python_name
119119

120+
@property
121+
def ordered_scripts(self):
122+
script_objects = {s.name: s for s in self.scripts.all()}
123+
ordered = [
124+
script_objects.pop(sc) for sc in self.module_scripts.keys() if sc in script_objects
125+
]
126+
ordered.extend(script_objects.items())
127+
return ordered
128+
120129
@property
121130
def module_scripts(self):
122131

netbox/templates/extras/script_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h2 class="card-header" id="module{{ module.pk }}">
3737
{% endif %}
3838
</div>
3939
</h2>
40-
{% with scripts=module.scripts.all %}
40+
{% with scripts=module.ordered_scripts %}
4141
{% if scripts %}
4242
<table class="table table-hover scripts">
4343
<thead>

0 commit comments

Comments
 (0)