From: Elrond Date: Sun, 4 Dec 2011 18:57:42 +0000 (+0100) Subject: Dot-Notation for MediaEntry.slug X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5da0bf901be7551e9708dd248319ff57d7b29a57;p=mediagoblin.git Dot-Notation for MediaEntry.slug --- 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(