From 2d85b056fcba28af281407e80b7c4c4c61229fd3 Mon Sep 17 00:00:00 2001 From: hernani Date: Sat, 1 Jan 2011 18:56:21 +0000 Subject: [PATCH] Should auto link old stuff in the node cache migration. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@660 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/migrations/0044_markdown_cache_migration.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/forum/migrations/0044_markdown_cache_migration.py b/forum/migrations/0044_markdown_cache_migration.py index 7ae4abd..ac31742 100644 --- a/forum/migrations/0044_markdown_cache_migration.py +++ b/forum/migrations/0044_markdown_cache_migration.py @@ -1,4 +1,5 @@ # encoding: utf-8 +import os, sys import datetime from south.db import db from south.v2 import DataMigration @@ -13,11 +14,20 @@ from forum.utils.html import sanitize_html class Migration(DataMigration): def forwards(self, orm): + sys.path.append(os.path.join(os.path.dirname(__file__),'../markdownext')) + count = orm.Node.objects.count() progress = ProgressBar(count) for node in orm.Node.objects.all(): - node.body = mark_safe(sanitize_html(markdown.markdown(node.body))) + rev = node.active_revision + + if not rev: + try: + rev = node.revisions.order_by('-revision')[0] + except: + continue + node.body = sanitize_html(markdown.markdown(rev.body, ['urlize'])) node.save() progress.update() -- 2.39.5