add(templates): base models and dto for girasol backend
Some checks failed
Deploy Girasol / deploy (push) Has been cancelled

This commit is contained in:
Julien Aldon
2026-04-23 18:17:31 +02:00
parent e91f140335
commit 89c20338dd
18 changed files with 858 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
"""Sitewide module models
"""
import uuid
from enum import StrEnum
from sqlalchemy.dialects.postgresql import JSONB
from sqlmodel import Field, SQLModel
class EmbeddedBlockLayout(StrEnum):
"""Relative layout of an embedded block's image and description
"""
LEFT = 'left'
RIGHT = 'right'
CENTER = 'center'
class EmbeddedBlockLocation(StrEnum):
"""The location where an embedded block should appear
"""
HOME = 'home'
CONTACT = 'contact'
class BaseSite(SQLModel):
"""BaseSite
"""
legal: dict = Field(sa_type=JSONB, nullable=False)
about: dict = Field(sa_type=JSONB, nullable=False)
short_description: str
class Site(BaseSite, table=True):
"""Database model representing the Site-wide configuration
"""
id: uuid.UUID | None = Field(
default=None, default_factory=uuid.uuid4, primary_key=True)
class BaseEmbeddedBlock(SQLModel):
"""BaseEmbeddedBlock
"""
title: str
layout: EmbeddedBlockLayout
location: EmbeddedBlockLocation
description: dict = Field(sa_type=JSONB, nullable=False)
class EmbeddedBlock(BaseEmbeddedBlock, table=True):
"""A paragraph displayed on the home page or contact page
with information about Girasol
"""
id: uuid.UUID | None = Field(
default=None, default_factory=uuid.uuid4, primary_key=True)
image_id: uuid.UUID = Field(foreign_key="file.id")