fix: render links for Plant Type column in Plant Assets grid

This commit is contained in:
Lance Edgar 2026-02-27 17:23:49 -06:00
parent 0d989dcb2c
commit bdda586ccd

View file

@ -23,6 +23,8 @@
Master view for Plants Master view for Plants
""" """
from webhelpers2.html import tags
from wuttaweb.forms.schema import WuttaDictEnum from wuttaweb.forms.schema import WuttaDictEnum
from wuttafarm.db.model import PlantType, PlantAsset from wuttafarm.db.model import PlantType, PlantAsset
@ -172,10 +174,20 @@ class PlantAssetView(AssetMasterView):
super().configure_grid(g) super().configure_grid(g)
# plant_types # plant_types
g.set_renderer("plant_types", self.render_grid_plant_types) g.set_renderer("plant_types", self.render_plant_types_for_grid)
def render_grid_plant_types(self, plant, field, value): def render_plant_types_for_grid(self, plant, field, value):
return ", ".join([t.plant_type.name for t in plant._plant_types]) plant_types = plant._plant_types
if self.farmos_style_grid_links:
links = []
for plant_type in plant_types:
plant_type = plant_type.plant_type
url = self.request.route_url("plant_types.view", uuid=plant_type.uuid)
links.append(tags.link_to(str(plant_type), url))
return ", ".join(links)
return ", ".join([str(pt.plant_type) for pt in plant_types])
def configure_form(self, form): def configure_form(self, form):
f = form f = form