43 lines
1.0 KiB
Python
43 lines
1.0 KiB
Python
"""Sigl Recipe Domain Model.
|
|
|
|
Simple Grocery List (Sigl) | sigl.app
|
|
Copyright (c) 2023 Asymworks, LLC. All Rights Reserved.
|
|
"""
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import List
|
|
|
|
from .mixins import NotesMixin, TimestampMixin
|
|
from .product import Product
|
|
|
|
__all__ = ('Recipe', 'RecipeEntry')
|
|
|
|
|
|
@dataclass
|
|
class RecipeEntry(NotesMixin, TimestampMixin):
|
|
"""Information about a Product in a Recipe.
|
|
|
|
This class contains information about a Product that is in a recipe
|
|
list, including the quantity to be purchased and notes about the entry.
|
|
"""
|
|
id: int = None
|
|
quantity: str = None
|
|
|
|
# Relationship Fields
|
|
product: Product = None
|
|
recipe: 'Recipe' = None
|
|
|
|
|
|
@dataclass
|
|
class Recipe(NotesMixin, TimestampMixin):
|
|
"""Top-Level Recipe.
|
|
|
|
Contains a collection of `RecipeEntry` items which are intended to be
|
|
added to shopping lists as a group.
|
|
"""
|
|
id: int = None
|
|
name: str = None
|
|
|
|
# Relationship Fields
|
|
entries: List[RecipeEntry] = field(default_factory=list)
|