mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
migration post one language
This commit is contained in:
parent
98207edb13
commit
219b22e34a
1 changed files with 25 additions and 27 deletions
|
@ -169,6 +169,28 @@ class ChatMessage(db.Model):
|
|||
sender = db.relationship('User', foreign_keys=[sender_id])
|
||||
|
||||
|
||||
class Tag(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(256))
|
||||
|
||||
|
||||
class Language(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
code = db.Column(db.String(5), index=True)
|
||||
name = db.Column(db.String(50))
|
||||
|
||||
|
||||
community_language = db.Table('community_language', db.Column('community_id', db.Integer, db.ForeignKey('community.id')),
|
||||
db.Column('language_id', db.Integer, db.ForeignKey('language.id')),
|
||||
db.PrimaryKeyConstraint('community_id', 'language_id')
|
||||
)
|
||||
|
||||
post_tag = db.Table('post_tag', db.Column('post_id', db.Integer, db.ForeignKey('post.id')),
|
||||
db.Column('tag_id', db.Integer, db.ForeignKey('tag.id')),
|
||||
db.PrimaryKeyConstraint('post_id', 'tag_id')
|
||||
)
|
||||
|
||||
|
||||
class File(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
file_path = db.Column(db.String(255))
|
||||
|
@ -365,6 +387,7 @@ class Community(db.Model):
|
|||
replies = db.relationship('PostReply', lazy='dynamic', cascade="all, delete-orphan")
|
||||
icon = db.relationship('File', foreign_keys=[icon_id], single_parent=True, backref='community', cascade="all, delete-orphan")
|
||||
image = db.relationship('File', foreign_keys=[image_id], single_parent=True, cascade="all, delete-orphan")
|
||||
languages = db.relationship('Language', lazy='dynamic', secondary=community_language, backref=db.backref('communities', lazy='dynamic'))
|
||||
|
||||
@cache.memoize(timeout=500)
|
||||
def icon_image(self, size='default') -> str:
|
||||
|
@ -895,7 +918,9 @@ class Post(db.Model):
|
|||
language = db.Column(db.String(10))
|
||||
edited_at = db.Column(db.DateTime)
|
||||
reports = db.Column(db.Integer, default=0) # how many times this post has been reported. Set to -1 to ignore reports
|
||||
language_id = db.Column(db.Integer, index=True)
|
||||
cross_posts = db.Column(MutableList.as_mutable(ARRAY(db.Integer)))
|
||||
tags = db.relationship('Tag', lazy='dynamic', secondary=post_tag, backref=db.backref('posts', lazy='dynamic'))
|
||||
|
||||
ap_id = db.Column(db.String(255), index=True)
|
||||
ap_create_id = db.Column(db.String(100))
|
||||
|
@ -1294,33 +1319,6 @@ class Site(db.Model):
|
|||
return User.query.filter_by(deleted=False, banned=False).join(user_role).filter(user_role.c.role_id == 4).all()
|
||||
|
||||
|
||||
class Tag(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(256))
|
||||
|
||||
|
||||
class Language(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
code = db.Column(db.String(5), index=True)
|
||||
name = db.Column(db.String(50))
|
||||
|
||||
|
||||
post_language = db.Table('post_language', db.Column('post_id', db.Integer, db.ForeignKey('post.id')),
|
||||
db.Column('language_id', db.Integer, db.ForeignKey('language.id')),
|
||||
db.PrimaryKeyConstraint('post_id', 'language_id')
|
||||
)
|
||||
|
||||
community_language = db.Table('community_language', db.Column('community_id', db.Integer, db.ForeignKey('community.id')),
|
||||
db.Column('language_id', db.Integer, db.ForeignKey('language.id')),
|
||||
db.PrimaryKeyConstraint('community_id', 'language_id')
|
||||
)
|
||||
|
||||
post_tag = db.Table('post_tag', db.Column('post_id', db.Integer, db.ForeignKey('post.id')),
|
||||
db.Column('tag_id', db.Integer, db.ForeignKey('tag.id')),
|
||||
db.PrimaryKeyConstraint('post_id', 'tag_id')
|
||||
)
|
||||
|
||||
|
||||
@login.user_loader
|
||||
def load_user(id):
|
||||
return User.query.get(int(id))
|
||||
|
|
Loading…
Reference in a new issue