mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-05-15 14:27:31 -04:00
add __filter_restricted__ to User table
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import string
|
import string
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Annotated
|
from typing import Annotated, ClassVar
|
||||||
|
|
||||||
from sqlalchemy import Integer
|
from sqlalchemy import Integer
|
||||||
from sqlalchemy.orm import DeclarativeBase, Mapped, declared_attr, mapped_column, synonym
|
from sqlalchemy.orm import DeclarativeBase, Mapped, declared_attr, mapped_column, synonym
|
||||||
@@ -22,6 +22,9 @@ Signals to the query filter API not to allow using this field in query operation
|
|||||||
|
|
||||||
|
|
||||||
class SqlAlchemyBase(DeclarativeBase):
|
class SqlAlchemyBase(DeclarativeBase):
|
||||||
|
__filter_restricted__: ClassVar[bool] = False
|
||||||
|
"""When True, the query filter API will block traversal into this model unless explicitly allowed."""
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||||
created_at: Mapped[datetime | None] = mapped_column(NaiveDateTime, default=get_utc_now, index=True)
|
created_at: Mapped[datetime | None] = mapped_column(NaiveDateTime, default=get_utc_now, index=True)
|
||||||
update_at: Mapped[datetime | None] = mapped_column(NaiveDateTime, default=get_utc_now, onupdate=get_utc_now)
|
update_at: Mapped[datetime | None] = mapped_column(NaiveDateTime, default=get_utc_now, onupdate=get_utc_now)
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ class AuthMethod(enum.Enum):
|
|||||||
|
|
||||||
class User(SqlAlchemyBase, BaseMixins):
|
class User(SqlAlchemyBase, BaseMixins):
|
||||||
__tablename__ = "users"
|
__tablename__ = "users"
|
||||||
|
__filter_restricted__ = True
|
||||||
|
|
||||||
id: Mapped[GUID] = mapped_column(GUID, primary_key=True, default=GUID.generate)
|
id: Mapped[GUID] = mapped_column(GUID, primary_key=True, default=GUID.generate)
|
||||||
full_name: Mapped[str | None] = mapped_column(String, index=True)
|
full_name: Mapped[str | None] = mapped_column(String, index=True)
|
||||||
username: Mapped[str | None] = mapped_column(String, index=True, unique=True)
|
username: Mapped[str | None] = mapped_column(String, index=True, unique=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user