diff --git a/src/wuttafarm/web/views/plants.py b/src/wuttafarm/web/views/plants.py index 4a343a6..cd6cb34 100644 --- a/src/wuttafarm/web/views/plants.py +++ b/src/wuttafarm/web/views/plants.py @@ -23,6 +23,8 @@ Master view for Plants """ +from webhelpers2.html import tags + from wuttaweb.forms.schema import WuttaDictEnum from wuttafarm.db.model import PlantType, PlantAsset @@ -172,10 +174,20 @@ class PlantAssetView(AssetMasterView): super().configure_grid(g) # 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): - return ", ".join([t.plant_type.name for t in plant._plant_types]) + def render_plant_types_for_grid(self, plant, field, value): + 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): f = form