Skip to content

Commit

Permalink
feat: Seed support for plural units (mealie-recipes#3933)
Browse files Browse the repository at this point in the history
Co-authored-by: Hayden <[email protected]>
  • Loading branch information
2 people authored and boc-the-git committed Sep 28, 2024
1 parent f4b2321 commit 3f92220
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
45 changes: 42 additions & 3 deletions mealie/repos/seed/resources/units/locales/en-US.json
Original file line number Diff line number Diff line change
@@ -1,102 +1,141 @@
{
"teaspoon": {
"name": "teaspoon",
"plural_name": "teaspoons",
"description": "",
"abbreviation": "tsp"
},
"tablespoon": {
"name": "tablespoon",
"plural_name": "tablespoons",
"description": "",
"abbreviation": "tbsp"
},
"cup": {
"name": "cup",
"plural_name": "cups",
"description": "",
"abbreviation": "cup"
"abbreviation": "c"
},
"fluid-ounce": {
"name": "fluid ounce",
"plural_name": "fluid ounces",
"description": "",
"abbreviation": "fl oz"
},
"pint": {
"name": "pint",
"plural_name": "pints",
"description": "",
"abbreviation": "pt"
},
"quart": {
"name": "quart",
"plural_name": "quarts",
"description": "",
"abbreviation": "qt"
},
"gallon": {
"name": "gallon",
"plural_name": "gallons",
"description": "",
"abbreviation": "gal"
},
"milliliter": {
"name": "milliliter",
"plural_name": "milliliters",
"description": "",
"abbreviation": "ml"
},
"liter": {
"name": "liter",
"plural_name": "liters",
"description": "",
"abbreviation": "l"
},
"pound": {
"name": "pound",
"plural_name": "pounds",
"description": "",
"abbreviation": "lb"
"abbreviation": "lb",
"plural_abbreviation": "lbs"
},
"ounce": {
"name": "ounce",
"plural_name": "ounces",
"description": "",
"abbreviation": "oz"
},
"gram": {
"name": "gram",
"plural_name": "grams",
"description": "",
"abbreviation": "g"
},
"kilogram": {
"name": "kilogram",
"plural_name": "kilograms",
"description": "",
"abbreviation": "kg"
},
"milligram": {
"name": "milligram",
"plural_name": "milligrams",
"description": "",
"abbreviation": "mg"
},
"splash": {
"name": "splash",
"plural_name": "splashes",
"description": "",
"abbreviation": ""
},
"dash": {
"name": "dash",
"plural_name": "dashes",
"description": "",
"abbreviation": ""
},
"serving": {
"name": "serving",
"plural_name": "servings",
"description": "",
"abbreviation": ""
},
"head": {
"name": "head",
"plural_name": "heads",
"description": "",
"abbreviation": ""
},
"clove": {
"name": "clove",
"plural_name": "cloves",
"description": "",
"abbreviation": ""
},
"can": {
"name": "can",
"plural_name": "cans",
"description": "",
"abbreviation": ""
},
"bunch": {
"name": "bunch",
"plural_name": "bunches",
"description": "",
"abbreviation": ""
},
"pack": {
"name": "pack",
"plural_name": "packs",
"description": "",
"abbreviation": ""
},
"pinch": {
"name": "pinch",
"plural_name": "pinches",
"description": "",
"abbreviation": ""
}
}
}
2 changes: 2 additions & 0 deletions mealie/repos/seed/seeders.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def load_data(self, locale: str | None = None) -> Generator[SaveIngredientUnit,
yield SaveIngredientUnit(
group_id=self.group_id,
name=unit["name"],
plural_name=unit.get("plural_name"),
description=unit["description"],
abbreviation=unit["abbreviation"],
plural_abbreviation=unit.get("plural_abbreviation"),
)

def seed(self, locale: str | None = None) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_seed_foods(api_client: TestClient, unique_user: TestUser, database: All


def test_seed_units(api_client: TestClient, unique_user: TestUser, database: AllRepositories):
CREATED_UNITS = 20
CREATED_UNITS = 23

# Check that the foods was created
units = database.ingredient_units.by_group(unique_user.group_id).get_all()
Expand Down

0 comments on commit 3f92220

Please sign in to comment.