mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-01-04 08:01:22 -05:00
feature/finish-recipe-assets (#384)
* add features to readme
* Copy markdown reference
* prop as whole recipe
* parameter as url instead of query
* add card styling to editor
* move images to /recipes/{slug}/images
* add image to breaking changes
* fix delete and import errors
* fix debug/about response
* logger updates
* dashboard ui
* add server side events
* unorganized routes
* default slot
* add backup viewer to dashboard
* format
* add dialog to backup imports
* initial event support
* delete assets when removed
Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
|
||||
|
||||
class AppStatistics(CamelModel):
|
||||
total_recipes: int
|
||||
total_users: int
|
||||
total_groups: int
|
||||
uncategorized_recipes: int
|
||||
untagged_recipes: int
|
||||
|
||||
|
||||
class AppInfo(CamelModel):
|
||||
production: bool
|
||||
version: str
|
||||
@@ -11,5 +20,6 @@ class AppInfo(CamelModel):
|
||||
class DebugInfo(AppInfo):
|
||||
api_port: int
|
||||
api_docs: bool
|
||||
db_type: str
|
||||
db_url: Path
|
||||
default_group: str
|
||||
31
mealie/schema/events.py
Normal file
31
mealie/schema/events.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class EventCategory(str, Enum):
|
||||
general = "general"
|
||||
recipe = "recipe"
|
||||
backup = "backup"
|
||||
scheduled = "scheduled"
|
||||
migration = "migration"
|
||||
sign_up = "signup"
|
||||
|
||||
|
||||
class Event(CamelModel):
|
||||
id: Optional[int]
|
||||
title: str
|
||||
text: str
|
||||
time_stamp: datetime = Field(default_factory=datetime.now)
|
||||
category: EventCategory = EventCategory.general
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class EventsOut(CamelModel):
|
||||
total: int
|
||||
events: list[Event]
|
||||
@@ -1,7 +1,9 @@
|
||||
import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from mealie.core.config import app_dirs
|
||||
from mealie.db.models.recipe.recipe import RecipeModel
|
||||
from pydantic import BaseModel, Field, validator
|
||||
from pydantic.utils import GetterDict
|
||||
@@ -58,8 +60,8 @@ class Nutrition(CamelModel):
|
||||
|
||||
class RecipeSummary(CamelModel):
|
||||
id: Optional[int]
|
||||
name: str
|
||||
slug: Optional[str] = ""
|
||||
name: Optional[str]
|
||||
slug: str = ""
|
||||
image: Optional[Any]
|
||||
|
||||
description: Optional[str]
|
||||
@@ -98,6 +100,28 @@ class Recipe(RecipeSummary):
|
||||
org_url: Optional[str] = Field(None, alias="orgURL")
|
||||
extras: Optional[dict] = {}
|
||||
|
||||
@staticmethod
|
||||
def directory_from_slug(slug) -> Path:
|
||||
return app_dirs.RECIPE_DATA_DIR.joinpath(slug)
|
||||
|
||||
@property
|
||||
def directory(self) -> Path:
|
||||
dir = app_dirs.RECIPE_DATA_DIR.joinpath(self.slug)
|
||||
dir.mkdir(exist_ok=True, parents=True)
|
||||
return dir
|
||||
|
||||
@property
|
||||
def asset_dir(self) -> Path:
|
||||
dir = self.directory.joinpath("assets")
|
||||
dir.mkdir(exist_ok=True, parents=True)
|
||||
return dir
|
||||
|
||||
@property
|
||||
def image_dir(self) -> Path:
|
||||
dir = self.directory.joinpath("images")
|
||||
dir.mkdir(exist_ok=True, parents=True)
|
||||
return dir
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
@@ -140,6 +164,8 @@ class Recipe(RecipeSummary):
|
||||
|
||||
@validator("slug", always=True, pre=True)
|
||||
def validate_slug(slug: str, values):
|
||||
if not values["name"]:
|
||||
return slug
|
||||
name: str = values["name"]
|
||||
calc_slug: str = slugify(name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user