feature/recipe-comments (#448)

* fix favorite color issue

* db and models for comments

* rename files

* initial UI for comments

* fix format

* import / export

* fixes #428

* format

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden
2021-05-29 20:50:17 -08:00
committed by GitHub
parent 6f38fcf81b
commit 2b97af5728
22 changed files with 360 additions and 19 deletions

View File

@@ -129,6 +129,9 @@ def backup_all(
db_export.export_items(all_recipes, "recipes", export_list=False, slug_folder=True)
db_export.export_templates(all_recipes)
all_comments = db.comments.get_all(session)
db_export.export_items(all_comments, "comments")
if export_settings:
all_settings = db.settings.get_all(session)
db_export.export_items(all_settings, "settings")

View File

@@ -6,6 +6,7 @@ from typing import Callable
from mealie.core.config import app_dirs
from mealie.db.database import db
from mealie.schema.comments import CommentOut
from mealie.schema.event_notifications import EventNotificationIn
from mealie.schema.recipe import Recipe
from mealie.schema.restore import (
@@ -85,6 +86,22 @@ class ImportDatabase:
return imports
def import_comments(self):
comment_dir: Path = self.import_dir.joinpath("comments", "comments.json")
comments = ImportDatabase.read_models_file(file_path=comment_dir, model=CommentOut)
for comment in comments:
comment: CommentOut
self.import_model(
db_table=db.comments,
model=comment,
return_model=ThemeImport,
name_attr="uuid",
search_key="uuid",
)
@staticmethod
def _recipe_migration(recipe_dict: dict) -> dict:
if recipe_dict.get("categories", False):
@@ -364,6 +381,9 @@ def import_database(
if import_notifications:
notification_report = import_session.import_notifications()
if import_recipes:
import_session.import_comments()
import_session.clean_up()
return {