mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-28 13:05:26 -05:00
feat: timeline event for mealplans (#2050)
* added related user to mealplans * made timeline event message actually optional * added task to create events for mealplan recipes * replaced fk constraint ops with bulk ops * fixed event creation and adjusted query range * indentation is hard * added missing recipe id query filter * added tests
This commit is contained in:
@@ -14,6 +14,7 @@ if TYPE_CHECKING:
|
||||
from group import Group
|
||||
|
||||
from ..recipe import RecipeModel
|
||||
from ..users import User
|
||||
|
||||
|
||||
class GroupMealPlanRules(BaseMixins, SqlAlchemyBase):
|
||||
@@ -47,6 +48,8 @@ class GroupMealPlan(SqlAlchemyBase, BaseMixins):
|
||||
|
||||
group_id: Mapped[GUID | None] = mapped_column(GUID, ForeignKey("groups.id"), index=True)
|
||||
group: Mapped[Optional["Group"]] = orm.relationship("Group", back_populates="mealplans")
|
||||
user_id: Mapped[GUID | None] = mapped_column(GUID, ForeignKey("users.id"), index=True)
|
||||
user: Mapped[Optional["User"]] = orm.relationship("User", back_populates="mealplans")
|
||||
|
||||
recipe_id: Mapped[GUID | None] = mapped_column(GUID, ForeignKey("recipes.id"), index=True)
|
||||
recipe: Mapped[Optional["RecipeModel"]] = orm.relationship(
|
||||
|
||||
@@ -13,6 +13,7 @@ from .user_to_favorite import users_to_favorites
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..group import Group
|
||||
from ..group.mealplan import GroupMealPlan
|
||||
from ..recipe import RecipeComment, RecipeModel, RecipeTimelineEvent
|
||||
from .password_reset import PasswordResetModel
|
||||
|
||||
@@ -68,6 +69,9 @@ class User(SqlAlchemyBase, BaseMixins):
|
||||
owned_recipes: Mapped[Optional["RecipeModel"]] = orm.relationship(
|
||||
"RecipeModel", single_parent=True, foreign_keys=[owned_recipes_id]
|
||||
)
|
||||
mealplans: Mapped[Optional["GroupMealPlan"]] = orm.relationship(
|
||||
"GroupMealPlan", order_by="GroupMealPlan.date", **sp_args
|
||||
)
|
||||
|
||||
favorite_recipes: Mapped[list["RecipeModel"]] = orm.relationship(
|
||||
"RecipeModel", secondary=users_to_favorites, back_populates="favorited_by"
|
||||
|
||||
Reference in New Issue
Block a user