diff --git a/dev/dev-notes.md b/dev/dev-notes.md index a1b0d7108..e7dfbe0d8 100644 --- a/dev/dev-notes.md +++ b/dev/dev-notes.md @@ -16,27 +16,38 @@ Don't forget to [join the Discord](https://discord.gg/R6QDyJgbD2)! # Todo's +Documentation +- [ ] V0.1.0 Release Notes +- [ ] Nextcloud Migration How To +- [ ] New Docker Setup with Sqlite +- [ ] New Roadmap / Milestones + Frontend -- [x] .Vue file reorganized into something that makes sense +- [ ] Prep / Cook / Total Time Indicator + Editor +- [ ] No Meal Today Page instead of Null - [ ] Recipe Print Page -- [x] Catch 400 / bad response on create from URL - [ ] Recipe Editor Data Validation Client Side -- [x] Favicon -- [x] Rename Window -- [x] Add version indicator and notification for new version available -- [ ] Enhanced Search Functionality - [ ] Organize Home Page my Category, ideally user selectable. +- [ ] Advanced Search Page, draft started +- [ ] Search Bar Re-design +- [ ] Replace Backups card with something like Home Assistant +- [ ] Replace import card with something like Home Assistant + - [ ] Select which imports to do Backend -- [x] Add Debug folder for writing the last pulled recipe data to. -- [x] Recipe Editor Data Validation Server Side -- [ ] Normalize Recipe data on scrape +- [ ] Database Import + - [x] Recipes + - [x] Images + - [ ] Meal Plans + - [ ] Settings + - [ ] Themes +- [ ] Remove Print / Debug Code - [ ] Support how to Sections and how to steps -- [ ] Export Markdown on Auto backups - [ ] Recipe request by category/tags -- [ ] Add Additional Migrations, See mealie/services/migrations/chowdown.py for examples of how to do this. - - [ ] Open Eats [See Issue #4](https://github.com/hay-kot/mealie/issues/4) - - [ ] NextCloud [See Issue #14](https://github.com/hay-kot/mealie/issues/14) + + +SQL +- [ ] Setup Database Migrations # Draft Changelog ## v0.0.2 diff --git a/dev/scratch/write_settings.py b/dev/scratch/write_settings.py index 21b897dbc..a76bcd023 100644 --- a/dev/scratch/write_settings.py +++ b/dev/scratch/write_settings.py @@ -37,4 +37,3 @@ if __name__ == "__main__": data = json.dumps(theme) response = requests.post(POST_URL, data) response = requests.get(GET_URL) - print(response.text) diff --git a/mealie/app.py b/mealie/app.py index bc93485f6..739b313be 100644 --- a/mealie/app.py +++ b/mealie/app.py @@ -3,21 +3,13 @@ from fastapi import FastAPI from fastapi.staticfiles import StaticFiles import utils.startup as startup -from routes import ( - backup_routes, - meal_routes, - migration_routes, - recipe_routes, - setting_routes, - static_routes, - user_routes, -) +from routes import (backup_routes, meal_routes, migration_routes, + recipe_routes, setting_routes, static_routes, user_routes) from settings import PORT, PRODUCTION, WEB_PATH, docs_url, redoc_url from utils.api_docs import generate_api_docs from utils.logger import logger startup.pre_start() -# start_scheduler() app = FastAPI( title="Mealie", diff --git a/mealie/data/db/mealie.sqlite b/mealie/data/db/mealie.sqlite index 4547bac4d..825847d36 100644 Binary files a/mealie/data/db/mealie.sqlite and b/mealie/data/db/mealie.sqlite differ diff --git a/mealie/db/db_base.py b/mealie/db/db_base.py index d673fce7d..462ac3ca3 100644 --- a/mealie/db/db_base.py +++ b/mealie/db/db_base.py @@ -146,7 +146,6 @@ class BaseDocument: return BaseDocument._unpack_mongo(new_document) elif USE_SQL: session = self.create_session() - print(document) new_document = self.sql_model(**document) session.add(new_document) return_data = new_document.dict() @@ -161,7 +160,6 @@ class BaseDocument: session, entry = self._query_one(match_value=match_value) entry.update(session=session, **new_data) return_data = entry.dict() - print(entry) session.commit() session.close() diff --git a/mealie/db/sql/_all_models.py b/mealie/db/sql/_all_models.py index e8816de62..c7df3b3be 100644 --- a/mealie/db/sql/_all_models.py +++ b/mealie/db/sql/_all_models.py @@ -1,4 +1,4 @@ from db.sql.meal_models import * from db.sql.recipe_models import * from db.sql.settings_models import * -from db.sql.settings_models import SiteSettingsModel +from db.sql.theme_models import * diff --git a/mealie/db/sql/recipe_models.py b/mealie/db/sql/recipe_models.py index 58b926ccd..f8b7cf65b 100644 --- a/mealie/db/sql/recipe_models.py +++ b/mealie/db/sql/recipe_models.py @@ -5,6 +5,7 @@ from typing import List import sqlalchemy as sa import sqlalchemy.orm as orm from db.sql.model_base import BaseMixins, SqlAlchemyBase +from sqlalchemy.ext.orderinglist import ordering_list class ApiExtras(SqlAlchemyBase): @@ -56,6 +57,7 @@ class Note(SqlAlchemyBase): class RecipeIngredient(SqlAlchemyBase): __tablename__ = "recipes_ingredients" id = sa.Column(sa.Integer, primary_key=True) + position = sa.Column(sa.Integer) parent_id = sa.Column(sa.String, sa.ForeignKey("recipes.id")) ingredient = sa.Column(sa.String) @@ -70,6 +72,7 @@ class RecipeInstruction(SqlAlchemyBase): __tablename__ = "recipe_instructions" id = sa.Column(sa.Integer, primary_key=True) parent_id = sa.Column(sa.String, sa.ForeignKey("recipes.id")) + position = sa.Column(sa.Integer) type = sa.Column(sa.String, default="") text = sa.Column(sa.String) @@ -81,19 +84,31 @@ class RecipeInstruction(SqlAlchemyBase): class RecipeModel(SqlAlchemyBase, BaseMixins): __tablename__ = "recipes" + # Database Specific id = sa.Column(sa.Integer, primary_key=True) + + # General Recipe Properties name = sa.Column(sa.String) description = sa.Column(sa.String) image = sa.Column(sa.String) recipeYield = sa.Column(sa.String) recipeIngredient: List[RecipeIngredient] = orm.relationship( - "RecipeIngredient", cascade="all, delete" + "RecipeIngredient", + cascade="all, delete", + order_by="RecipeIngredient.position", + collection_class=ordering_list("position"), ) recipeInstructions: List[RecipeInstruction] = orm.relationship( "RecipeInstruction", cascade="all, delete", + order_by="RecipeInstruction.position", + collection_class=ordering_list("position"), ) + + # How to Properties totalTime = sa.Column(sa.String) + prepTime = sa.Column(sa.String) + performTime = sa.Column(sa.String) # Mealie Specific slug = sa.Column(sa.String, index=True, unique=True) @@ -123,6 +138,8 @@ class RecipeModel(SqlAlchemyBase, BaseMixins): recipeIngredient: List[str] = None, recipeInstructions: List[dict] = None, totalTime: str = None, + prepTime: str = None, + performTime: str = None, slug: str = None, categories: List[str] = None, tags: List[str] = None, @@ -144,6 +161,8 @@ class RecipeModel(SqlAlchemyBase, BaseMixins): for instruc in recipeInstructions ] self.totalTime = totalTime + self.prepTime = prepTime + self.performTime = performTime # Mealie Specific self.slug = slug @@ -165,6 +184,8 @@ class RecipeModel(SqlAlchemyBase, BaseMixins): recipeIngredient: List[str] = None, recipeInstructions: List[dict] = None, totalTime: str = None, + prepTime: str = None, + performTime: str = None, slug: str = None, categories: List[str] = None, tags: List[str] = None, @@ -175,11 +196,6 @@ class RecipeModel(SqlAlchemyBase, BaseMixins): extras: dict = None, ): """Updated a database entry by removing nested rows and rebuilds the row through the __init__ functions""" - self.name = name - self.description = description - self.image = image - self.recipeYield = recipeYield - list_of_tables = [RecipeIngredient, RecipeInstruction, Category, Tag, ApiExtras] RecipeModel._sql_remove_list(session, list_of_tables, self.id) @@ -191,6 +207,8 @@ class RecipeModel(SqlAlchemyBase, BaseMixins): recipeIngredient=recipeIngredient, recipeInstructions=recipeInstructions, totalTime=totalTime, + prepTime=prepTime, + performTime=performTime, slug=slug, categories=categories, tags=tags, @@ -210,6 +228,8 @@ class RecipeModel(SqlAlchemyBase, BaseMixins): "recipeIngredient": [x.to_str() for x in self.recipeIngredient], "recipeInstructions": [x.dict() for x in self.recipeInstructions], "totalTime": self.totalTime, + "prepTime": self.prepTime, + "performTime": self.performTime, # Mealie "slug": self.slug, "categories": [x.to_str() for x in self.categories], diff --git a/mealie/routes/setting_routes.py b/mealie/routes/setting_routes.py index 169e9205b..db7c6fb73 100644 --- a/mealie/routes/setting_routes.py +++ b/mealie/routes/setting_routes.py @@ -32,7 +32,7 @@ def update_settings(data: SiteSettings): # status_code=400, detail=SnackResponse.error("Unable to Save Settings") # ) - # scheduler.reschedule_webhooks() + scheduler.reschedule_webhooks() return SnackResponse.success("Settings Updated") @@ -81,11 +81,11 @@ def update_theme(theme_name: str, data: SiteTheme): def delete_theme(theme_name: str): """ Deletes theme from the database """ SiteTheme.delete_theme(theme_name) - try: - SiteTheme.delete_theme(theme_name) - except: - raise HTTPException( - status_code=400, detail=SnackResponse.error("Unable to Delete Theme") - ) + # try: + # SiteTheme.delete_theme(theme_name) + # except: + # raise HTTPException( + # status_code=400, detail=SnackResponse.error("Unable to Delete Theme") + # ) return SnackResponse.success("Theme Deleted") diff --git a/mealie/services/backups/exports.py b/mealie/services/backups/exports.py index 80e08bb91..28091c8c3 100644 --- a/mealie/services/backups/exports.py +++ b/mealie/services/backups/exports.py @@ -92,7 +92,6 @@ class ExportDatabase: def export_themes(self): all_themes = SiteTheme.get_all() - print(all_themes) if all_themes: all_themes = [x.dict() for x in all_themes] out_file = self.themes_dir.joinpath("themes.json") @@ -105,7 +104,6 @@ class ExportDatabase: if meal_plans: meal_plans = [x.dict() for x in meal_plans] - print(meal_plans) out_file = self.mealplans_dir.joinpath("mealplans.json") ExportDatabase._write_json_file(meal_plans, out_file) diff --git a/mealie/services/recipe_services.py b/mealie/services/recipe_services.py index 5176c569f..00312d2e7 100644 --- a/mealie/services/recipe_services.py +++ b/mealie/services/recipe_services.py @@ -27,7 +27,10 @@ class Recipe(BaseModel): recipeYield: Optional[str] recipeIngredient: Optional[list] recipeInstructions: Optional[list] + totalTime: Optional[Any] + prepTime: Optional[str] + performTime: Optional[str] # Mealie Specific slug: Optional[str] = "" diff --git a/mealie/settings.py b/mealie/settings.py index 2f4d11dc3..b25141e12 100644 --- a/mealie/settings.py +++ b/mealie/settings.py @@ -47,7 +47,7 @@ else: # DATABASE ENV -DATABASE_TYPE = os.getenv("db_type", "mongo") # mongo, tinydb +DATABASE_TYPE = os.getenv("db_type", "sql") # mongo, tinydb if DATABASE_TYPE == "sql": USE_SQL = True USE_MONGO = False diff --git a/mealie/utils/global_scheduler.py b/mealie/utils/global_scheduler.py index 35214a0c9..77d574dd0 100644 --- a/mealie/utils/global_scheduler.py +++ b/mealie/utils/global_scheduler.py @@ -1,8 +1,11 @@ from services.scheduler_services import Scheduler -scheduler = None def start_scheduler(): global scheduler scheduler = Scheduler() scheduler.startup_scheduler() + return scheduler + + +scheduler = start_scheduler()