From 5da0bf901be7551e9708dd248319ff57d7b29a57 Mon Sep 17 00:00:00 2001 From: Elrond Date: Sun, 4 Dec 2011 19:57:42 +0100 Subject: [PATCH] Dot-Notation for MediaEntry.slug --- mediagoblin/db/models.py | 12 ++++++------ mediagoblin/edit/views.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 7af76b9f..aeee69dd 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -249,13 +249,13 @@ class MediaEntry(Document): pass def generate_slug(self): - self['slug'] = url.slugify(self.title) + self.slug = url.slugify(self.title) duplicate = mg_globals.database.media_entries.find_one( - {'slug': self['slug']}) + {'slug': self.slug}) if duplicate: - self['slug'] = "%s-%s" % (self._id, self['slug']) + self.slug = "%s-%s" % (self._id, self.slug) def url_for_self(self, urlgen): """ @@ -269,7 +269,7 @@ class MediaEntry(Document): return urlgen( 'mediagoblin.user_pages.media_home', user=uploader.username, - media=self['slug']) + media=self.slug) else: return urlgen( 'mediagoblin.user_pages.media_home', @@ -287,7 +287,7 @@ class MediaEntry(Document): if cursor.count(): return urlgen('mediagoblin.user_pages.media_home', user=self.get_uploader().username, - media=unicode(cursor[0]['slug'])) + media=unicode(cursor[0].slug)) def url_to_next(self, urlgen): """ @@ -301,7 +301,7 @@ class MediaEntry(Document): if cursor.count(): return urlgen('mediagoblin.user_pages.media_home', user=self.get_uploader().username, - media=unicode(cursor[0]['slug'])) + media=unicode(cursor[0].slug)) def get_uploader(self): return self.db.User.find_one({'_id': self.uploader}) diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py index feda397d..51661a21 100644 --- a/mediagoblin/edit/views.py +++ b/mediagoblin/edit/views.py @@ -44,7 +44,7 @@ def edit_media(request, media): defaults = dict( title=media.title, - slug=media['slug'], + slug=media.slug, description=media['description'], tags=media_tags_as_string(media['tags'])) @@ -72,7 +72,7 @@ def edit_media(request, media): media['description_html'] = cleaned_markdown_conversion( media['description']) - media['slug'] = unicode(request.POST['slug']) + media.slug = unicode(request.POST['slug']) media.save() return exc.HTTPFound( -- 2.25.1