Update app.py
This commit is contained in:
17
app.py
17
app.py
@@ -149,6 +149,9 @@ def inject_admin_counts():
|
|||||||
plant_count=plant_count
|
plant_count=plant_count
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def none_if_empty(val):
|
||||||
|
return val if val not in (None, '', 'None') else None
|
||||||
|
|
||||||
# Routes
|
# Routes
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def home():
|
def home():
|
||||||
@@ -528,13 +531,13 @@ def new_plant():
|
|||||||
plant = Plant(
|
plant = Plant(
|
||||||
name=name,
|
name=name,
|
||||||
picture=picture_filename,
|
picture=picture_filename,
|
||||||
climate_id=climate_id,
|
climate_id=none_if_empty(climate_id),
|
||||||
environment_id=environment_id,
|
environment_id=none_if_empty(environment_id),
|
||||||
light_id=light_id,
|
light_id=none_if_empty(light_id),
|
||||||
toxicity_id=toxicity_id,
|
toxicity_id=none_if_empty(toxicity_id),
|
||||||
size_id=size_id,
|
size_id=none_if_empty(size_id),
|
||||||
care_difficulty_id=care_difficulty_id,
|
care_difficulty_id=none_if_empty(care_difficulty_id),
|
||||||
growth_rate_id=growth_rate_id,
|
growth_rate_id=none_if_empty(growth_rate_id),
|
||||||
products=','.join(product_ids),
|
products=','.join(product_ids),
|
||||||
description=description,
|
description=description,
|
||||||
care_guide=care_guide
|
care_guide=care_guide
|
||||||
|
|||||||
Reference in New Issue
Block a user