diff --git a/nyaa/models.py b/nyaa/models.py index 3500a13..687bd5c 100644 --- a/nyaa/models.py +++ b/nyaa/models.py @@ -186,7 +186,7 @@ class TorrentBase(DeclarativeHelperBase): @declarative.declared_attr def trackers(cls): return db.relationship(cls._flavor_prefix('TorrentTrackers'), uselist=True, - cascade="all, delete-orphan", lazy='select', + cascade="all, delete-orphan", order_by=cls._flavor_prefix('TorrentTrackers.order')) @declarative.declared_attr @@ -498,8 +498,7 @@ class User(db.Model): bans = db.relationship('Ban', uselist=True, foreign_keys='Ban.user_id') - preferences = db.relationship('UserPreferences', - back_populates='user', uselist=False, lazy='select') + preferences = db.relationship('UserPreferences', back_populates='user', uselist=False) def __init__(self, username, email, password): self.username = username diff --git a/nyaa/views/torrents.py b/nyaa/views/torrents.py index 5dc9bb8..743c791 100644 --- a/nyaa/views/torrents.py +++ b/nyaa/views/torrents.py @@ -24,8 +24,6 @@ def view_torrent(torrent_id): .options(joinedload('filelist')) \ .filter_by(id=torrent_id) \ .first() - comments = models.Comment.query \ - .filter_by(torrent_id=torrent_id) if not torrent: flask.abort(404) @@ -69,11 +67,15 @@ def view_torrent(torrent_id): if torrent.filelist: files = json.loads(torrent.filelist.filelist_blob.decode('utf-8')) + torrent_comments = models.Comment.query.filter_by( + torrent_id=torrent_id + ).order_by(models.Comment.id.asc()) + report_form = forms.ReportForm() return flask.render_template('view.html', torrent=torrent, files=files, comment_form=comment_form, - comments=comments, + comments=torrent_comments, can_edit=can_edit, report_form=report_form)