feat: Add Households to Mealie (#3970)

This commit is contained in:
Michael Genson
2024-08-22 10:14:32 -05:00
committed by GitHub
parent 0c29cef17d
commit eb170cc7e5
315 changed files with 6975 additions and 3577 deletions

View File

@@ -1,6 +1,5 @@
import contextlib
from pathlib import Path
from uuid import UUID
from pydantic import UUID4
@@ -42,7 +41,8 @@ class BaseMigrator(BaseService):
db: AllRepositories,
session,
user_id: UUID4,
group_id: UUID,
household_id: UUID4,
group_id: UUID4,
add_migration_tag: bool,
translator: Translator,
):
@@ -56,11 +56,16 @@ class BaseMigrator(BaseService):
if not user:
raise UnexpectedNone(f"Cannot find user {user_id}")
household = db.households.get_one(household_id)
if not household:
raise UnexpectedNone(f"Cannot find household {household_id}")
group = db.groups.get_one(group_id)
if not group:
raise UnexpectedNone(f"Cannot find group {group_id}")
self.user = user
self.household = household
self.group = group
self.name = "migration"
@@ -69,8 +74,8 @@ class BaseMigrator(BaseService):
self.logger = root_logger.get_logger()
self.helpers = DatabaseMigrationHelpers(self.db, self.session, self.group.id, self.user.id)
self.recipe_service = RecipeService(db, user, group, translator=self.translator)
self.helpers = DatabaseMigrationHelpers(self.db, self.session)
self.recipe_service = RecipeService(db, user, household, translator=self.translator)
super().__init__()
@@ -163,16 +168,16 @@ class BaseMigrator(BaseService):
return_vars: list[tuple[str, UUID4, bool]] = []
if not self.group.preferences:
raise ValueError("Group preferences not found")
if not self.household.preferences:
raise ValueError("Household preferences not found")
default_settings = RecipeSettings(
public=self.group.preferences.recipe_public,
show_nutrition=self.group.preferences.recipe_show_nutrition,
show_assets=self.group.preferences.recipe_show_assets,
landscape_view=self.group.preferences.recipe_landscape_view,
disable_comments=self.group.preferences.recipe_disable_comments,
disable_amount=self.group.preferences.recipe_disable_amount,
public=self.household.preferences.recipe_public,
show_nutrition=self.household.preferences.recipe_show_nutrition,
show_assets=self.household.preferences.recipe_show_assets,
landscape_view=self.household.preferences.recipe_landscape_view,
disable_comments=self.household.preferences.recipe_disable_comments,
disable_amount=self.household.preferences.recipe_disable_amount,
)
for recipe in validated_recipes: