From: Christopher Allan Webber Date: Thu, 14 Jul 2011 05:00:24 +0000 (-0500) Subject: First migration: Add markdown bio! X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5ebe69e5a0cdaf7e27d485624465834eb3132c13;p=mediagoblin.git First migration: Add markdown bio! --- diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py index 683a57f3..f398f4b3 100644 --- a/mediagoblin/db/migrations.py +++ b/mediagoblin/db/migrations.py @@ -15,10 +15,24 @@ # along with this program. If not, see . from mediagoblin.db.util import RegisterMigration +from mediagoblin.util import cleaned_markdown_conversion + # Please see mediagoblin/tests/test_migrations.py for some examples of # basic migrations. -# @RegisterMigration(1) -# def do_something(database): -# pass + +@RegisterMigration(1) +def user_add_bio_html(database): + """ + Users now have richtext bios via Markdown, reflect appropriately. + """ + collection = database['users'] + + target = collection.find( + {'bio_html': {'$exists': False}}) + + for document in target: + document['bio_html'] = cleaned_markdown_conversion( + document['bio']) + collection.save(document)