inc
parent
a46a2b421e
commit
322321b1ed
@ -1,10 +1,24 @@
|
||||
from sqlalchemy import create_engine, Column, Integer, String, ForeignKey
|
||||
from sqlalchemy.orm import relationship, sessionmaker
|
||||
from sqlalchemy.orm import relationship, sessionmaker, Mapped
|
||||
|
||||
from .show import Base
|
||||
|
||||
class Pattern(Base):
|
||||
|
||||
__tablename__ = 'patterns'
|
||||
|
||||
# v1.x
|
||||
id = Column(Integer, primary_key=True)
|
||||
pattern = Column(String)
|
||||
|
||||
# v2.0
|
||||
# id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
# pattern: Mapped[str] = mapped_column(String, nullable=False)
|
||||
|
||||
# v1.x
|
||||
show_id = Column(Integer, ForeignKey('shows.id', ondelete="CASCADE"))
|
||||
show = relationship('Show', back_populates='patterns')
|
||||
|
||||
# v2.0
|
||||
# show_id: Mapped[int] = mapped_column(ForeignKey("shows.id", ondelete="CASCADE"))
|
||||
# show: Mapped["Show"] = relationship(back_populates="patterns")
|
||||
|
@ -1,13 +1,25 @@
|
||||
# from typing import List
|
||||
from sqlalchemy import create_engine, Column, Integer, String, ForeignKey
|
||||
from sqlalchemy.orm import relationship, sessionmaker
|
||||
|
||||
from sqlalchemy.orm import declarative_base
|
||||
from sqlalchemy.orm import relationship, declarative_base, sessionmaker
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
class Show(Base):
|
||||
|
||||
__tablename__ = 'shows'
|
||||
|
||||
# v1.x
|
||||
id = Column(Integer, primary_key=True)
|
||||
name = Column(String)
|
||||
year = Column(Integer)
|
||||
|
||||
# v2.0
|
||||
# id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
# name: Mapped[str] = mapped_column(String, nullable=False)
|
||||
# year: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
# v1.x
|
||||
patterns = relationship('Pattern', back_populates='show', cascade="all, delete")
|
||||
|
||||
# v2.0
|
||||
# patterns: Mapped[List["Pattern"]] = relationship(back_populates="show", cascade="all, delete")
|
||||
|
@ -1,60 +0,0 @@
|
||||
import click
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button
|
||||
from textual.containers import Grid, Horizontal
|
||||
|
||||
from ffx.model.show import Show
|
||||
|
||||
class ShowNewScreen(Screen):
|
||||
|
||||
CSS = """
|
||||
|
||||
Grid {
|
||||
grid-size: 2;
|
||||
grid-rows: 2 auto;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
padding: 1;
|
||||
}
|
||||
|
||||
#top {
|
||||
height: 1;
|
||||
}
|
||||
|
||||
|
||||
#two {
|
||||
column-span: 2;
|
||||
row-span: 2;
|
||||
tint: magenta 40%;
|
||||
}
|
||||
|
||||
.box {
|
||||
height: 100%;
|
||||
border: solid green;
|
||||
}
|
||||
"""
|
||||
|
||||
BINDINGS = [
|
||||
("q", "quit()", "Quit"),
|
||||
("h", "switch_mode('help')", "Help")
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.context = self.app.getContext()
|
||||
|
||||
self.Session = self.context['database_session'] # convenience
|
||||
|
||||
|
||||
def compose(self):
|
||||
|
||||
yield Header()
|
||||
|
||||
with Grid():
|
||||
|
||||
yield Static("New Show")
|
||||
|
||||
yield Footer()
|
Loading…
Reference in New Issue