This commit is contained in:
2024-02-21 19:14:58 +03:00
parent 88cd6e1060
commit 214af0cf51
33 changed files with 750 additions and 773 deletions

View File

@@ -5,36 +5,36 @@ from services.db import Base
class AuthorRating(Base):
__tablename__ = "author_rating"
__tablename__ = 'author_rating'
id = None # type: ignore
rater = Column(ForeignKey("author.id"), primary_key=True)
author = Column(ForeignKey("author.id"), primary_key=True)
rater = Column(ForeignKey('author.id'), primary_key=True)
author = Column(ForeignKey('author.id'), primary_key=True)
plus = Column(Boolean)
class AuthorFollower(Base):
__tablename__ = "author_follower"
__tablename__ = 'author_follower'
id = None # type: ignore
follower = Column(ForeignKey("author.id"), primary_key=True)
author = Column(ForeignKey("author.id"), primary_key=True)
follower = Column(ForeignKey('author.id'), primary_key=True)
author = Column(ForeignKey('author.id'), primary_key=True)
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
auto = Column(Boolean, nullable=False, default=False)
class Author(Base):
__tablename__ = "author"
__tablename__ = 'author'
user = Column(String) # unbounded link with authorizer's User type
name = Column(String, nullable=True, comment="Display name")
name = Column(String, nullable=True, comment='Display name')
slug = Column(String, unique=True, comment="Author's slug")
bio = Column(String, nullable=True, comment="Bio") # status description
about = Column(String, nullable=True, comment="About") # long and formatted
pic = Column(String, nullable=True, comment="Picture")
links = Column(JSON, nullable=True, comment="Links")
bio = Column(String, nullable=True, comment='Bio') # status description
about = Column(String, nullable=True, comment='About') # long and formatted
pic = Column(String, nullable=True, comment='Picture')
links = Column(JSON, nullable=True, comment='Links')
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
last_seen = Column(Integer, nullable=False, default=lambda: int(time.time()))
updated_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
deleted_at = Column(Integer, nullable=True, comment="Deleted at")
deleted_at = Column(Integer, nullable=True, comment='Deleted at')

View File

@@ -6,20 +6,20 @@ from services.db import Base
class ShoutCollection(Base):
__tablename__ = "shout_collection"
__tablename__ = 'shout_collection'
id = None # type: ignore
shout = Column(ForeignKey("shout.id"), primary_key=True)
collection = Column(ForeignKey("collection.id"), primary_key=True)
shout = Column(ForeignKey('shout.id'), primary_key=True)
collection = Column(ForeignKey('collection.id'), primary_key=True)
class Collection(Base):
__tablename__ = "collection"
__tablename__ = 'collection'
slug = Column(String, unique=True)
title = Column(String, nullable=False, comment="Title")
body = Column(String, nullable=True, comment="Body")
pic = Column(String, nullable=True, comment="Picture")
title = Column(String, nullable=False, comment='Title')
body = Column(String, nullable=True, comment='Body')
pic = Column(String, nullable=True, comment='Picture')
created_at = Column(Integer, default=lambda: int(time.time()))
created_by = Column(ForeignKey("author.id"), comment="Created By")
created_by = Column(ForeignKey('author.id'), comment='Created By')
published_at = Column(Integer, default=lambda: int(time.time()))

View File

@@ -8,22 +8,22 @@ from orm.author import Author
class CommunityAuthor(Base):
__tablename__ = "community_author"
__tablename__ = 'community_author'
id = None # type: ignore
author = Column(ForeignKey("author.id"), primary_key=True)
community = Column(ForeignKey("community.id"), primary_key=True)
author = Column(ForeignKey('author.id'), primary_key=True)
community = Column(ForeignKey('community.id'), primary_key=True)
joined_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
role = Column(String, nullable=False)
class Community(Base):
__tablename__ = "community"
__tablename__ = 'community'
name = Column(String, nullable=False)
slug = Column(String, nullable=False, unique=True)
desc = Column(String, nullable=False, default="")
pic = Column(String, nullable=False, default="")
desc = Column(String, nullable=False, default='')
pic = Column(String, nullable=False, default='')
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
authors = relationship(Author, secondary="community_author")
authors = relationship(Author, secondary='community_author')

View File

