Compare commits

..

2 commits

2 changed files with 16 additions and 4 deletions

View file

@ -667,10 +667,17 @@ class AssetRefsWidget(Widget):
readonly = kw.get("readonly", self.readonly)
if readonly:
assets = []
for uuid in cstruct or []:
asset = session.get(model.Asset, uuid)
assets.append(
if asset := session.get(model.Asset, uuid):
assets.append(asset)
assets.sort(key=lambda asset: asset.asset_name)
html = []
for asset in assets:
html.append(
HTML.tag(
"li",
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)
if not isinstance(values, sequence_types):

View file

@ -103,6 +103,7 @@ class AssetMasterView(WuttaFarmMasterView):
row_labels = {
"message": "Log Name",
"locations": "Location",
}
row_grid_columns = [
@ -112,7 +113,7 @@ class AssetMasterView(WuttaFarmMasterView):
"message",
"log_type",
"assets",
"location",
"locations",
"quantity",
"is_group_assignment",
]
@ -446,6 +447,9 @@ class AssetMasterView(WuttaFarmMasterView):
# assets
g.set_renderer("assets", self.render_assets_for_grid)
# locations
g.set_renderer("locations", self.render_assets_for_grid)
def render_assets_for_grid(self, log, field, value):
assets = getattr(log, field)