diff options
author | Jef van Schendel <jefvanschendel@gmail.com> | 2011-06-20 16:33:14 +0200 |
---|---|---|
committer | Jef van Schendel <jefvanschendel@gmail.com> | 2011-06-20 16:33:14 +0200 |
commit | 2d1f91cc41aca908502ea1d18687b902a5fd90a1 (patch) | |
tree | 1d6d425a8ec7a7bfb8490c88d87806d856336d1e /mediagoblin/db | |
parent | 76e21adbd8756159d83bef99b335398519b338f3 (diff) | |
parent | 5c441e75ebc4ad63c3a5362d9bc451abe97984d2 (diff) | |
download | mediagoblin-2d1f91cc41aca908502ea1d18687b902a5fd90a1.tar.lz mediagoblin-2d1f91cc41aca908502ea1d18687b902a5fd90a1.tar.xz mediagoblin-2d1f91cc41aca908502ea1d18687b902a5fd90a1.zip |
Merge remote-tracking branch 'gitorious/master'
Diffstat (limited to 'mediagoblin/db')
-rw-r--r-- | mediagoblin/db/migrations.py | 16 | ||||
-rw-r--r-- | mediagoblin/db/models.py | 3 |
2 files changed, 18 insertions, 1 deletions
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py index f1f625b7..b87988fe 100644 --- a/mediagoblin/db/migrations.py +++ b/mediagoblin/db/migrations.py @@ -14,6 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from mediagoblin.util import cleaned_markdown_conversion + from mongokit import DocumentMigration @@ -33,5 +35,19 @@ class MediaEntryMigration(DocumentMigration): self.collection.update( self.target, self.update, multi=True, safe=True) + def allmigration02_add_description_html(self): + """ + Now that we can have rich descriptions via Markdown, we should + update all existing entries to record the rich description versions. + """ + self.target = {'description_html': {'$exists': False}} + + if not self.status: + for doc in self.collection.find(self.target): + self.update = { + '$set': { + 'description_html': cleaned_markdown_conversion( + doc['description'])}} + MIGRATE_CLASSES = ['MediaEntry'] diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index d77cf619..e034cc29 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -73,7 +73,8 @@ class MediaEntry(Document): 'title': unicode, 'slug': unicode, 'created': datetime.datetime, - 'description': unicode, + 'description': unicode, # May contain markdown/up + 'description_html': unicode, # May contain plaintext, or HTML 'media_type': unicode, 'media_data': dict, # extra data relevant to this media_type 'plugin_data': dict, # plugins can dump stuff here. |