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:
parent
db425022dd
commit
fb7dd855de
@ -346,7 +346,8 @@ class MediaComment(Document):
|
|||||||
def media_entry(self):
|
def media_entry(self):
|
||||||
return self.db.MediaEntry.find_one({'_id': self['media_entry']})
|
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']})
|
return self.db.User.find_one({'_id': self['author']})
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if comments %}
|
{% if comments %}
|
||||||
{% for comment in comments %}
|
{% for comment in comments %}
|
||||||
{% set comment_author = comment.author() %}
|
{% set comment_author = comment.get_author %}
|
||||||
{% if pagination.active_id == comment._id %}
|
{% if pagination.active_id == comment._id %}
|
||||||
<div class="comment_wrapper comment_active" id="comment-{{ comment._id }}">
|
<div class="comment_wrapper comment_active" id="comment-{{ comment._id }}">
|
||||||
<a name="comment" id="comment"></a>
|
<a name="comment" id="comment"></a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user