lol
This commit is contained in:
15
app.py
15
app.py
@@ -183,8 +183,8 @@ def home():
|
||||
query = query.filter(Plant.growth_rate_id == growth_rate_id)
|
||||
plants = query.order_by(Plant.date_added.desc()).all()
|
||||
|
||||
climates_dict = {c.id: {'name': c.name, 'icon': c.icon} for c in Climate.query.all()}
|
||||
environments_dict = {e.id: {'name': e.name, 'icon': e.icon} for e in Environment.query.all()}
|
||||
climates_dict = {c.id: {'name': c.name, 'icon': c.icon, 'description': c.description} for c in Climate.query.all()}
|
||||
environments_dict = {e.id: {'name': e.name, 'icon': e.icon, 'description': e.description} for e in Environment.query.all()}
|
||||
products_dict = {p.id: p.name for p in Product.query.all()}
|
||||
|
||||
display_plants = []
|
||||
@@ -195,29 +195,36 @@ def home():
|
||||
pid = pid.strip()
|
||||
if pid.isdigit() and int(pid) in products_dict:
|
||||
product_names.append(products_dict[int(pid)])
|
||||
climate_info = climates_dict.get(plant.climate_id, {'name': '', 'icon': None})
|
||||
environment_info = environments_dict.get(plant.environment_id, {'name': '', 'icon': None})
|
||||
climate_info = climates_dict.get(plant.climate_id, {'name': '', 'icon': None, 'description': ''})
|
||||
environment_info = environments_dict.get(plant.environment_id, {'name': '', 'icon': None, 'description': ''})
|
||||
display_plants.append({
|
||||
'id': plant.id,
|
||||
'name': plant.name,
|
||||
'picture': plant.picture,
|
||||
'climate': climate_info['name'],
|
||||
'climate_icon': climate_info['icon'],
|
||||
'climate_description': climate_info['description'],
|
||||
'environment': environment_info['name'],
|
||||
'environment_icon': environment_info['icon'],
|
||||
'environment_description': environment_info['description'],
|
||||
'products': ', '.join(product_names),
|
||||
'description': plant.description,
|
||||
'date_added': plant.date_added,
|
||||
'light': plant.light.name if plant.light else '',
|
||||
'light_icon': plant.light.icon if plant.light and plant.light.icon else None,
|
||||
'light_description': plant.light.description if plant.light else '',
|
||||
'toxicity': plant.toxicity.name if plant.toxicity else '',
|
||||
'toxicity_icon': plant.toxicity.icon if plant.toxicity and plant.toxicity.icon else None,
|
||||
'toxicity_description': plant.toxicity.description if plant.toxicity else '',
|
||||
'size': plant.size.name if plant.size else '',
|
||||
'size_icon': plant.size.icon if plant.size and plant.size.icon else None,
|
||||
'size_description': plant.size.description if plant.size else '',
|
||||
'care_difficulty': plant.care_difficulty.name if plant.care_difficulty else '',
|
||||
'care_difficulty_icon': plant.care_difficulty.icon if plant.care_difficulty and plant.care_difficulty.icon else None,
|
||||
'care_difficulty_description': plant.care_difficulty.description if plant.care_difficulty else '',
|
||||
'growth_rate': plant.growth_rate.name if plant.growth_rate else '',
|
||||
'growth_rate_icon': plant.growth_rate.icon if plant.growth_rate and plant.growth_rate.icon else None,
|
||||
'growth_rate_description': plant.growth_rate.description if plant.growth_rate else '',
|
||||
})
|
||||
|
||||
return render_template('home.html',
|
||||
|
||||
Reference in New Issue
Block a user