From ca6fc3c32d0e12bbee89991b6b1a44b8e234c7bd Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Thu, 1 Dec 2022 13:04:38 +0300 Subject: [PATCH] about/bio --- migration/tables/users.py | 11 ++++++----- orm/user.py | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/migration/tables/users.py b/migration/tables/users.py index b30e82c8..53b574d9 100644 --- a/migration/tables/users.py +++ b/migration/tables/users.py @@ -35,11 +35,12 @@ def migrate(entry): slug = entry["profile"].get("path").lower() slug = re.sub('[^0-9a-zA-Z]+', '-', slug).strip() user_dict["slug"] = slug - bio = BeautifulSoup(entry.get("profile").get("bio") or "", features="lxml").text - if bio.startswith('<'): - print('[migration] bio! ' + bio) - bio = BeautifulSoup(bio, features="lxml").text - bio = bio.replace('\(', '(').replace('\)', ')') + bio = (entry.get("profile", {"bio": ""}).get("bio") or "").replace('\(', '(').replace('\)', ')') + bio_html = BeautifulSoup(bio, features="lxml").text + if bio == bio_html: + user_dict["bio"] = bio + else: + user_dict["about"] = bio # userpic try: diff --git a/orm/user.py b/orm/user.py index 2dc25b61..b8853f82 100644 --- a/orm/user.py +++ b/orm/user.py @@ -56,7 +56,8 @@ class User(Base): email = Column(String, unique=True, nullable=False, comment="Email") username = Column(String, nullable=False, comment="Login") password = Column(String, nullable=True, comment="Password") - bio = Column(String, nullable=True, comment="Bio") + bio = Column(String, nullable=True, comment="Bio") # status description + about = Column(String, nullable=True, comment="About") # long and formatted userpic = Column(String, nullable=True, comment="Userpic") name = Column(String, nullable=True, comment="Display name") slug = Column(String, unique=True, comment="User's slug")