fgg
This commit is contained in:
parent
09a57dad7c
commit
61fb596548
4 changed files with 14 additions and 16 deletions
|
@ -132,6 +132,3 @@ def after_request(response):
|
||||||
|
|
||||||
|
|
||||||
from files.routes import *
|
from files.routes import *
|
||||||
|
|
||||||
|
|
||||||
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()]
|
|
|
@ -5,13 +5,14 @@ from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship, deferred
|
from sqlalchemy.orm import relationship, deferred
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
from files.helpers.const import SLURS
|
from files.helpers.const import SLURS
|
||||||
from files.__main__ import Base, shadowbanned
|
from files.__main__ import Base
|
||||||
from .flags import CommentFlag
|
from .flags import CommentFlag
|
||||||
from os import environ
|
from os import environ
|
||||||
import time
|
import time
|
||||||
|
|
||||||
site = environ.get("DOMAIN").strip()
|
site = environ.get("DOMAIN").strip()
|
||||||
|
|
||||||
|
|
||||||
class Comment(Base):
|
class Comment(Base):
|
||||||
|
|
||||||
__tablename__ = "comments"
|
__tablename__ = "comments"
|
||||||
|
@ -356,12 +357,12 @@ class Comment(Base):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def active_flags(self): return self.ordered_flags.count()
|
def active_flags(self): return self.flags.count()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def ordered_flags(self):
|
def ordered_flags(self): return self.flags.order_by(CommentFlag.id).all()
|
||||||
return self.flags.filter(CommentFlag.user_id.notin_(shadowbanned)).order_by(CommentFlag.id).all()
|
|
||||||
|
|
||||||
|
|
||||||
class Notification(Base):
|
class Notification(Base):
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
from flask import render_template
|
from flask import render_template, g
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship, deferred
|
from sqlalchemy.orm import relationship, deferred
|
||||||
import re, random
|
import re, random
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from files.helpers.lazy import lazy
|
from files.helpers.lazy import lazy
|
||||||
from files.helpers.const import SLURS
|
from files.helpers.const import SLURS
|
||||||
from files.__main__ import Base, shadowbanned
|
from files.__main__ import Base
|
||||||
from .flags import Flag
|
from .flags import *
|
||||||
from os import environ
|
from os import environ
|
||||||
import time
|
import time
|
||||||
|
|
||||||
site = environ.get("DOMAIN").strip()
|
site = environ.get("DOMAIN").strip()
|
||||||
site_name = environ.get("SITE_NAME").strip()
|
site_name = environ.get("SITE_NAME").strip()
|
||||||
|
|
||||||
|
|
||||||
class Submission(Base):
|
class Submission(Base):
|
||||||
|
|
||||||
__tablename__ = "submissions"
|
__tablename__ = "submissions"
|
||||||
|
@ -388,12 +389,11 @@ class Submission(Base):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def active_flags(self): return self.ordered_flags.count()
|
def active_flags(self): return self.flags.count()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def ordered_flags(self):
|
def ordered_flags(self): return self.flags.order_by(Flag.id).all()
|
||||||
return self.flags.filter(Flag.user_id.notin_(shadowbanned)).order_by(Flag.id).all()
|
|
||||||
|
|
||||||
|
|
||||||
class SaveRelationship(Base):
|
class SaveRelationship(Base):
|
||||||
|
|
|
@ -10,7 +10,7 @@ def api_flag_post(pid, v):
|
||||||
|
|
||||||
post = get_post(pid)
|
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()
|
existing = g.db.query(Flag).options(lazyload('*')).filter_by(user_id=v.id, post_id=post.id).first()
|
||||||
|
|
||||||
if existing: return "", 409
|
if existing: return "", 409
|
||||||
|
@ -41,7 +41,7 @@ def api_flag_comment(cid, v):
|
||||||
|
|
||||||
comment = get_comment(cid)
|
comment = get_comment(cid)
|
||||||
|
|
||||||
if v:
|
if v and not v.shadowbanned:
|
||||||
existing = g.db.query(CommentFlag).options(lazyload('*')).filter_by(
|
existing = g.db.query(CommentFlag).options(lazyload('*')).filter_by(
|
||||||
user_id=v.id, comment_id=comment.id).first()
|
user_id=v.id, comment_id=comment.id).first()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue