fsdsfd
This commit is contained in:
parent
1f32f3a35d
commit
2984e15fba
9 changed files with 124 additions and 30 deletions
|
@ -53,6 +53,7 @@ class Comment(Base):
|
|||
parent_comment = relationship("Comment", remote_side=[id], viewonly=True)
|
||||
child_comments = relationship("Comment", remote_side=[parent_comment_id], viewonly=True)
|
||||
awards = relationship("AwardRelationship", viewonly=True)
|
||||
reports = relationship("CommentFlag", viewonly=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ class Submission(Base):
|
|||
oauth_app = relationship("OauthApp", viewonly=True)
|
||||
approved_by = relationship("User", uselist=False, primaryjoin="Submission.is_approved==User.id", viewonly=True)
|
||||
awards = relationship("AwardRelationship", viewonly=True)
|
||||
reports = relationship("Flag", viewonly=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -216,7 +216,7 @@ def get_comment(i, v=None, graceful=False):
|
|||
return comment
|
||||
|
||||
|
||||
def get_comments(cids, v=None, load_parent=False, shadowbanned=False):
|
||||
def get_comments(cids, v=None, load_parent=False):
|
||||
|
||||
if not cids: return []
|
||||
|
||||
|
@ -236,7 +236,7 @@ def get_comments(cids, v=None, load_parent=False, shadowbanned=False):
|
|||
blocked.c.id,
|
||||
).filter(Comment.id.in_(cids))
|
||||
|
||||
if not shadowbanned and not v.shadowbanned and v.admin_level < 2:
|
||||
if not (v and (v.shadowbanned or v.admin_level > 1)):
|
||||
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
||||
|
||||
comments = comments.join(
|
||||
|
|
|
@ -21,8 +21,10 @@ def get_logged_in_user():
|
|||
if not uid: return None
|
||||
# if not uid or not logged_in or uid != logged_in: return None
|
||||
|
||||
if g.db: v = g.db.query(User).filter_by(id=uid).first()
|
||||
else: return None
|
||||
try:
|
||||
if g.db: v = g.db.query(User).filter_by(id=uid).first()
|
||||
else: return None
|
||||
except: return None
|
||||
|
||||
if not v or nonce < v.login_nonce: return None
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ def reported_posts(v):
|
|||
posts = g.db.query(Submission).filter_by(
|
||||
is_approved=0,
|
||||
is_banned=False
|
||||
).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26)
|
||||
).join(Submission.reports).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26)
|
||||
|
||||
listing = [p.id for p in posts]
|
||||
next_exists = (len(listing) > 25)
|
||||
|
@ -312,7 +312,7 @@ def reported_comments(v):
|
|||
).filter_by(
|
||||
is_approved=0,
|
||||
is_banned=False
|
||||
).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
).join(Comment.reports).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
listing = [p.id for p in posts]
|
||||
next_exists = (len(listing) > 25)
|
||||
|
@ -559,7 +559,7 @@ def admin_link_accounts(v):
|
|||
return redirect(f"/admin/alt_votes?u1={g.db.query(User).get(u1).username}&u2={g.db.query(User).get(u2).username}")
|
||||
|
||||
|
||||
@app.get("/admin/removed")
|
||||
@app.get("/admin/removed/posts")
|
||||
@admin_level_required(2)
|
||||
def admin_removed(v):
|
||||
|
||||
|
@ -583,6 +583,29 @@ def admin_removed(v):
|
|||
)
|
||||
|
||||
|
||||
@app.get("/admin/removed/comments")
|
||||
@admin_level_required(2)
|
||||
def admin_removed_comments(v):
|
||||
|
||||
page = int(request.values.get("page", 1))
|
||||
|
||||
ids = g.db.query(Comment.id).join(User, User.id == Comment.author_id).filter(or_(Comment.is_banned==True, User.shadowbanned != None)).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||
|
||||
ids=[x[0] for x in ids]
|
||||
|
||||
next_exists = len(ids) > 25
|
||||
|
||||
ids = ids[:25]
|
||||
|
||||
comments = get_comments(ids, v=v)
|
||||
|
||||
return render_template("admin/removed_comments.html",
|
||||
v=v,
|
||||
listing=comments,
|
||||
page=page,
|
||||
next_exists=next_exists
|
||||
)
|
||||
|
||||
|
||||
@app.post("/agendaposter/<user_id>")
|
||||
@admin_level_required(2)
|
||||
|
|
|
@ -370,7 +370,7 @@ def random_post(v):
|
|||
return redirect(f"/post/{post.id}")
|
||||
|
||||
@cache.memoize(timeout=86400)
|
||||
def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", shadowbanned=False):
|
||||
def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"):
|
||||
|
||||
posts = g.db.query(Submission)
|
||||
cc_idlist = [x[0] for x in g.db.query(Submission.id).filter(Submission.club == True).all()]
|
||||
|
@ -418,7 +418,6 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", shadowbanned
|
|||
elif sort == "bottom":
|
||||
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
|
||||
|
||||
if shadowbanned: comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned != None)
|
||||
comments = comments.offset(25 * (page - 1)).limit(26).all()
|
||||
return [x[0] for x in comments]
|
||||
|
||||
|
@ -432,20 +431,17 @@ def all_comments(v):
|
|||
sort=request.values.get("sort", "new")
|
||||
t=request.values.get("t", defaulttimefilter)
|
||||
|
||||
if request.values.get("shadowbanned") and v and v.admin_level > 1: shadowbanned = True
|
||||
else: shadowbanned = False
|
||||
|
||||
idlist = comment_idlist(v=v,
|
||||
page=page,
|
||||
sort=sort,
|
||||
t=t,
|
||||
shadowbanned=shadowbanned
|
||||
)
|
||||
comments = get_comments(idlist, v=v, shadowbanned=shadowbanned)
|
||||
|
||||
comments = get_comments(idlist, v=v)
|
||||
|
||||
next_exists = len(idlist) > 25
|
||||
|
||||
idlist = idlist[:25]
|
||||
|
||||
if request.headers.get("Authorization"): return {"data": [x.json for x in comments]}
|
||||
else: return render_template("home_comments.html", v=v, sort=sort, t=t, page=page, comments=comments, standalone=True, next_exists=next_exists, shadowbanned=shadowbanned)
|
||||
else: return render_template("home_comments.html", v=v, sort=sort, t=t, page=page, comments=comments, standalone=True, next_exists=next_exists)
|
|
@ -1003,10 +1003,7 @@ def settings_song_change(v):
|
|||
id = song.split("v=")[1]
|
||||
elif song.startswith("https://youtu.be/"):
|
||||
id = song.split("https://youtu.be/")[1]
|
||||
else:
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
error=f"Not a youtube link.")
|
||||
else: return render_template("settings_profile.html", v=v, error=f"Not a youtube link.")
|
||||
|
||||
if "?" in id: id = id.split("?")[0]
|
||||
if "&" in id: id = id.split("&")[0]
|
||||
|
@ -1020,17 +1017,16 @@ def settings_song_change(v):
|
|||
|
||||
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5).json()
|
||||
duration = req['items'][0]['contentDetails']['duration']
|
||||
if duration == 'P0D':
|
||||
return render_template("settings_profile.html", v=v, error=f"Can't use a live youtube video!")
|
||||
|
||||
if "H" in duration:
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
error=f"Duration of the video must not exceed 10 minutes.")
|
||||
return render_template("settings_profile.html", v=v, error=f"Duration of the video must not exceed 10 minutes.")
|
||||
|
||||
if "M" in duration:
|
||||
duration = int(duration.split("PT")[1].split("M")[0])
|
||||
if duration > 10:
|
||||
return render_template("settings_profile.html",
|
||||
v=v,
|
||||
error=f"Duration of the video must not exceed 10 minutes.")
|
||||
return render_template("settings_profile.html", v=v, error=f"Duration of the video must not exceed 10 minutes.")
|
||||
|
||||
|
||||
if v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User.id).filter_by(song=v.song).count() == 1:
|
||||
|
|
|
@ -12,17 +12,19 @@
|
|||
|
||||
<h4>Content</h4>
|
||||
<ul>
|
||||
<li><a href="/admin/image_posts">Image Posts</a></li>
|
||||
<li><a href="/admin/reported/posts">Reported Posts</a></li>
|
||||
<li><a href="/admin/reported/comments">Reported Comments</a></li>
|
||||
<li><a href="/admin/image_posts">Image Posts</a></li>
|
||||
<li><a href="/admin/removed">Removed Posts</a></li>
|
||||
<li><a href="/admin/removed/posts">Removed Posts</a></li>
|
||||
<li><a href="/admin/removed/comments">Removed Comments</a></li>
|
||||
</ul>
|
||||
|
||||
<h4>Users</h4>
|
||||
<ul>
|
||||
<li><a href="/admin/users">Users Feed</a></li>
|
||||
<li><a href="/admin/shadowbanned">Shadowbanned Users</a></li>
|
||||
<li><a href="/admin/agendaposters">Users with Agendaposter Theme</a></li>
|
||||
<li><a href="/admin/users">Users Feed</a></li>
|
||||
<li><a href="/admin/truescore">Users by True Score</a></li>
|
||||
</ul>
|
||||
|
||||
<h4>Safety</h4>
|
||||
|
|
73
files/templates/admin/removed_comments.html
Normal file
73
files/templates/admin/removed_comments.html
Normal file
|
@ -0,0 +1,73 @@
|
|||
{% extends "admin/image_posts.html" %}
|
||||
|
||||
|
||||
{% block title %}
|
||||
<title>Removed Content</title>
|
||||
<meta name="description" content="on {{'SITE_NAME' | app_config}}">
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="row justify-content-around mx-lg-5 d-lg-none no-gutters">
|
||||
<div class="col bg-light border-bottom rounded-md p-3">
|
||||
<div class="profile-details">
|
||||
<div class="media">
|
||||
<div class="media-body">
|
||||
<pre></pre>
|
||||
<h5 class="h6 d-inline-block">Removed Posts</h5>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row no-gutters">
|
||||
|
||||
<div class="col">
|
||||
|
||||
{% block listing %}
|
||||
|
||||
|
||||
<div class="posts">
|
||||
{% with comments=listing %}
|
||||
{% include "comments.html" %}
|
||||
{% endwith %}
|
||||
{% if not listing %}
|
||||
<div class="row no-gutters">
|
||||
<div class="col">
|
||||
<div class="text-center py-7">
|
||||
<div class="h4 p-2">There are no comments here (yet).</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block pagenav %}
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination pagination-sm py-3 pl-3 mb-0">
|
||||
{% if page>1 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="?page={{page-1}}" tabindex="-1">Prev</a></small>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled"><span class="page-link">Prev</span></li>
|
||||
{% endif %}
|
||||
{% if next_exists %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="?page={{page+1}}">Next</a></small>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled"><span class="page-link">Next</span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue