From 02ede85826e0cede55a3ae23b16508bf606cbb45 Mon Sep 17 00:00:00 2001 From: Elrond Date: Mon, 2 Jan 2012 13:07:16 +0100 Subject: [PATCH] Create a fully functional get_comments for SQL Using proper sqlalchemy syntax instead of the emulated mongo one. --- mediagoblin/db/sql/models.py | 7 +++++++ 1 file changed, 7 insertions(+) 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" -- 2.25.1