From 0cbe982fd87f67ea2d514339fc3dfe36c507ce7d Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 5 Oct 2021 21:09:47 +0200 Subject: [PATCH] sdfsdf --- files/classes/comment.py | 10 ++++++---- files/classes/submission.py | 12 +++++++----- files/templates/comments.html | 6 ++---- files/templates/submission.html | 6 ++---- files/templates/submission_listing.html | 6 ++---- files/templates/userpage.html | 4 ++-- 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index f3388ba5d..60ad51b14 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -2,16 +2,18 @@ import re from urllib.parse import urlencode, urlparse, parse_qs from flask import * from sqlalchemy import * -from sqlalchemy.orm import relationship, deferred +from sqlalchemy.orm import relationship, deferred, lazyload from files.helpers.lazy import lazy from files.helpers.const import SLURS from files.__main__ import Base from .flags import CommentFlag +from .user import User from os import environ import time site = environ.get("DOMAIN").strip() +shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] class Comment(Base): @@ -357,12 +359,12 @@ class Comment(Base): @property @lazy - def active_flags(self): return self.flags.count() + def active_flags(self): return self.ordered_flags.count() @property @lazy - def ordered_flags(self): return self.flags.order_by(CommentFlag.id).all() - + def ordered_flags(self): + return self.flags.filter(CommentFlag.user_id.notin_(shadowbanned)).order_by(CommentFlag.id).all() class Notification(Base): diff --git a/files/classes/submission.py b/files/classes/submission.py index f41e3a496..fba7a053d 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -1,18 +1,19 @@ from flask import render_template, g from sqlalchemy import * -from sqlalchemy.orm import relationship, deferred +from sqlalchemy.orm import relationship, deferred, lazyload 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 -from .flags import * +from .flags import Flag +from .user import User from os import environ import time site = environ.get("DOMAIN").strip() site_name = environ.get("SITE_NAME").strip() - +shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] class Submission(Base): @@ -389,11 +390,12 @@ class Submission(Base): @property @lazy - def active_flags(self): return self.flags.count() + def active_flags(self): return self.ordered_flags.count() @property @lazy - def ordered_flags(self): return self.flags.order_by(Flag.id).all() + def ordered_flags(self): + return self.flags.filter(Flag.user_id.notin_(shadowbanned)).order_by(Flag.id).all() class SaveRelationship(Base): diff --git a/files/templates/comments.html b/files/templates/comments.html index 5c7d2476d..239db932a 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -212,7 +212,7 @@ {% if c.is_blocking %}{% endif %} {% if c.is_blocked %}{% endif %} - {% if c.author.verified %} + {% if c.author.verified %} {% endif %} {{c.author.username}} @@ -232,9 +232,7 @@

 				
 			
diff --git a/files/templates/submission.html b/files/templates/submission.html
index 031bf276c..79dffd4a3 100644
--- a/files/templates/submission.html
+++ b/files/templates/submission.html
@@ -281,7 +281,7 @@
 						{% if p.over_18 %}+18{% endif %}
 						{% if p.private %}Draft{% endif %}
 						{% if p.active_flags %}{{p.active_flags}} Reports{% endif %}
-						{% if p.author.verified %}
+						{% if p.author.verified %}
 						{% endif %}
 						{{p.author.username}}{% if p.author.customtitle %}  {% if p.author.quadrant %}{% endif %}{{p.author.customtitle | safe}}{% endif %}
 						 {{p.age_string}}
@@ -296,9 +296,7 @@
 						

 						
 					
diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html
index 1e1fd4610..e17c26766 100644
--- a/files/templates/submission_listing.html
+++ b/files/templates/submission_listing.html
@@ -138,7 +138,7 @@
 				{% if p.is_blocked %}{% endif %}
 				{% if p.private %}Draft{% endif %}
 				{% if p.active_flags %}{{p.active_flags}} Reports{% endif %}
-				{% if p.author.verified %}
+				{% if p.author.verified %}
 				{% endif %}
 				{{p.author.username}}{% if p.author.customtitle %}  {% if p.author.quadrant %}{% endif %}{{p.author.customtitle | safe}}{% endif %}
 				 {{p.age_string}}
@@ -420,9 +420,7 @@
 		

 		
 	
diff --git a/files/templates/userpage.html b/files/templates/userpage.html
index 23c2c9fe9..97f512da1 100644
--- a/files/templates/userpage.html
+++ b/files/templates/userpage.html
@@ -90,7 +90,7 @@
 									
 								
 								{% endif %}
-								{% if u.verified %}{% endif %}
+								{% if u.verified %}{% endif %}
 								{% if u.admin_level > 1 or (u.admin_level == 1 and (not v or v.admin_level < 2)) %}
 								
 									
@@ -365,7 +365,7 @@
 					
BANNED USER{% if u.ban_reason %}: {{u.ban_reason}}{% endif %}
{% if u.unban_utc %}
{{u.unban_string}}
{% endif %} {% endif %} - {% if u.verified %} {% endif %} + {% if u.verified %} {% endif %}

{{u.username}}

{% if u.username != u.original_username %}