From 4b9c702877b87ec443660ae305f053a09fa8043e Mon Sep 17 00:00:00 2001 From: justcool393 Date: Tue, 15 Nov 2022 03:28:39 -0600 Subject: [PATCH] fix listing bugs --- files/classes/comment.py | 1 - files/routes/notifications.py | 10 +++++----- files/routes/search.py | 2 +- files/routes/static.py | 2 +- files/routes/users.py | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index beadade38..96204a190 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -80,7 +80,6 @@ class Comment(Base): super().__init__(*args, **kwargs) def __repr__(self): - return f"" @lazy diff --git a/files/routes/notifications.py b/files/routes/notifications.py index d651976d0..401cab518 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -53,7 +53,7 @@ def notifications_modmail(v): g.db.commit() - if v.client: return {"data":[x.json for x in listing]} + if v.client: return {"data":[x.json(g.db) for x in listing]} return render_template("notifications.html", v=v, @@ -123,7 +123,7 @@ def notifications_messages(v): c.unread = True list_to_perserve_unread_attribute.append(c) - if v.client: return {"data":[x.json for x in listing]} + if v.client: return {"data":[x.json(g.db) for x in listing]} return render_template("notifications.html", v=v, @@ -165,7 +165,7 @@ def notifications_posts(v): v.last_viewed_post_notifs = int(time.time()) g.db.add(v) - if v.client: return {"data":[x.json for x in listing]} + if v.client: return {"data":[x.json(g.db) for x in listing]} return render_template("notifications.html", v=v, @@ -247,7 +247,7 @@ def notifications_reddit(v): g.db.commit() - if v.client: return {"data":[x.json for x in listing]} + if v.client: return {"data":[x.json(g.db) for x in listing]} return render_template("notifications.html", v=v, @@ -318,7 +318,7 @@ def notifications(v): g.db.commit() - if v.client: return {"data":[x.json for x in listing]} + if v.client: return {"data":[x.json(g.db) for x in listing]} return render_template("notifications.html", v=v, diff --git a/files/routes/search.py b/files/routes/search.py index 16d285e97..2a910a001 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -166,7 +166,7 @@ def searchposts(v): posts = get_posts(ids, v=v, eager=True) - if v.client: return {"total":total, "data":[x.json for x in posts]} + if v.client: return {"total":total, "data":[x.json(g.db) for x in posts]} return render_template("search.html", v=v, diff --git a/files/routes/static.py b/files/routes/static.py index 68a5e215b..60e0ae998 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -400,7 +400,7 @@ def transfers(v): comments = comments[:PAGE_SIZE] if v.client: - return {"data": [x.json for x in comments]} + return {"data": [x.json(g.db) for x in comments]} else: return render_template("transfers.html", v=v, page=page, comments=comments, standalone=True, next_exists=next_exists) diff --git a/files/routes/users.py b/files/routes/users.py index b60ca5d99..ccf1fd73c 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -956,7 +956,7 @@ def get_saves_and_subscribes(v, template, relationship_cls, page:int, standalone listing = get_comments(ids, v=v) else: raise TypeError("Only supports Submissions and Comments. This is probably the result of a bug with *this* function") - if v.client: return {"data": [x.json for x in listing]} + if v.client: return {"data": [x.json(g.db) for x in listing]} return render_template(template, u=v, v=v, listing=listing, page=page, next_exists=next_exists, standalone=standalone) @app.get("/@/saved/posts")