@@ -7,19 +7,19 @@ from services.db import Base
class InviteStatus(Enumeration):
PENDING = "PENDING"
ACCEPTED = "ACCEPTED"
REJECTED = "REJECTED"
PENDING = 'PENDING'
ACCEPTED = 'ACCEPTED'
REJECTED = 'REJECTED'
class Invite(Base):
__tablename__ = "invite"
__tablename__ = 'invite'
inviter_id = Column(ForeignKey("author.id"), primary_key=True)
author_id = Column(ForeignKey("author.id"), primary_key=True)
shout_id = Column(ForeignKey("shout.id"), primary_key=True)
inviter_id = Column(ForeignKey('author.id'), primary_key=True)
author_id = Column(ForeignKey('author.id'), primary_key=True)
shout_id = Column(ForeignKey('shout.id'), primary_key=True)
status = Column(String, default=InviteStatus.PENDING.value)
inviter = relationship("author", foreign_keys=[inviter_id])
author = relationship("author", foreign_keys=[author_id])
shout = relationship("shout")
inviter = relationship('author', foreign_keys=[inviter_id])
author = relationship('author', foreign_keys=[author_id])
shout = relationship('shout')

View File

@@ -10,34 +10,34 @@ class ReactionKind(Enumeration):
# TYPE = <reaction index> # rating diff
# editor mode
AGREE = "AGREE" # +1
DISAGREE = "DISAGREE" # -1
ASK = "ASK" # +0
PROPOSE = "PROPOSE" # +0
PROOF = "PROOF" # +1
DISPROOF = "DISPROOF" # -1
ACCEPT = "ACCEPT" # +1
REJECT = "REJECT" # -1
AGREE = 'AGREE' # +1
DISAGREE = 'DISAGREE' # -1
ASK = 'ASK' # +0
PROPOSE = 'PROPOSE' # +0
PROOF = 'PROOF' # +1
DISPROOF = 'DISPROOF' # -1
ACCEPT = 'ACCEPT' # +1
REJECT = 'REJECT' # -1
# public feed
QUOTE = "QUOTE" # +0 TODO: use to bookmark in collection
COMMENT = "COMMENT" # +0
LIKE = "LIKE" # +1
DISLIKE = "DISLIKE" # -1
QUOTE = 'QUOTE' # +0 TODO: use to bookmark in collection
COMMENT = 'COMMENT' # +0
LIKE = 'LIKE' # +1
DISLIKE = 'DISLIKE' # -1
class Reaction(Base):
__tablename__ = "reaction"
__tablename__ = 'reaction'
body = Column(String, default="", comment="Reaction Body")
body = Column(String, default='', comment='Reaction Body')
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
updated_at = Column(Integer, nullable=True, comment="Updated at")
deleted_at = Column(Integer, nullable=True, comment="Deleted at")
deleted_by = Column(ForeignKey("author.id"), nullable=True)
reply_to = Column(ForeignKey("reaction.id"), nullable=True)
quote = Column(String, nullable=True, comment="Original quoted text")
shout = Column(ForeignKey("shout.id"), nullable=False)
created_by = Column(ForeignKey("author.id"), nullable=False)
updated_at = Column(Integer, nullable=True, comment='Updated at')
deleted_at = Column(Integer, nullable=True, comment='Deleted at')
deleted_by = Column(ForeignKey('author.id'), nullable=True)
reply_to = Column(ForeignKey('reaction.id'), nullable=True)
quote = Column(String, nullable=True, comment='Original quoted text')
shout = Column(ForeignKey('shout.id'), nullable=False)
created_by = Column(ForeignKey('author.id'), nullable=False)
kind = Column(String, nullable=False)
oid = Column(String)

View File

