-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added announcements (also known as motd) that will be used by decky to show important messages to users.
- Loading branch information
Showing
14 changed files
with
553 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from datetime import datetime | ||
|
||
from ..utils import UUID7 | ||
from .base import BaseModel | ||
|
||
|
||
class CurrentAnnouncementResponse(BaseModel): | ||
class Config: | ||
orm_mode = True | ||
|
||
id: UUID7 | ||
|
||
title: str | ||
text: str | ||
|
||
created: datetime | ||
updated: datetime | ||
|
||
|
||
class AnnouncementResponse(BaseModel): | ||
class Config: | ||
orm_mode = True | ||
|
||
id: UUID7 | ||
|
||
title: str | ||
text: str | ||
|
||
active: bool | ||
|
||
created: datetime | ||
updated: datetime | ||
|
||
|
||
class AnnouncementRequest(BaseModel): | ||
title: str | ||
text: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
plugin_store/database/migrations/versions/2024_08_10_2158-469f48c143b9_announcements.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""empty message | ||
Revision ID: 469f48c143b9 | ||
Revises: f5a91a25a410 | ||
Create Date: 2024-08-10 21:58:11.798321 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
from database import utils | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "469f48c143b9" | ||
down_revision = "f5a91a25a410" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"announcements", | ||
sa.Column("id", sa.Uuid(), nullable=False), | ||
sa.Column("title", sa.Text(), nullable=False), | ||
sa.Column("text", sa.Text(), nullable=False), | ||
sa.Column("active", sa.Boolean(), nullable=False), | ||
sa.Column("updated", utils.TZDateTime(), nullable=False), | ||
sa.Column("created", utils.TZDateTime(), nullable=False), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table("announcements") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from datetime import datetime | ||
from uuid import UUID | ||
from zoneinfo import ZoneInfo | ||
|
||
from sqlalchemy import Boolean, Column, Text, Uuid | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from ..utils import TZDateTime, uuid7 | ||
from .Base import Base | ||
|
||
UTC = ZoneInfo("UTC") | ||
|
||
|
||
def utcnow() -> datetime: | ||
return datetime.now(UTC) | ||
|
||
|
||
class Announcement(Base): | ||
__tablename__ = "announcements" | ||
|
||
id: Mapped[UUID] = mapped_column(Uuid, primary_key=True, default=uuid7) | ||
|
||
title: Mapped[str] = Column(Text, nullable=False) | ||
text: Mapped[str] = Column(Text, nullable=False) | ||
|
||
active: Mapped[bool] = Column(Boolean, nullable=False) | ||
|
||
created: Mapped[datetime] = Column(TZDateTime, nullable=False, default=utcnow) | ||
updated: Mapped[datetime] = Column(TZDateTime, nullable=False, default=utcnow, onupdate=utcnow) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,3 +86,4 @@ env = [ | |
"DB_URL=sqlite+aiosqlite:///:memory:", | ||
"SUBMIT_AUTH_KEY=deadbeef", | ||
] | ||
asyncio_mode = "auto" |
Oops, something went wrong.