safety commit
This commit is contained in:
@@ -5,7 +5,7 @@ from typing import List, Optional
|
||||
|
||||
import pytz
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from sqlalchemy import Column, DateTime, String, TypeDecorator
|
||||
from sqlalchemy import Boolean, Column, DateTime, String, TypeDecorator
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
db : SQLAlchemy = SQLAlchemy()
|
||||
@@ -45,7 +45,7 @@ class Password(db.Model):
|
||||
value : Mapped[str] = mapped_column(String(60))
|
||||
expires_at: Mapped[Optional[datetime]] = mapped_column(UTCDateTime()) # Optional expiration
|
||||
|
||||
decks : Mapped[List[Deck]] = relationship("Deck", secondary=deck_password, back_populates='passwords')
|
||||
decks : Mapped[List[Deck]] = relationship("Deck", secondary=deck_password, back_populates='passwords', cascade="all")
|
||||
|
||||
def __init__(self, value: str, expires_at: datetime|None) -> None:
|
||||
self.value = value
|
||||
@@ -67,8 +67,8 @@ class Deck(db.Model):
|
||||
deck : Mapped[str] = mapped_column(String(60), unique=True, nullable=False)
|
||||
description : Mapped[str] = mapped_column(String(60))
|
||||
|
||||
passwords : Mapped[List[Password]] = relationship("Password", secondary=deck_password, back_populates='decks')
|
||||
tokens : Mapped[List[Token]] = relationship("Token", secondary=deck_token, back_populates='decks')
|
||||
passwords : Mapped[List[Password]] = relationship("Password", secondary=deck_password, back_populates='decks', cascade="all")
|
||||
tokens : Mapped[List[Token]] = relationship("Token", secondary=deck_token, back_populates='decks', cascade="all")
|
||||
|
||||
def __init__(self, name: str, deck: str, description: str = "") -> None:
|
||||
self.name = name
|
||||
@@ -82,7 +82,7 @@ class Token(db.Model):
|
||||
__tablename__ = "token"
|
||||
id : Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(60), unique=True, nullable=False)
|
||||
decks : Mapped[List[Deck]]= relationship("Deck", secondary=deck_token, back_populates='tokens')
|
||||
decks : Mapped[List[Deck]]= relationship("Deck", secondary=deck_token, back_populates='tokens', cascade="all")
|
||||
|
||||
def __init__(self, name: str) -> None:
|
||||
self.name = name
|
||||
@@ -93,3 +93,13 @@ class Token(db.Model):
|
||||
def is_unlocked(self, deck: str) -> bool :
|
||||
return deck in [deck.deck for deck in self.decks]
|
||||
|
||||
class InfoBanner(db.Model):
|
||||
__tablename__ = "info_banner"
|
||||
id : Mapped[int] = mapped_column(primary_key=True)
|
||||
content : Mapped[str] = mapped_column(String(280))
|
||||
is_active : Mapped[bool] = mapped_column(Boolean)
|
||||
|
||||
def __init__(self, content : str) -> None:
|
||||
self.content = content
|
||||
self.is_active = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user