Work on blog

rewrite entire blog section
This commit is contained in:
2025-12-13 02:30:50 +01:00
parent 68d798845d
commit a5ba0b90bb
14 changed files with 354 additions and 72 deletions

View File

@@ -45,7 +45,6 @@ def init_db(database):
category TEXT,
author TEXT,
status TEXT,
blog_theme TEXT,
PRIMARY KEY(title, author)
)
""")
@@ -74,19 +73,22 @@ def check_directories(users_folder):
print("Le dossier {} a été créé".format(users_folder))
def db_migrate(database):
invitations_col = False
lost_password_token_col = False
totp_col = False
blog_unified_col = False
blog_theme_col = False
updated_col = False
creation_date_col = False
content_col = False
conn = sqlite3.connect(database)
cursor = conn.cursor()
cursor.execute("""SELECT name FROM PRAGMA_TABLE_INFO('users');""")
db_columns = cursor.fetchall()
invitations_col = False
lost_password_token_col = False
totp_col = False
blog_theme_col = False
updated_col = False
creation_date_col = False
content_col = False
for col in db_columns:
if "invitations" == col[0]:
invitations_col = True
@@ -94,12 +96,13 @@ def db_migrate(database):
lost_password_token_col = True
if "totp" == col[0]:
totp_col = True
if "blog_theme" == col[0]:
blog_theme_col = True
cursor.execute("""SELECT name FROM PRAGMA_TABLE_INFO('Blog_posts');""")
db_columns = cursor.fetchall()
for col in db_columns:
if "blog_theme" == col[0]:
blog_theme_col = True
if "last_updated" == col[0]:
updated_col = True
if "content" == col[0]:
@@ -125,8 +128,7 @@ def db_migrate(database):
cursor.execute("""ALTER TABLE Users ADD COLUMN totp CHAR(40);""")
conn.commit()
print ("Ajout du champ totp dans la table Users")
if not(blog_theme_col):
cursor.execute("""ALTER TABLE Blog_posts ADD COLUMN blog_theme TEXT;""")