add markup metadata to sig; reparse sigs on init
This commit is contained in:
@@ -48,21 +48,38 @@ def create_deleted_user():
|
||||
"permission": PermissionLevel.SYSTEM.value,
|
||||
})
|
||||
|
||||
def reparse_posts():
|
||||
def reparse_babycode():
|
||||
print('Re-parsing babycode, this may take a while...')
|
||||
from .db import db
|
||||
post_histories = PostHistory.findall([
|
||||
('markup_language', '=', 'babycode'),
|
||||
('format_version', 'IS NOT', BABYCODE_VERSION)
|
||||
])
|
||||
if len(post_histories) == 0:
|
||||
return
|
||||
print('Re-parsing babycode, this may take a while...')
|
||||
with db.transaction():
|
||||
for ph in post_histories:
|
||||
ph.update({
|
||||
'content': babycode_to_html(ph['original_markup']),
|
||||
'format_version': BABYCODE_VERSION,
|
||||
if len(post_histories) > 0:
|
||||
print('Re-parsing user posts...')
|
||||
with db.transaction():
|
||||
for ph in post_histories:
|
||||
ph.update({
|
||||
'content': babycode_to_html(ph['original_markup']),
|
||||
'format_version': BABYCODE_VERSION,
|
||||
})
|
||||
print('Re-parsing posts done.')
|
||||
|
||||
users_with_sigs = Users.findall([
|
||||
('signature_markup_language', '=', 'babycode'),
|
||||
('signature_format_version', 'IS NOT', BABYCODE_VERSION),
|
||||
('signature_original_markup', 'IS NOT', '')
|
||||
])
|
||||
if len(users_with_sigs) > 0:
|
||||
print('Re-parsing user sigs...')
|
||||
with db.transaction():
|
||||
for user in users_with_sigs:
|
||||
user.update({
|
||||
'signature_rendered': babycode_to_html(user['signature_original_markup']),
|
||||
'signature_format_version': BABYCODE_VERSION,
|
||||
})
|
||||
print(f'Re-parsed {len(users_with_sigs)} user sigs.')
|
||||
|
||||
print('Re-parsing done.')
|
||||
|
||||
def create_app():
|
||||
@@ -105,7 +122,7 @@ def create_app():
|
||||
create_admin()
|
||||
create_deleted_user()
|
||||
|
||||
reparse_posts()
|
||||
reparse_babycode()
|
||||
|
||||
from app.routes.app import bp as app_bp
|
||||
from app.routes.topics import bp as topics_bp
|
||||
|
||||
Reference in New Issue
Block a user