This commit is contained in:
parent
811086de83
commit
6377bc3d64
|
@ -3,8 +3,7 @@ import time
|
|||
from sqlalchemy import Column, ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from orm.author import Author
|
||||
from services.db import Base, local_session
|
||||
from services.db import Base
|
||||
|
||||
|
||||
class CommunityAuthor(Base):
|
||||
|
@ -26,16 +25,4 @@ class Community(Base):
|
|||
pic = Column(String, nullable=False, default='')
|
||||
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
|
||||
|
||||
authors = relationship(lambda: Author, secondary=CommunityAuthor.__tablename__)
|
||||
|
||||
@staticmethod
|
||||
def init_table():
|
||||
with local_session('orm.community') as session:
|
||||
d = session.query(Community).filter(Community.slug == 'discours').first()
|
||||
if not d:
|
||||
d = Community(name='Дискурс', slug='discours')
|
||||
session.add(d)
|
||||
session.commit()
|
||||
print('[orm.community] created community %s' % d.slug)
|
||||
Community.default_community = d
|
||||
print('[orm.community] default community is %s' % d.slug)
|
||||
authors = relationship('author', secondary='community_author')
|
||||
|
|
|
@ -3,8 +3,6 @@ from enum import Enum as Enumeration
|
|||
from sqlalchemy import Column, ForeignKey, String
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from orm.author import Author
|
||||
from orm.shout import Shout
|
||||
from services.db import Base
|
||||
|
||||
|
||||
|
@ -22,6 +20,6 @@ class Invite(Base):
|
|||
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')
|
||||
|
|
12
orm/shout.py
12
orm/shout.py
|
@ -3,10 +3,6 @@ import time
|
|||
from sqlalchemy import JSON, Boolean, Column, ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from orm.author import Author
|
||||
from orm.community import Community
|
||||
from orm.reaction import Reaction
|
||||
from orm.topic import Topic
|
||||
from services.db import Base
|
||||
|
||||
|
||||
|
@ -71,10 +67,10 @@ class Shout(Base):
|
|||
layout = Column(String, nullable=False, default='article')
|
||||
media = Column(JSON, nullable=True)
|
||||
|
||||
authors = relationship(lambda: Author, secondary='shout_author')
|
||||
topics = relationship(lambda: Topic, secondary='shout_topic')
|
||||
communities = relationship(lambda: Community, secondary='shout_community')
|
||||
reactions = relationship(lambda: Reaction)
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user