aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mediagoblin/db/mixin.py8
-rw-r--r--mediagoblin/db/mongo/migrations.py20
-rw-r--r--mediagoblin/db/mongo/models.py4
-rw-r--r--mediagoblin/db/sql/convert.py2
-rw-r--r--mediagoblin/db/sql/models.py1
-rw-r--r--mediagoblin/edit/views.py5
-rw-r--r--mediagoblin/listings/views.py2
-rw-r--r--mediagoblin/submit/views.py4
-rw-r--r--mediagoblin/user_pages/views.py2
9 files changed, 27 insertions, 21 deletions
diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py
index 2ff08722..4e3800ab 100644
--- a/mediagoblin/db/mixin.py
+++ b/mediagoblin/db/mixin.py
@@ -46,6 +46,14 @@ class UserMixin(object):
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):
"""
diff --git a/mediagoblin/db/mongo/migrations.py b/mediagoblin/db/mongo/migrations.py
index 74a810c1..57da7dd8 100644
--- a/mediagoblin/db/mongo/migrations.py
+++ b/mediagoblin/db/mongo/migrations.py
@@ -29,6 +29,16 @@ def add_table_field(db, table_name, field_name, default_value):
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.
@@ -118,11 +128,9 @@ def mediaentry_add_license(database):
@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')
diff --git a/mediagoblin/db/mongo/models.py b/mediagoblin/db/mongo/models.py
index c1282f4a..db38d502 100644
--- a/mediagoblin/db/mongo/models.py
+++ b/mediagoblin/db/mongo/models.py
@@ -110,9 +110,6 @@ class MediaEntry(Document, MediaEntryMixin):
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' ;)
@@ -177,7 +174,6 @@ class MediaEntry(Document, MediaEntryMixin):
'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.
diff --git a/mediagoblin/db/sql/convert.py b/mediagoblin/db/sql/convert.py
index a098927f..9d276866 100644
--- a/mediagoblin/db/sql/convert.py
+++ b/mediagoblin/db/sql/convert.py
@@ -77,7 +77,7 @@ def convert_media_entries(mk_db):
new_entry = MediaEntry()
copy_attrs(entry, new_entry,
('title', 'slug', 'created',
- 'description', 'description_html',
+ 'description',
'media_type', 'state', 'license',
'fail_error',
'queued_task_id',))
diff --git a/mediagoblin/db/sql/models.py b/mediagoblin/db/sql/models.py
index 3cf4ff40..72591f4e 100644
--- a/mediagoblin/db/sql/models.py
+++ b/mediagoblin/db/sql/models.py
@@ -85,7 +85,6 @@ class MediaEntry(Base, MediaEntryMixin):
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?
diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py
index 47761f23..3df36e8e 100644
--- a/mediagoblin/edit/views.py
+++ b/mediagoblin/edit/views.py
@@ -34,7 +34,7 @@ from mediagoblin.tools.response import render_to_response, redirect
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
@@ -72,9 +72,6 @@ def edit_media(request, media):
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'])
diff --git a/mediagoblin/listings/views.py b/mediagoblin/listings/views.py
index 48320cb2..ba23fc46 100644
--- a/mediagoblin/listings/views.py
+++ b/mediagoblin/listings/views.py
@@ -91,7 +91,7 @@ def tag_atom_feed(request):
'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,
diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py
index cdd097ec..845400ca 100644
--- a/mediagoblin/submit/views.py
+++ b/mediagoblin/submit/views.py
@@ -28,7 +28,7 @@ _log = logging.getLogger(__name__)
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
@@ -66,8 +66,6 @@ def submit_start(request):
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
diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py
index 82791278..46435d81 100644
--- a/mediagoblin/user_pages/views.py
+++ b/mediagoblin/user_pages/views.py
@@ -250,7 +250,7 @@ def atom_feed(request):
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={