diff options
author | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-02-19 12:14:13 +0100 |
---|---|---|
committer | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-03-07 21:32:20 +0100 |
commit | 814334f6eb95de5521796f798104e216706fe81f (patch) | |
tree | 0f326aa555604b2713f1ad6c8bf3b1bb3eb79be8 /mediagoblin/db/mongo/models.py | |
parent | 74743bed0a600db13ffb98e9bfe0bffff17720ee (diff) | |
download | mediagoblin-814334f6eb95de5521796f798104e216706fe81f.tar.lz mediagoblin-814334f6eb95de5521796f798104e216706fe81f.tar.xz mediagoblin-814334f6eb95de5521796f798104e216706fe81f.zip |
Generic generate_slug for mongo and sql.
Using the new check_media_slug_used it is possible to have
one generic generate_slug in the mixin class instead of in
each db class.
In the sql variant self.id is not always set: If the slug
alone would create a dupe the current code decides for "no
slug at all".
Diffstat (limited to 'mediagoblin/db/mongo/models.py')
-rw-r--r-- | mediagoblin/db/mongo/models.py | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/mediagoblin/db/mongo/models.py b/mediagoblin/db/mongo/models.py index c86adbb6..2e35a2b8 100644 --- a/mediagoblin/db/mongo/models.py +++ b/mediagoblin/db/mongo/models.py @@ -18,11 +18,9 @@ import datetime from mongokit import Document -from mediagoblin import mg_globals from mediagoblin.db.mongo import migrations from mediagoblin.db.mongo.util import ASCENDING, DESCENDING, ObjectId from mediagoblin.tools.pagination import Pagination -from mediagoblin.tools import url from mediagoblin.db.mixin import UserMixin, MediaEntryMixin, MediaCommentMixin @@ -232,15 +230,6 @@ class MediaEntry(Document, MediaEntryMixin): return self.db.MediaComment.find({ 'media_entry': self._id}).sort('created', order) - def generate_slug(self): - self.slug = url.slugify(self.title) - - duplicate = mg_globals.database.media_entries.find_one( - {'slug': self.slug}) - - if duplicate: - self.slug = "%s-%s" % (self._id, self.slug) - def url_to_prev(self, urlgen): """ Provide a url to the previous entry from this user, if there is one |