1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011 Free Software Foundation, Inc
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 from mediagoblin
.db
.util
import RegisterMigration
18 from mediagoblin
.util
import cleaned_markdown_conversion
21 # Please see mediagoblin/tests/test_migrations.py for some examples of
26 def user_add_bio_html(database
):
28 Users now have richtext bios via Markdown, reflect appropriately.
30 collection
= database
['users']
32 target
= collection
.find(
33 {'bio_html': {'$exists': False}})
35 for document
in target
:
36 document
['bio_html'] = cleaned_markdown_conversion(
38 collection
.save(document
)
42 def mediaentry_mediafiles_main_to_original(database
):
44 Rename "main" media file to "original".
46 collection
= database
['media_entries']
47 target
= collection
.find(
48 {'media_files.main': {'$exists': True}})
50 for document
in target
:
51 original
= document
['media_files'].pop('main')
52 document
['media_files']['original'] = original
54 collection
.save(document
)