diff options
author | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-01-02 13:07:16 +0100 |
---|---|---|
committer | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-01-22 18:40:42 +0100 |
commit | 02ede85826e0cede55a3ae23b16508bf606cbb45 (patch) | |
tree | 32dd31452b15fbab87f833a515f822a1ff88bd2d /mediagoblin/db/sql/models.py | |
parent | ee4fb8125aef6cc4ba357b695483da51bed4310d (diff) | |
download | mediagoblin-02ede85826e0cede55a3ae23b16508bf606cbb45.tar.lz mediagoblin-02ede85826e0cede55a3ae23b16508bf606cbb45.tar.xz mediagoblin-02ede85826e0cede55a3ae23b16508bf606cbb45.zip |
Create a fully functional get_comments for SQL
Using proper sqlalchemy syntax instead of the emulated
mongo one.
Diffstat (limited to 'mediagoblin/db/sql/models.py')
-rw-r--r-- | mediagoblin/db/sql/models.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mediagoblin/db/sql/models.py b/mediagoblin/db/sql/models.py index 507efe62..d5573a56 100644 --- a/mediagoblin/db/sql/models.py +++ b/mediagoblin/db/sql/models.py @@ -109,6 +109,13 @@ class MediaEntry(Base, MediaEntryMixin): # attachment_files # fail_error + def get_comments(self, ascending=False): + order_col = MediaComment.created + if not ascending: + order_col = desc(order_col) + return MediaComment.query.filter_by( + media_entry=self.id).order_by(order_col) + class MediaFile(Base): __tablename__ = "mediafiles" |