mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
change tool -> tools
This commit is contained in:
parent
bfcfeb525d
commit
99ee0f8840
3 changed files with 5 additions and 20 deletions
|
@ -1,7 +1,5 @@
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
import sqlalchemy.orm as orm
|
import sqlalchemy.orm as orm
|
||||||
from fastapi.logger import logger
|
|
||||||
from mealie.core.config import settings
|
|
||||||
from mealie.db.models.model_base import BaseMixins, SqlAlchemyBase
|
from mealie.db.models.model_base import BaseMixins, SqlAlchemyBase
|
||||||
from mealie.db.models.recipe.category import Category, group2categories
|
from mealie.db.models.recipe.category import Category, group2categories
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
@ -61,13 +59,3 @@ class Group(SqlAlchemyBase, BaseMixins):
|
||||||
if item is None:
|
if item is None:
|
||||||
item = session.query(Group).filter(Group.id == 1).one()
|
item = session.query(Group).filter(Group.id == 1).one()
|
||||||
return item
|
return item
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def create_if_not_exist(session, name: str = settings.DEFAULT_GROUP):
|
|
||||||
result = session.query(Group).filter(Group.name == name).one_or_none()
|
|
||||||
if result:
|
|
||||||
logger.info("Group exists, associating recipe")
|
|
||||||
return result
|
|
||||||
else:
|
|
||||||
logger.info("Group doesn't exists, creating tag")
|
|
||||||
return Group(name=name)
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
|
||||||
cookTime = sa.Column(sa.String)
|
cookTime = sa.Column(sa.String)
|
||||||
recipeYield = sa.Column(sa.String)
|
recipeYield = sa.Column(sa.String)
|
||||||
recipeCuisine = sa.Column(sa.String)
|
recipeCuisine = sa.Column(sa.String)
|
||||||
tool: List[Tool] = orm.relationship("Tool", cascade="all, delete-orphan")
|
tools: List[Tool] = orm.relationship("Tool", cascade="all, delete-orphan")
|
||||||
nutrition: Nutrition = orm.relationship("Nutrition", uselist=False, cascade="all, delete-orphan")
|
nutrition: Nutrition = orm.relationship("Nutrition", uselist=False, cascade="all, delete-orphan")
|
||||||
recipeCategory: List = orm.relationship("Category", secondary=recipes2categories, back_populates="recipes")
|
recipeCategory: List = orm.relationship("Category", secondary=recipes2categories, back_populates="recipes")
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
|
||||||
totalTime: str = None,
|
totalTime: str = None,
|
||||||
prepTime: str = None,
|
prepTime: str = None,
|
||||||
nutrition: dict = None,
|
nutrition: dict = None,
|
||||||
tool: list[str] = [],
|
tools: list[str] = [],
|
||||||
performTime: str = None,
|
performTime: str = None,
|
||||||
slug: str = None,
|
slug: str = None,
|
||||||
recipeCategory: List[str] = None,
|
recipeCategory: List[str] = None,
|
||||||
|
@ -97,7 +97,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
|
||||||
else:
|
else:
|
||||||
self.nutrition = Nutrition()
|
self.nutrition = Nutrition()
|
||||||
|
|
||||||
self.tool = [Tool(tool=x) for x in tool] if tool else []
|
self.tools = [Tool(tool=x) for x in tools] if tools else []
|
||||||
|
|
||||||
self.recipeYield = recipeYield
|
self.recipeYield = recipeYield
|
||||||
self.recipeIngredient = [RecipeIngredient(ingredient=ingr) for ingr in recipeIngredient]
|
self.recipeIngredient = [RecipeIngredient(ingredient=ingr) for ingr in recipeIngredient]
|
||||||
|
@ -131,7 +131,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
|
||||||
recipeInstructions: List[dict] = None,
|
recipeInstructions: List[dict] = None,
|
||||||
recipeCuisine: str = None,
|
recipeCuisine: str = None,
|
||||||
totalTime: str = None,
|
totalTime: str = None,
|
||||||
tool: list[str] = [],
|
tools: list[str] = [],
|
||||||
prepTime: str = None,
|
prepTime: str = None,
|
||||||
performTime: str = None,
|
performTime: str = None,
|
||||||
nutrition: dict = None,
|
nutrition: dict = None,
|
||||||
|
@ -159,7 +159,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
|
||||||
prepTime=prepTime,
|
prepTime=prepTime,
|
||||||
performTime=performTime,
|
performTime=performTime,
|
||||||
nutrition=nutrition,
|
nutrition=nutrition,
|
||||||
tool=tool,
|
tools=tools,
|
||||||
slug=slug,
|
slug=slug,
|
||||||
recipeCategory=recipeCategory,
|
recipeCategory=recipeCategory,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
|
|
|
@ -10,6 +10,3 @@ class Tool(SqlAlchemyBase):
|
||||||
|
|
||||||
def __init__(self, tool) -> None:
|
def __init__(self, tool) -> None:
|
||||||
self.tool = tool
|
self.tool = tool
|
||||||
|
|
||||||
def str(self):
|
|
||||||
return self.tool
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue