From a5ce637b50cf4ea787a3a3743314b2e3a91b1d69 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 5 Oct 2021 21:15:48 +0200 Subject: [PATCH] fgg --- files/__main__.py | 5 +---- files/classes/comment.py | 9 +++++---- files/classes/submission.py | 12 ++++++------ files/routes/reporting.py | 4 ++-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/files/__main__.py b/files/__main__.py index fee021a7b..47cce45c4 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -131,7 +131,4 @@ def after_request(response): return response -from files.routes import * - - -shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] \ No newline at end of file +from files.routes import * \ No newline at end of file diff --git a/files/classes/comment.py b/files/classes/comment.py index 2f39b69f9..f3388ba5d 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -5,13 +5,14 @@ from sqlalchemy import * from sqlalchemy.orm import relationship, deferred from files.helpers.lazy import lazy from files.helpers.const import SLURS -from files.__main__ import Base, shadowbanned +from files.__main__ import Base from .flags import CommentFlag from os import environ import time site = environ.get("DOMAIN").strip() + class Comment(Base): __tablename__ = "comments" @@ -356,12 +357,12 @@ class Comment(Base): @property @lazy - def active_flags(self): return self.ordered_flags.count() + def active_flags(self): return self.flags.count() @property @lazy - def ordered_flags(self): - return self.flags.filter(CommentFlag.user_id.notin_(shadowbanned)).order_by(CommentFlag.id).all() + def ordered_flags(self): return self.flags.order_by(CommentFlag.id).all() + class Notification(Base): diff --git a/files/classes/submission.py b/files/classes/submission.py index bb7eb8a8b..f41e3a496 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -1,18 +1,19 @@ -from flask import render_template +from flask import render_template, g from sqlalchemy import * from sqlalchemy.orm import relationship, deferred import re, random from urllib.parse import urlparse from files.helpers.lazy import lazy from files.helpers.const import SLURS -from files.__main__ import Base, shadowbanned -from .flags import Flag +from files.__main__ import Base +from .flags import * from os import environ import time site = environ.get("DOMAIN").strip() site_name = environ.get("SITE_NAME").strip() + class Submission(Base): __tablename__ = "submissions" @@ -388,12 +389,11 @@ class Submission(Base): @property @lazy - def active_flags(self): return self.ordered_flags.count() + def active_flags(self): return self.flags.count() @property @lazy - def ordered_flags(self): - return self.flags.filter(Flag.user_id.notin_(shadowbanned)).order_by(Flag.id).all() + def ordered_flags(self): return self.flags.order_by(Flag.id).all() class SaveRelationship(Base): diff --git a/files/routes/reporting.py b/files/routes/reporting.py index 3fda9ef8e..ed925f2cd 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -10,7 +10,7 @@ def api_flag_post(pid, v): post = get_post(pid) - if v: + if v and not v.shadowbanned: existing = g.db.query(Flag).options(lazyload('*')).filter_by(user_id=v.id, post_id=post.id).first() if existing: return "", 409 @@ -41,7 +41,7 @@ def api_flag_comment(cid, v): comment = get_comment(cid) - if v: + if v and not v.shadowbanned: existing = g.db.query(CommentFlag).options(lazyload('*')).filter_by( user_id=v.id, comment_id=comment.id).first()