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.
This commit is contained in:
Elrond 2011-12-18 22:52:49 +01:00
parent db425022dd
commit fb7dd855de
2 changed files with 3 additions and 2 deletions

View File

@ -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']})

View File

@ -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 %}
<div class="comment_wrapper comment_active" id="comment-{{ comment._id }}">
<a name="comment" id="comment"></a>