fix: render links for Plant Type column in Plant Assets grid
This commit is contained in:
parent
0d989dcb2c
commit
bdda586ccd
1 changed files with 15 additions and 3 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue