1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-23 15:19:41 +02:00

feat: Allow Cookbooks To Share Names (#4186)

This commit is contained in:
Michael Genson 2024-09-15 06:42:58 -05:00 committed by GitHub
parent abe4504640
commit dbbd662e7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 185 additions and 29 deletions

View file

@ -1,8 +1,6 @@
from typing import Annotated
from pydantic import UUID4, ConfigDict, Field, field_validator
from pydantic_core.core_schema import ValidationInfo
from slugify import slugify
from sqlalchemy.orm import joinedload
from sqlalchemy.orm.interfaces import LoaderOption
@ -31,16 +29,6 @@ class CreateCookBook(MealieModel):
def validate_public(public: bool | None) -> bool:
return False if public is None else public
@field_validator("slug", mode="before")
def validate_slug(slug: str, info: ValidationInfo):
name: str = info.data["name"]
calc_slug: str = slugify(name)
if slug != calc_slug:
slug = calc_slug
return slug
class SaveCookBook(CreateCookBook):
group_id: UUID4