class Poster(Table, tags=["special"]): """ Has tags for tests which need it. """ image = Bytea(default=b"\xbd\x78\xd8") content = Text()
class Post(Table): """ A simple blog post. """ title = Varchar() content = Text() published = Boolean(default=False) created_on = Timestamp()
class Movie(Table, db=DB): name = Varchar(length=300) rating = Real() duration = Integer() director = ForeignKey(references=Director) won_oscar = Boolean() description = Text() release_date = Timestamp() box_office = Numeric(digits=(5, 1))
class Review(Table): content = Text() created = Timestamp() review_grade = Integer() review_user = ForeignKey(references=User) ad = ForeignKey(references=Ad) @classmethod def get_readable(cls): return Readable(template="%s", columns=[cls.ad])
class Category(Table): """ An Category table. """ name = Varchar() description = Text() @classmethod def get_readable(cls): return Readable(template="%s", columns=[cls.name])
class Movie(Table): name = Varchar(length=300) rating = Real(help_text="The rating on IMDB.") duration = Interval() director = ForeignKey(references=Director) oscar_nominations = Integer() won_oscar = Boolean() description = Text() release_date = Timestamp() box_office = Numeric(digits=(5, 1), help_text="In millions of US dollars.") tags = Array(base_column=Varchar())
class Reply(Table): """ An Reply table. """ description = Text() created = Timestamp() topic = ForeignKey(references=Topic) reply_user = ForeignKey(references=BaseUser) @classmethod def get_readable(cls): return Readable(template="%s", columns=[cls.topic])
class Answer(Table): """ An answer table. """ content = Text() created_at = Timestamp() answer_like = Integer(default=0) is_accepted_answer = Boolean(default=False) ans_user = ForeignKey(references=User) question = ForeignKey(references=Question) @classmethod def get_readable(cls): return Readable(template="%s", columns=[cls.question])
class Ad(Table): title = Varchar(length=255) slug = Varchar(length=255) content = Text() created = Timestamp() view = Integer(default=0) price = Integer() room = Integer() visitor = Integer() address = Varchar(length=255) city = Varchar(length=255) ad_user = ForeignKey(references=User) @classmethod def get_readable(cls): return Readable(template="%s", columns=[cls.title])
class Question(Table): """ An question table. """ title = Varchar(length=200) slug = Varchar(length=200) description = Text() created_at = Timestamp() view = Integer(default=0) question_like = Integer(default=0) accepted_answer = Boolean(default=False) user = ForeignKey(references=User) category = ForeignKey(references=Category) @classmethod def get_readable(cls): return Readable(template="%s", columns=[cls.title])
class Movie(Table): class Genre(int, enum.Enum): fantasy = 1 sci_fi = 2 documentary = 3 horror = 4 action = 5 comedy = 6 romance = 7 musical = 8 name = Varchar(length=300) rating = Real(help_text="The rating on IMDB.") duration = Interval() director = ForeignKey(references=Director) oscar_nominations = Integer() won_oscar = Boolean() description = Text() release_date = Timestamp() box_office = Numeric(digits=(5, 1), help_text="In millions of US dollars.") tags = Array(base_column=Varchar()) barcode = BigInt(default=0) genre = SmallInt(choices=Genre, null=True)
class Band(Table): bio = Text()
class Poster(Table, tags=["special"]): """ Has tags for tests which need it. """ content = Text()