aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/sql/models.py
diff options
context:
space:
mode:
authorElrond <elrond+mediagoblin.org@samba-tng.org>2012-01-02 13:07:16 +0100
committerElrond <elrond+mediagoblin.org@samba-tng.org>2012-01-22 18:40:42 +0100
commit02ede85826e0cede55a3ae23b16508bf606cbb45 (patch)
tree32dd31452b15fbab87f833a515f822a1ff88bd2d /mediagoblin/db/sql/models.py
parentee4fb8125aef6cc4ba357b695483da51bed4310d (diff)
downloadmediagoblin-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.py7
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"