@@ -11,44 +11,44 @@ from orm.topic import Topic
class ShoutTopic(Base):
__tablename__ = "shout_topic"
__tablename__ = 'shout_topic'
id = None # type: ignore
shout = Column(ForeignKey("shout.id"), primary_key=True)
topic = Column(ForeignKey("topic.id"), primary_key=True)
shout = Column(ForeignKey('shout.id'), primary_key=True)
topic = Column(ForeignKey('topic.id'), primary_key=True)
main = Column(Boolean, nullable=True)
class ShoutReactionsFollower(Base):
__tablename__ = "shout_reactions_followers"
__tablename__ = 'shout_reactions_followers'
id = None # type: ignore
follower = Column(ForeignKey("author.id"), primary_key=True)
shout = Column(ForeignKey("shout.id"), primary_key=True)
follower = Column(ForeignKey('author.id'), primary_key=True)
shout = Column(ForeignKey('shout.id'), primary_key=True)
auto = Column(Boolean, nullable=False, default=False)
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
deleted_at = Column(Integer, nullable=True)
class ShoutAuthor(Base):
__tablename__ = "shout_author"
__tablename__ = 'shout_author'
id = None # type: ignore
shout = Column(ForeignKey("shout.id"), primary_key=True)
author = Column(ForeignKey("author.id"), primary_key=True)
caption = Column(String, nullable=True, default="")
shout = Column(ForeignKey('shout.id'), primary_key=True)
author = Column(ForeignKey('author.id'), primary_key=True)
caption = Column(String, nullable=True, default='')
class ShoutCommunity(Base):
__tablename__ = "shout_community"
__tablename__ = 'shout_community'
id = None # type: ignore
shout = Column(ForeignKey("shout.id"), primary_key=True)
community = Column(ForeignKey("community.id"), primary_key=True)
shout = Column(ForeignKey('shout.id'), primary_key=True)
community = Column(ForeignKey('community.id'), primary_key=True)
class Shout(Base):
__tablename__ = "shout"
__tablename__ = 'shout'
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
updated_at = Column(Integer, nullable=True)
@@ -56,28 +56,28 @@ class Shout(Base):
featured_at = Column(Integer, nullable=True)
deleted_at = Column(Integer, nullable=True)
created_by = Column(ForeignKey("author.id"), nullable=False)
updated_by = Column(ForeignKey("author.id"), nullable=True)
deleted_by = Column(ForeignKey("author.id"), nullable=True)
created_by = Column(ForeignKey('author.id'), nullable=False)
updated_by = Column(ForeignKey('author.id'), nullable=True)
deleted_by = Column(ForeignKey('author.id'), nullable=True)
body = Column(String, nullable=False, comment="Body")
body = Column(String, nullable=False, comment='Body')
slug = Column(String, unique=True)
cover = Column(String, nullable=True, comment="Cover image url")
cover_caption = Column(String, nullable=True, comment="Cover image alt caption")
cover = Column(String, nullable=True, comment='Cover image url')
cover_caption = Column(String, nullable=True, comment='Cover image alt caption')
lead = Column(String, nullable=True)
description = Column(String, nullable=True)
title = Column(String, nullable=False)
subtitle = Column(String, nullable=True)
layout = Column(String, nullable=False, default="article")
layout = Column(String, nullable=False, default='article')
media = Column(JSON, nullable=True)
authors = relationship(Author, secondary="shout_author")
topics = relationship(Topic, secondary="shout_topic")
communities = relationship(Community, secondary="shout_community")
authors = relationship(Author, secondary='shout_author')
topics = relationship(Topic, secondary='shout_topic')
communities = relationship(Community, secondary='shout_community')
reactions = relationship(Reaction)
lang = Column(String, nullable=False, default="ru", comment="Language")
version_of = Column(ForeignKey("shout.id"), nullable=True)
lang = Column(String, nullable=False, default='ru', comment='Language')
version_of = Column(ForeignKey('shout.id'), nullable=True)
oid = Column(String, nullable=True)
seo = Column(String, nullable=True) # JSON

View File

@@ -6,21 +6,21 @@ from services.db import Base
class TopicFollower(Base):
__tablename__ = "topic_followers"
__tablename__ = 'topic_followers'
id = None # type: ignore
follower = Column(ForeignKey("author.id"), primary_key=True)
topic = Column(ForeignKey("topic.id"), primary_key=True)
follower = Column(ForeignKey('author.id'), primary_key=True)
topic = Column(ForeignKey('topic.id'), primary_key=True)
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
auto = Column(Boolean, nullable=False, default=False)
class Topic(Base):
__tablename__ = "topic"
__tablename__ = 'topic'
slug = Column(String, unique=True)
title = Column(String, nullable=False, comment="Title")
body = Column(String, nullable=True, comment="Body")
pic = Column(String, nullable=True, comment="Picture")
community = Column(ForeignKey("community.id"), default=1)
oid = Column(String, nullable=True, comment="Old ID")
title = Column(String, nullable=False, comment='Title')
body = Column(String, nullable=True, comment='Body')
pic = Column(String, nullable=True, comment='Picture')
community = Column(ForeignKey('community.id'), default=1)
oid = Column(String, nullable=True, comment='Old ID')

View File

@@ -6,7 +6,7 @@ from services.db import Base
class User(Base):
__tablename__ = "authorizer_users"
__tablename__ = 'authorizer_users'
id = Column(String, primary_key=True, unique=True, nullable=False, default=None)
key = Column(String)
@@ -24,7 +24,7 @@ class User(Base):
# preferred_username = Column(String, nullable=False)
picture = Column(String)
revoked_timestamp = Column(Integer)
roles = Column(String, default="author, reader")
signup_methods = Column(String, default="magic_link_login")
roles = Column(String, default='author, reader')
signup_methods = Column(String, default='magic_link_login')
created_at = Column(Integer, default=lambda: int(time.time()))
updated_at = Column(Integer, default=lambda: int(time.time()))