fix: sort related assets field when viewing a log

This commit is contained in:
Lance Edgar 2026-05-30 20:37:20 -05:00
parent 8fc9851e21
commit 03dacd9957

View file

@ -667,10 +667,17 @@ class AssetRefsWidget(Widget):
readonly = kw.get("readonly", self.readonly) readonly = kw.get("readonly", self.readonly)
if readonly: if readonly:
assets = [] assets = []
for uuid in cstruct or []: for uuid in cstruct or []:
asset = session.get(model.Asset, uuid) if asset := session.get(model.Asset, uuid):
assets.append( assets.append(asset)
assets.sort(key=lambda asset: asset.asset_name)
html = []
for asset in assets:
html.append(
HTML.tag( HTML.tag(
"li", "li",
c=tags.link_to( c=tags.link_to(
@ -681,7 +688,8 @@ class AssetRefsWidget(Widget):
), ),
) )
) )
return HTML.tag("ul", c=assets)
return HTML.tag("ul", c=html)
values = kw.get("values", self.values) values = kw.get("values", self.values)
if not isinstance(values, sequence_types): if not isinstance(values, sequence_types):