mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-26 09:43:19 -05:00
don't overwrite user-provided standardization data
This commit is contained in:
@@ -44,6 +44,11 @@ class RepositoryUnit(GroupRepositoryGeneric[IngredientUnit, IngredientUnitModel]
|
|||||||
if not isinstance(data, dict):
|
if not isinstance(data, dict):
|
||||||
data = data.model_dump()
|
data = data.model_dump()
|
||||||
|
|
||||||
|
# Don't overwrite user data if it exists
|
||||||
|
if data.get("standard_quantity") is not None or data.get("standard_unit") is not None:
|
||||||
|
return data
|
||||||
|
|
||||||
|
# Compare name attrs to translation files and see if there's a match to a known standard unit
|
||||||
for prop in ["name", "plural_name", "abbreviation", "plural_abbreviation"]:
|
for prop in ["name", "plural_name", "abbreviation", "plural_abbreviation"]:
|
||||||
val = data.get(prop)
|
val = data.get(prop)
|
||||||
if not (val and isinstance(val, str)):
|
if not (val and isinstance(val, str)):
|
||||||
|
|||||||
Reference in New Issue
Block a user