From: hernani Date: Sat, 1 Jan 2011 18:56:21 +0000 (+0000) Subject: Should auto link old stuff in the node cache migration. X-Git-Tag: live~474 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/2d85b056fcba28af281407e80b7c4c4c61229fd3 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 --- 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()