mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 21:45:25 +02:00
chore: refactor base schema (#1098)
* remove dead backup code * implmenet own base model * refactor to use MealieModel instead of CamelModel * cleanup deps
This commit is contained in:
parent
bcd98cba2f
commit
11b4d2389a
50 changed files with 253 additions and 623 deletions
|
@ -0,0 +1,2 @@
|
|||
from .mealie_model import *
|
||||
from .types import *
|
44
mealie/schema/_mealie/mealie_model.py
Normal file
44
mealie/schema/_mealie/mealie_model.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TypeVar
|
||||
|
||||
from humps.main import camelize
|
||||
from pydantic import BaseModel
|
||||
|
||||
T = TypeVar("T", bound=BaseModel)
|
||||
|
||||
|
||||
class MealieModel(BaseModel):
|
||||
class Config:
|
||||
alias_generator = camelize
|
||||
allow_population_by_field_name = True
|
||||
|
||||
def cast(self, cls: type[T], **kwargs) -> T:
|
||||
"""
|
||||
Cast the current model to another with additional arguments. Useful for
|
||||
transforming DTOs into models that are saved to a database
|
||||
"""
|
||||
create_data = {field: getattr(self, field) for field in self.__fields__ if field in cls.__fields__}
|
||||
create_data.update(kwargs or {})
|
||||
return cls(**create_data)
|
||||
|
||||
def map_to(self, dest: T) -> T:
|
||||
"""
|
||||
Map matching values from the current model to another model. Model returned
|
||||
for method chaining.
|
||||
"""
|
||||
|
||||
for field in self.__fields__:
|
||||
if field in dest.__fields__:
|
||||
setattr(dest, field, getattr(self, field))
|
||||
|
||||
return dest
|
||||
|
||||
def map_from(self, src: BaseModel):
|
||||
"""
|
||||
Map matching values from another model to the current model.
|
||||
"""
|
||||
|
||||
for field in src.__fields__:
|
||||
if field in self.__fields__:
|
||||
setattr(self, field, getattr(src, field))
|
|
@ -1,7 +1,7 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
|
||||
class AppStatistics(CamelModel):
|
||||
class AppStatistics(MealieModel):
|
||||
total_recipes: int
|
||||
total_users: int
|
||||
total_groups: int
|
||||
|
@ -9,7 +9,7 @@ class AppStatistics(CamelModel):
|
|||
untagged_recipes: int
|
||||
|
||||
|
||||
class AppInfo(CamelModel):
|
||||
class AppInfo(MealieModel):
|
||||
production: bool
|
||||
version: str
|
||||
demo_status: bool
|
||||
|
@ -26,7 +26,7 @@ class AdminAboutInfo(AppInfo):
|
|||
build_id: str
|
||||
|
||||
|
||||
class CheckAppConfig(CamelModel):
|
||||
class CheckAppConfig(MealieModel):
|
||||
email_ready: bool = False
|
||||
ldap_ready: bool = False
|
||||
base_url_set: bool = False
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
|
||||
class MaintenanceSummary(CamelModel):
|
||||
class MaintenanceSummary(MealieModel):
|
||||
data_dir_size: str
|
||||
log_file_size: str
|
||||
cleanable_images: int
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
from typing import Optional
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import validator
|
||||
from slugify import slugify
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
from ..recipe.recipe_category import RecipeCategoryResponse
|
||||
|
||||
|
||||
class CustomPageBase(CamelModel):
|
||||
class CustomPageBase(MealieModel):
|
||||
name: str
|
||||
slug: Optional[str]
|
||||
position: int
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4, validator
|
||||
from slugify import slugify
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
from ..recipe.recipe_category import CategoryBase, RecipeCategoryResponse
|
||||
|
||||
|
||||
class CreateCookBook(CamelModel):
|
||||
class CreateCookBook(MealieModel):
|
||||
name: str
|
||||
description: str = ""
|
||||
slug: str = None
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
from .group_preferences import UpdateGroupPreferences
|
||||
|
||||
|
||||
class GroupAdminUpdate(CamelModel):
|
||||
class GroupAdminUpdate(MealieModel):
|
||||
id: UUID4
|
||||
name: str
|
||||
preferences: UpdateGroupPreferences
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4, NoneStr
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
# =============================================================================
|
||||
# Group Events Notifier Options
|
||||
|
||||
|
||||
class GroupEventNotifierOptions(CamelModel):
|
||||
class GroupEventNotifierOptions(MealieModel):
|
||||
"""
|
||||
These events are in-sync with the EventTypes found in the EventBusService.
|
||||
If you modify this, make sure to update the EventBusService as well.
|
||||
|
@ -55,7 +56,7 @@ class GroupEventNotifierOptionsOut(GroupEventNotifierOptions):
|
|||
# Notifiers
|
||||
|
||||
|
||||
class GroupEventNotifierCreate(CamelModel):
|
||||
class GroupEventNotifierCreate(MealieModel):
|
||||
name: str
|
||||
apprise_url: str
|
||||
|
||||
|
@ -71,7 +72,7 @@ class GroupEventNotifierUpdate(GroupEventNotifierSave):
|
|||
apprise_url: NoneStr = None
|
||||
|
||||
|
||||
class GroupEventNotifierOut(CamelModel):
|
||||
class GroupEventNotifierOut(MealieModel):
|
||||
id: UUID4
|
||||
name: str
|
||||
enabled: bool
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from datetime import datetime
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class GroupDataExport(CamelModel):
|
||||
|
||||
class GroupDataExport(MealieModel):
|
||||
id: UUID4
|
||||
group_id: UUID4
|
||||
name: str
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import enum
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
|
||||
class SupportedMigrations(str, enum.Enum):
|
||||
|
@ -10,5 +10,5 @@ class SupportedMigrations(str, enum.Enum):
|
|||
mealie_alpha = "mealie_alpha"
|
||||
|
||||
|
||||
class DataMigrationCreate(CamelModel):
|
||||
class DataMigrationCreate(MealieModel):
|
||||
source_type: SupportedMigrations
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class SetPermissions(CamelModel):
|
||||
|
||||
class SetPermissions(MealieModel):
|
||||
user_id: UUID4
|
||||
can_manage: bool = False
|
||||
can_invite: bool = False
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from uuid import UUID
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class UpdateGroupPreferences(CamelModel):
|
||||
|
||||
class UpdateGroupPreferences(MealieModel):
|
||||
private_group: bool = False
|
||||
first_day_of_week: int = 0
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ from __future__ import annotations
|
|||
|
||||
from typing import Optional
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
from mealie.schema.recipe.recipe_ingredient import IngredientFood, IngredientUnit
|
||||
|
||||
|
||||
class ShoppingListItemRecipeRef(CamelModel):
|
||||
class ShoppingListItemRecipeRef(MealieModel):
|
||||
recipe_id: UUID4
|
||||
recipe_quantity: float
|
||||
|
||||
|
@ -21,7 +21,7 @@ class ShoppingListItemRecipeRefOut(ShoppingListItemRecipeRef):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class ShoppingListItemCreate(CamelModel):
|
||||
class ShoppingListItemCreate(MealieModel):
|
||||
shopping_list_id: UUID4
|
||||
checked: bool = False
|
||||
position: int = 0
|
||||
|
@ -51,11 +51,11 @@ class ShoppingListItemOut(ShoppingListItemUpdate):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class ShoppingListCreate(CamelModel):
|
||||
class ShoppingListCreate(MealieModel):
|
||||
name: str = None
|
||||
|
||||
|
||||
class ShoppingListRecipeRefOut(CamelModel):
|
||||
class ShoppingListRecipeRefOut(MealieModel):
|
||||
id: UUID4
|
||||
shopping_list_id: UUID4
|
||||
recipe_id: UUID4
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
from uuid import UUID
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import NoneStr
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class CreateInviteToken(CamelModel):
|
||||
|
||||
class CreateInviteToken(MealieModel):
|
||||
uses: int
|
||||
|
||||
|
||||
class SaveInviteToken(CamelModel):
|
||||
class SaveInviteToken(MealieModel):
|
||||
uses_left: int
|
||||
group_id: UUID
|
||||
token: str
|
||||
|
||||
|
||||
class ReadInviteToken(CamelModel):
|
||||
class ReadInviteToken(MealieModel):
|
||||
token: str
|
||||
uses_left: int
|
||||
group_id: UUID
|
||||
|
@ -23,11 +24,11 @@ class ReadInviteToken(CamelModel):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class EmailInvitation(CamelModel):
|
||||
class EmailInvitation(MealieModel):
|
||||
email: str
|
||||
token: str
|
||||
|
||||
|
||||
class EmailInitationResponse(CamelModel):
|
||||
class EmailInitationResponse(MealieModel):
|
||||
success: bool
|
||||
error: NoneStr = None
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from uuid import UUID
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class CreateWebhook(CamelModel):
|
||||
|
||||
class CreateWebhook(MealieModel):
|
||||
enabled: bool = True
|
||||
name: str = ""
|
||||
url: str = ""
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class MultiPurposeLabelCreate(CamelModel):
|
||||
|
||||
class MultiPurposeLabelCreate(MealieModel):
|
||||
name: str
|
||||
color: str = "#E0E0E0"
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import validator
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class MealIn(CamelModel):
|
||||
|
||||
class MealIn(MealieModel):
|
||||
slug: Optional[str]
|
||||
name: Optional[str]
|
||||
description: Optional[str]
|
||||
|
@ -14,7 +15,7 @@ class MealIn(CamelModel):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class MealDayIn(CamelModel):
|
||||
class MealDayIn(MealieModel):
|
||||
date: Optional[date]
|
||||
meals: list[MealIn]
|
||||
|
||||
|
@ -29,7 +30,7 @@ class MealDayOut(MealDayIn):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class MealPlanIn(CamelModel):
|
||||
class MealPlanIn(MealieModel):
|
||||
group: str
|
||||
start_date: date
|
||||
end_date: date
|
||||
|
|
|
@ -3,9 +3,9 @@ from enum import Enum
|
|||
from typing import Optional
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import validator
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
from mealie.schema.recipe.recipe import RecipeSummary
|
||||
|
||||
|
||||
|
@ -16,12 +16,12 @@ class PlanEntryType(str, Enum):
|
|||
side = "side"
|
||||
|
||||
|
||||
class CreatRandomEntry(CamelModel):
|
||||
class CreatRandomEntry(MealieModel):
|
||||
date: date
|
||||
entry_type: PlanEntryType = PlanEntryType.dinner
|
||||
|
||||
|
||||
class CreatePlanEntry(CamelModel):
|
||||
class CreatePlanEntry(MealieModel):
|
||||
date: date
|
||||
entry_type: PlanEntryType = PlanEntryType.breakfast
|
||||
title: str = ""
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import datetime
|
||||
from enum import Enum
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class Category(CamelModel):
|
||||
|
||||
class Category(MealieModel):
|
||||
id: UUID4
|
||||
name: str
|
||||
slug: str
|
||||
|
@ -46,7 +47,7 @@ class PlanRulesType(str, Enum):
|
|||
unset = "unset"
|
||||
|
||||
|
||||
class PlanRulesCreate(CamelModel):
|
||||
class PlanRulesCreate(MealieModel):
|
||||
day: PlanRulesDay = PlanRulesDay.unset
|
||||
entry_type: PlanRulesType = PlanRulesType.unset
|
||||
categories: list[Category] = []
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
from typing import Optional
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic.utils import GetterDict
|
||||
|
||||
from mealie.db.models.group.shopping_list import ShoppingList
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
|
||||
class ListItem(CamelModel):
|
||||
class ListItem(MealieModel):
|
||||
title: Optional[str]
|
||||
text: str = ""
|
||||
quantity: int = 1
|
||||
|
@ -16,7 +16,7 @@ class ListItem(CamelModel):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class ShoppingListIn(CamelModel):
|
||||
class ShoppingListIn(MealieModel):
|
||||
name: str
|
||||
group: Optional[str]
|
||||
items: list[ListItem]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
|
||||
class GetAll(CamelModel):
|
||||
class GetAll(MealieModel):
|
||||
start: int = 0
|
||||
limit: int = 999
|
||||
|
|
|
@ -5,13 +5,13 @@ from pathlib import Path
|
|||
from typing import Any, Optional
|
||||
from uuid import uuid4
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4, BaseModel, Field, validator
|
||||
from pydantic.utils import GetterDict
|
||||
from slugify import slugify
|
||||
|
||||
from mealie.core.config import get_app_dirs
|
||||
from mealie.db.models.recipe.recipe import RecipeModel
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
from .recipe_asset import RecipeAsset
|
||||
from .recipe_comments import RecipeCommentOut
|
||||
|
@ -23,7 +23,7 @@ from .recipe_step import RecipeStep
|
|||
app_dirs = get_app_dirs()
|
||||
|
||||
|
||||
class RecipeTag(CamelModel):
|
||||
class RecipeTag(MealieModel):
|
||||
id: UUID4 = None
|
||||
name: str
|
||||
slug: str
|
||||
|
@ -58,11 +58,11 @@ class CreateRecipeByUrlBulk(BaseModel):
|
|||
imports: list[CreateRecipeBulk]
|
||||
|
||||
|
||||
class CreateRecipe(CamelModel):
|
||||
class CreateRecipe(MealieModel):
|
||||
name: str
|
||||
|
||||
|
||||
class RecipeSummary(CamelModel):
|
||||
class RecipeSummary(MealieModel):
|
||||
id: Optional[UUID4]
|
||||
|
||||
user_id: UUID4 = Field(default_factory=uuid4)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from typing import Optional
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
|
||||
class RecipeAsset(CamelModel):
|
||||
class RecipeAsset(MealieModel):
|
||||
name: str
|
||||
icon: str
|
||||
file_name: Optional[str]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import enum
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
from mealie.schema.recipe.recipe_category import CategoryBase, TagBase
|
||||
|
||||
|
||||
|
@ -9,7 +8,7 @@ class ExportTypes(str, enum.Enum):
|
|||
JSON = "json"
|
||||
|
||||
|
||||
class ExportBase(CamelModel):
|
||||
class ExportBase(MealieModel):
|
||||
recipes: list[str]
|
||||
|
||||
|
||||
|
@ -29,12 +28,12 @@ class DeleteRecipes(ExportBase):
|
|||
pass
|
||||
|
||||
|
||||
class BulkActionError(CamelModel):
|
||||
class BulkActionError(MealieModel):
|
||||
recipe: str
|
||||
error: str
|
||||
|
||||
|
||||
class BulkActionsResponse(CamelModel):
|
||||
class BulkActionsResponse(MealieModel):
|
||||
success: bool
|
||||
message: str
|
||||
errors: list[BulkActionError] = []
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
from pydantic.utils import GetterDict
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class CategoryIn(CamelModel):
|
||||
|
||||
class CategoryIn(MealieModel):
|
||||
name: str
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@ from datetime import datetime
|
|||
from typing import Optional
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class UserBase(CamelModel):
|
||||
|
||||
class UserBase(MealieModel):
|
||||
id: int
|
||||
username: Optional[str]
|
||||
admin: bool
|
||||
|
@ -15,7 +16,7 @@ class UserBase(CamelModel):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class RecipeCommentCreate(CamelModel):
|
||||
class RecipeCommentCreate(MealieModel):
|
||||
recipe_id: UUID4
|
||||
text: str
|
||||
|
||||
|
@ -24,7 +25,7 @@ class RecipeCommentSave(RecipeCommentCreate):
|
|||
user_id: UUID4
|
||||
|
||||
|
||||
class RecipeCommentUpdate(CamelModel):
|
||||
class RecipeCommentUpdate(MealieModel):
|
||||
id: UUID
|
||||
text: str
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@ import enum
|
|||
from typing import Optional, Union
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4, Field
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
from mealie.schema._mealie.types import NoneFloat
|
||||
|
||||
|
||||
class UnitFoodBase(CamelModel):
|
||||
class UnitFoodBase(MealieModel):
|
||||
name: str
|
||||
description: str = ""
|
||||
|
||||
|
@ -47,7 +47,7 @@ class IngredientUnit(CreateIngredientUnit):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class RecipeIngredient(CamelModel):
|
||||
class RecipeIngredient(MealieModel):
|
||||
title: Optional[str]
|
||||
note: Optional[str]
|
||||
unit: Optional[Union[IngredientUnit, CreateIngredientUnit]]
|
||||
|
@ -64,7 +64,7 @@ class RecipeIngredient(CamelModel):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class IngredientConfidence(CamelModel):
|
||||
class IngredientConfidence(MealieModel):
|
||||
average: NoneFloat = None
|
||||
comment: NoneFloat = None
|
||||
name: NoneFloat = None
|
||||
|
@ -73,7 +73,7 @@ class IngredientConfidence(CamelModel):
|
|||
food: NoneFloat = None
|
||||
|
||||
|
||||
class ParsedIngredient(CamelModel):
|
||||
class ParsedIngredient(MealieModel):
|
||||
input: Optional[str]
|
||||
confidence: IngredientConfidence = IngredientConfidence()
|
||||
ingredient: RecipeIngredient
|
||||
|
@ -84,12 +84,12 @@ class RegisteredParser(str, enum.Enum):
|
|||
brute = "brute"
|
||||
|
||||
|
||||
class IngredientsRequest(CamelModel):
|
||||
class IngredientsRequest(MealieModel):
|
||||
parser: RegisteredParser = RegisteredParser.nlp
|
||||
ingredients: list[str]
|
||||
|
||||
|
||||
class IngredientRequest(CamelModel):
|
||||
class IngredientRequest(MealieModel):
|
||||
parser: RegisteredParser = RegisteredParser.nlp
|
||||
ingredient: str
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from typing import Optional
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
|
||||
class Nutrition(CamelModel):
|
||||
class Nutrition(MealieModel):
|
||||
calories: Optional[str]
|
||||
fat_content: Optional[str]
|
||||
protein_content: Optional[str]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
|
||||
class RecipeSettings(CamelModel):
|
||||
class RecipeSettings(MealieModel):
|
||||
public: bool = False
|
||||
show_nutrition: bool = False
|
||||
show_assets: bool = False
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4, Field
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
from .recipe import Recipe
|
||||
|
||||
|
||||
|
@ -10,7 +11,7 @@ def defaut_expires_at_time() -> datetime:
|
|||
return datetime.utcnow() + timedelta(days=30)
|
||||
|
||||
|
||||
class RecipeShareTokenCreate(CamelModel):
|
||||
class RecipeShareTokenCreate(MealieModel):
|
||||
recipe_id: UUID4
|
||||
expires_at: datetime = Field(default_factory=defaut_expires_at_time)
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from typing import Optional
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4, Field
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class IngredientReferences(CamelModel):
|
||||
|
||||
class IngredientReferences(MealieModel):
|
||||
"""
|
||||
A list of ingredient references.
|
||||
"""
|
||||
|
@ -16,7 +17,7 @@ class IngredientReferences(CamelModel):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class RecipeStep(CamelModel):
|
||||
class RecipeStep(MealieModel):
|
||||
id: Optional[UUID] = Field(default_factory=uuid4)
|
||||
title: Optional[str] = ""
|
||||
text: str
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import typing
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class RecipeToolCreate(CamelModel):
|
||||
|
||||
class RecipeToolCreate(MealieModel):
|
||||
name: str
|
||||
on_hand: bool = False
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import BaseModel
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
# TODO: Should these exist?!?!?!?!?
|
||||
|
||||
|
||||
class RecipeSlug(CamelModel):
|
||||
class RecipeSlug(MealieModel):
|
||||
slug: str
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import datetime
|
||||
import enum
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import Field
|
||||
from pydantic.types import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
|
||||
class ReportCategory(str, enum.Enum):
|
||||
backup = "backup"
|
||||
|
@ -19,7 +20,7 @@ class ReportSummaryStatus(str, enum.Enum):
|
|||
partial = "partial"
|
||||
|
||||
|
||||
class ReportEntryCreate(CamelModel):
|
||||
class ReportEntryCreate(MealieModel):
|
||||
report_id: UUID4
|
||||
timestamp: datetime.datetime = Field(default_factory=datetime.datetime.utcnow)
|
||||
success: bool = True
|
||||
|
@ -34,7 +35,7 @@ class ReportEntryOut(ReportEntryCreate):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class ReportCreate(CamelModel):
|
||||
class ReportCreate(MealieModel):
|
||||
timestamp: datetime.datetime = Field(default_factory=datetime.datetime.utcnow)
|
||||
category: ReportCategory
|
||||
group_id: UUID4
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
from typing import Optional
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import BaseModel
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
|
||||
class ErrorResponse(BaseModel):
|
||||
message: str
|
||||
|
@ -31,7 +32,7 @@ class SuccessResponse(BaseModel):
|
|||
return cls(message=message).dict()
|
||||
|
||||
|
||||
class FileTokenResponse(CamelModel):
|
||||
class FileTokenResponse(MealieModel):
|
||||
file_token: str
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -2,9 +2,10 @@ import datetime
|
|||
import enum
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import Field
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
|
||||
class ServerTaskNames(str, enum.Enum):
|
||||
default = "Background Task"
|
||||
|
@ -18,7 +19,7 @@ class ServerTaskStatus(str, enum.Enum):
|
|||
failed = "failed"
|
||||
|
||||
|
||||
class ServerTaskCreate(CamelModel):
|
||||
class ServerTaskCreate(MealieModel):
|
||||
group_id: UUID
|
||||
name: ServerTaskNames = ServerTaskNames.default
|
||||
created_at: datetime.datetime = Field(default_factory=datetime.datetime.now)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import validator
|
||||
from pydantic.types import NoneStr, constr
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
class CreateUserRegistration(CamelModel):
|
||||
|
||||
class CreateUserRegistration(MealieModel):
|
||||
group: NoneStr = None
|
||||
group_token: NoneStr = None
|
||||
email: constr(to_lower=True, strip_whitespace=True) # type: ignore
|
||||
|
|
|
@ -3,13 +3,13 @@ from pathlib import Path
|
|||
from typing import Any, Optional
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
from pydantic.types import constr
|
||||
from pydantic.utils import GetterDict
|
||||
|
||||
from mealie.core.config import get_app_dirs, get_app_settings
|
||||
from mealie.db.models.users import User
|
||||
from mealie.schema._mealie import MealieModel
|
||||
from mealie.schema.group.group_preferences import ReadGroupPreferences
|
||||
from mealie.schema.recipe import RecipeSummary
|
||||
|
||||
|
@ -18,7 +18,7 @@ from ..recipe import CategoryBase
|
|||
settings = get_app_settings()
|
||||
|
||||
|
||||
class LoingLiveTokenIn(CamelModel):
|
||||
class LoingLiveTokenIn(MealieModel):
|
||||
name: str
|
||||
|
||||
|
||||
|
@ -38,19 +38,19 @@ class CreateToken(LoingLiveTokenIn):
|
|||
orm_mode = True
|
||||
|
||||
|
||||
class ChangePassword(CamelModel):
|
||||
class ChangePassword(MealieModel):
|
||||
current_password: str
|
||||
new_password: str
|
||||
|
||||
|
||||
class GroupBase(CamelModel):
|
||||
class GroupBase(MealieModel):
|
||||
name: str
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class UserBase(CamelModel):
|
||||
class UserBase(MealieModel):
|
||||
username: Optional[str]
|
||||
full_name: Optional[str] = None
|
||||
email: constr(to_lower=True, strip_whitespace=True) # type: ignore
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.schema._mealie import MealieModel
|
||||
|
||||
from .user import PrivateUser
|
||||
|
||||
|
||||
class ForgotPassword(CamelModel):
|
||||
class ForgotPassword(MealieModel):
|
||||
email: str
|
||||
|
||||
|
||||
class ValidateResetToken(CamelModel):
|
||||
class ValidateResetToken(MealieModel):
|
||||
token: str
|
||||
|
||||
|
||||
|
@ -18,7 +19,7 @@ class ResetPassword(ValidateResetToken):
|
|||
passwordConfirm: str
|
||||
|
||||
|
||||
class SavePasswordResetToken(CamelModel):
|
||||
class SavePasswordResetToken(MealieModel):
|
||||
user_id: UUID4
|
||||
token: str
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue