56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
"""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")
|