diff --git a/files/classes/comment.py b/files/classes/comment.py index f88853435..377349901 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -231,6 +231,11 @@ class Comment(Base): def permalink(self): return f"{SITE_FULL}{self.shortlink}" + @property + @lazy + def log_link(self): + return f"{SITE_FULL}/transfers/{self.id}" + @property @lazy def morecomments(self): diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py index c4cb9e60c..39a56f602 100644 --- a/files/classes/mod_logs.py +++ b/files/classes/mod_logs.py @@ -105,7 +105,7 @@ class ModAction(Base): @property @lazy def permalink(self): - return f"/log/{self.id}" + return f"{SITE_FULL}/log/{self.id}" ACTIONTYPES = { 'agendaposter': { diff --git a/files/routes/front.py b/files/routes/front.py index bc59b2bf3..bacc6981d 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -296,21 +296,4 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", gt=0, lt=0, comments = sort_comments(sort, comments) comments = comments.offset(25 * (page - 1)).limit(26).all() - return [x[0] for x in comments] - - -@app.get("/transfers") -@auth_required -def transfers(v): - - comments = g.db.query(Comment).filter(Comment.author_id == AUTOJANNY_ID, Comment.parent_submission == None, Comment.body_html.like("% has transferred %")).order_by(Comment.id.desc()) - - if request.headers.get("Authorization"): return {"data": [x.json for x in comments.all()]} - - try: page = max(int(request.values.get("page", 1)), 1) - except: page = 1 - - comments = comments.offset(25 * (page - 1)).limit(26).all() - next_exists = len(comments) > 25 - comments = comments[:25] - return render_template("transfers.html", v=v, page=page, comments=comments, standalone=True, next_exists=next_exists) + return [x[0] for x in comments] \ No newline at end of file diff --git a/files/routes/static.py b/files/routes/static.py index aad6028ed..2a7c5bf8b 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -375,3 +375,32 @@ def settings_security(v): def dismiss_mobile_tip(): session["tooltip_last_dismissed"] = int(time.time()) return "", 204 + +@app.get("/transfers/") +@auth_required +def transfers_id(id, v): + + try: id = int(id) + except: abort(404) + + transfer = g.db.get(Comment, id) + + if not transfer: abort(404) + + return render_template("transfers.html", v=v, page=1, comments=[transfer], standalone=True, next_exists=False) + +@app.get("/transfers") +@auth_required +def transfers(v): + + comments = g.db.query(Comment).filter(Comment.author_id == AUTOJANNY_ID, Comment.parent_submission == None, Comment.body_html.like("% has transferred %")).order_by(Comment.id.desc()) + + if request.headers.get("Authorization"): return {"data": [x.json for x in comments.all()]} + + try: page = max(int(request.values.get("page", 1)), 1) + except: page = 1 + + comments = comments.offset(25 * (page - 1)).limit(26).all() + next_exists = len(comments) > 25 + comments = comments[:25] + return render_template("transfers.html", v=v, page=page, comments=comments, standalone=True, next_exists=next_exists) \ No newline at end of file diff --git a/files/templates/comments.html b/files/templates/comments.html index e054e7f88..64cf6bade 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -585,6 +585,9 @@ + + + {% if render_replies %} {% if level<9 or request.path.startswith('/notifications') or request.headers.get("xhr") %}
diff --git a/files/templates/transfers.html b/files/templates/transfers.html index 7470b47d0..b23b7ff17 100644 --- a/files/templates/transfers.html +++ b/files/templates/transfers.html @@ -37,4 +37,12 @@ {% endif %} + + + + {% endblock %} \ No newline at end of file