mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-11-18 09:52:23 -05:00
* Make first day of the week customizable New settings section 'Locale settings' New setting 'First day of week' New date picker reusable UI that uses the new setting Meal planner now uses this new date picker * Clean up unused code in settings page * Fix First day of week mapping * Replace missing v-date-picker with custom card DatePicker * Mention first day of the week feature in change log
58 lines
1.4 KiB
Python
58 lines
1.4 KiB
Python
from typing import Optional
|
|
|
|
from fastapi_camelcase import CamelModel
|
|
from mealie.schema.category import CategoryBase
|
|
from pydantic import validator
|
|
from slugify import slugify
|
|
|
|
|
|
class SiteSettings(CamelModel):
|
|
language: str = "en"
|
|
first_day_of_week: int = 0
|
|
show_recent: bool = True
|
|
cards_per_section: int = 9
|
|
categories: Optional[list[CategoryBase]] = []
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
schema_extra = {
|
|
"example": {
|
|
"language": "en",
|
|
"firstDayOfWeek": 0,
|
|
"showRecent": True,
|
|
"categories": [
|
|
{"id": 1, "name": "thanksgiving", "slug": "thanksgiving"},
|
|
{"id": 2, "name": "homechef", "slug": "homechef"},
|
|
{"id": 3, "name": "potatoes", "slug": "potatoes"},
|
|
],
|
|
}
|
|
}
|
|
|
|
|
|
class CustomPageBase(CamelModel):
|
|
name: str
|
|
slug: Optional[str]
|
|
position: int
|
|
categories: list[CategoryBase] = []
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
@validator("slug", always=True, pre=True)
|
|
def validate_slug(slug: str, values):
|
|
name: str = values["name"]
|
|
calc_slug: str = slugify(name)
|
|
|
|
if slug != calc_slug:
|
|
slug = calc_slug
|
|
|
|
return slug
|
|
|
|
|
|
class CustomPageOut(CustomPageBase):
|
|
id: int
|
|
|
|
class Config:
|
|
orm_mode = True
|