From fb7dd855de987d4e3dded1e55cad09a9fe6120cc Mon Sep 17 00:00:00 2001 From: Elrond Date: Sun, 18 Dec 2011 22:52:49 +0100 Subject: [PATCH] Turn MediaComment's author() into get_author property 1) MediaComment's author method conflicts with the author field. So rename it to get_author. 2) Turn it from a normal function into a python property. That means you call it by ".get_author" not by ".get_author()". This is exactly what sqlalchemy gives us free of charge. --- mediagoblin/db/mongo/models.py | 3 ++- mediagoblin/templates/mediagoblin/user_pages/media.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mediagoblin/db/mongo/models.py b/mediagoblin/db/mongo/models.py index e2ac1b5a..0e31fc1c 100644 --- a/mediagoblin/db/mongo/models.py +++ b/mediagoblin/db/mongo/models.py @@ -346,7 +346,8 @@ class MediaComment(Document): def media_entry(self): return self.db.MediaEntry.find_one({'_id': self['media_entry']}) - def author(self): + @property + def get_author(self): return self.db.User.find_one({'_id': self['author']}) diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index b9e31667..c171dd5a 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -109,7 +109,7 @@ {% endif %} {% if comments %} {% for comment in comments %} - {% set comment_author = comment.author() %} + {% set comment_author = comment.get_author %} {% if pagination.active_id == comment._id %}