Coverage for opt/mealie/lib/python3.12/site-packages/mealie/db/models/recipe/instruction.py: 96%
27 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-11-25 15:48 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-11-25 15:48 +0000
1from pydantic import ConfigDict 1a
2from sqlalchemy import ForeignKey, Integer, String, orm 1a
3from sqlalchemy.orm import Mapped, mapped_column 1a
5from .._model_base import BaseMixins, SqlAlchemyBase 1a
6from .._model_utils.auto_init import auto_init 1a
7from .._model_utils.guid import GUID 1a
10class RecipeIngredientRefLink(SqlAlchemyBase, BaseMixins): 1a
11 __tablename__ = "recipe_ingredient_ref_link" 1a
12 instruction_id: Mapped[GUID | None] = mapped_column(GUID, ForeignKey("recipe_instructions.id"), index=True) 1a
13 reference_id: Mapped[GUID | None] = mapped_column(GUID, index=True) 1a
15 @auto_init() 1a
16 def __init__(self, **_) -> None: 1a
17 pass
20class RecipeInstruction(SqlAlchemyBase): 1a
21 __tablename__ = "recipe_instructions" 1a
22 id: Mapped[GUID] = mapped_column(GUID, primary_key=True, default=GUID.generate) 1a
23 recipe_id: Mapped[GUID | None] = mapped_column(GUID, ForeignKey("recipes.id"), index=True) 1a
24 position: Mapped[int | None] = mapped_column(Integer, index=True) 1a
25 type: Mapped[str | None] = mapped_column(String, default="") 1a
26 title: Mapped[str | None] = mapped_column(String) # This is the section title 1a
27 text: Mapped[str | None] = mapped_column(String) 1a
28 summary: Mapped[str | None] = mapped_column(String) 1a
30 ingredient_references: Mapped[list[RecipeIngredientRefLink]] = orm.relationship( 1a
31 RecipeIngredientRefLink, cascade="all, delete-orphan"
32 )
33 model_config = ConfigDict( 1a
34 exclude={
35 "id",
36 "ingredient_references",
37 }
38 )
40 @auto_init() 1a
41 def __init__(self, ingredient_references, session, **_) -> None: 1a
42 self.ingredient_references = [RecipeIngredientRefLink(**ref, session=session) for ref in ingredient_references] 1bc