class MediaEntryMixin(object):
+ @property
+ def description_html(self):
+ """
+ Rendered version of the description, run through
+ Markdown and cleaned with our cleaning tool.
+ """
+ return cleaned_markdown_conversion(self.description)
+
def get_display_media(self, media_map,
fetch_order=common.DISPLAY_IMAGE_FETCHING_ORDER):
"""
multi=True)
+def drop_table_field(db, table_name, field_name):
+ """
+ Drop an old field from a table/collection
+ """
+ db[table_name].update(
+ {field_name: {'$exists': True}},
+ {'$unset': {field_name: 1}},
+ multi=True)
+
+
# Please see mediagoblin/tests/test_migrations.py for some examples of
# basic migrations.
@RegisterMigration(9)
-def user_remove_bio_html(database):
+def remove_calculated_html(database):
"""
- Drop bio_html again and calculate things on the fly (and cache)
+ Drop bio_html, description_html again and calculate things on the fly (and cache)
"""
- database['users'].update(
- {'bio_html': {'$exists': True}},
- {'$unset': {'bio_html': 1}},
- multi=True)
+ drop_table_field(database, 'users', 'bio_html')
+ drop_table_field(database, 'media_entries', 'description_html')
up with MarkDown for slight fanciness (links, boldness, italics,
paragraphs...)
- - description_html: Rendered version of the description, run through
- Markdown and cleaned with our cleaning tool.
-
- media_type: What type of media is this? Currently we only support
'image' ;)
'slug': unicode,
'created': datetime.datetime,
'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.
new_entry = MediaEntry()
copy_attrs(entry, new_entry,
('title', 'slug', 'created',
- 'description', 'description_html',
+ 'description',
'media_type', 'state', 'license',
'fail_error',
'queued_task_id',))
slug = Column(Unicode)
created = Column(DateTime, nullable=False, default=datetime.datetime.now)
description = Column(UnicodeText) # ??
- description_html = Column(UnicodeText) # ??
media_type = Column(Unicode, nullable=False)
state = Column(Unicode, default=u'unprocessed', nullable=False)
# or use sqlalchemy.types.Enum?
from mediagoblin.tools.translate import pass_to_ugettext as _
from mediagoblin.tools.text import (
clean_html, convert_to_tag_list_of_dicts,
- media_tags_as_string, cleaned_markdown_conversion)
+ media_tags_as_string)
from mediagoblin.tools.licenses import SUPPORTED_LICENSES
media.tags = convert_to_tag_list_of_dicts(
request.POST.get('tags'))
- media.description_html = cleaned_markdown_conversion(
- media.description)
-
media.license = unicode(request.POST.get('license', '')) or None
media.slug = unicode(request.POST['slug'])
'type': 'text/html'}])
for entry in cursor:
feed.add(entry.get('title'),
- entry.get('description_html'),
+ entry.description_html,
id=entry.url_for_self(request.urlgen,qualified=True),
content_type='html',
author={'name': entry.get_uploader.username,
from werkzeug.utils import secure_filename
from mediagoblin.db.util import ObjectId
-from mediagoblin.tools.text import cleaned_markdown_conversion, convert_to_tag_list_of_dicts
+from mediagoblin.tools.text import convert_to_tag_list_of_dicts
from mediagoblin.tools.translate import pass_to_ugettext as _
from mediagoblin.tools.response import render_to_response, redirect
from mediagoblin.decorators import require_active_login
or unicode(splitext(filename)[0]))
entry.description = unicode(request.POST.get('description'))
- entry.description_html = cleaned_markdown_conversion(
- entry.description)
entry.license = unicode(request.POST.get('license', "")) or None
for entry in cursor:
feed.add(entry.get('title'),
- entry.get('description_html'),
+ entry.description_html,
id=entry.url_for_self(request.urlgen,qualified=True),
content_type='html',
author={