From 0db49efe4a8cc32d3060a00a557d993111693b8d Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 8 Jan 2019 21:35:46 +0000 Subject: [PATCH] Fix weird ordering of screenshots --- app/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models.py b/app/models.py index d3cba53a..b1cfbb57 100644 --- a/app/models.py +++ b/app/models.py @@ -380,7 +380,7 @@ class Package(db.Model): lazy="dynamic", order_by=db.desc("package_release_releaseDate")) screenshots = db.relationship("PackageScreenshot", backref="package", - lazy="dynamic") + lazy="dynamic", order_by=db.asc("package_screenshot_id")) requests = db.relationship("EditRequest", backref="package", lazy="dynamic") @@ -439,11 +439,11 @@ class Package(db.Model): } def getThumbnailURL(self, level=2): - screenshot = self.screenshots.filter_by(approved=True).first() + screenshot = self.screenshots.filter_by(approved=True).order_by(db.asc(PackageScreenshot.id)).first() return screenshot.getThumbnailURL(level) if screenshot is not None else None def getMainScreenshotURL(self): - screenshot = self.screenshots.filter_by(approved=True).first() + screenshot = self.screenshots.filter_by(approved=True).order_by(db.asc(PackageScreenshot.id)).first() return screenshot.url if screenshot is not None else None def getDetailsURL(self):