forked from rDrama/rDrama
Merge branch 'master' into db-seed
commit
49182ce7f6
|
@ -42,8 +42,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
|
|||
distinguish_level = Column(Integer, default=0)
|
||||
deleted_utc = Column(Integer, default=0)
|
||||
is_approved = Column(Integer, default=0)
|
||||
approved_utc = Column(Integer, default=0)
|
||||
creation_ip = Column(String(64), default='')
|
||||
level = Column(Integer, default=0)
|
||||
parent_comment_id = Column(Integer, ForeignKey("comments.id"))
|
||||
|
||||
|
@ -81,8 +79,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
|
|||
if "created_utc" not in kwargs:
|
||||
kwargs["created_utc"] = int(time.time())
|
||||
|
||||
kwargs["creation_ip"] = request.remote_addr
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
|
|
|
@ -37,7 +37,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
uselist=False,
|
||||
innerjoin=True,
|
||||
primaryjoin="Submission.id==SubmissionAux.id")
|
||||
gm_distinguish = Column(Integer, default=0)
|
||||
author_id = Column(BigInteger, ForeignKey("users.id"))
|
||||
repost_id = Column(BigInteger, ForeignKey("submissions.id"), default=0)
|
||||
edited_utc = Column(BigInteger, default=0)
|
||||
|
@ -61,7 +60,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
domain_obj = relationship("Domain")
|
||||
flags = relationship("Flag", backref="submission")
|
||||
is_approved = Column(Integer, ForeignKey("users.id"), default=0)
|
||||
approved_utc = Column(Integer, default=0)
|
||||
over_18 = Column(Boolean, default=False)
|
||||
author = relationship(
|
||||
"User",
|
||||
|
@ -102,7 +100,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
"%I:%M %p on %d %b %Y", time.gmtime(
|
||||
kwargs["created_utc"]))
|
||||
|
||||
kwargs["creation_ip"] = request.remote_addr
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ class Vote(Base):
|
|||
vote_type = Column(Integer)
|
||||
submission_id = Column(Integer, ForeignKey("submissions.id"))
|
||||
created_utc = Column(Integer, default=0)
|
||||
creation_ip = Column(String)
|
||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||
|
||||
user = relationship("User", lazy="subquery")
|
||||
|
@ -25,7 +24,6 @@ class Vote(Base):
|
|||
if "created_utc" not in kwargs:
|
||||
kwargs["created_utc"] = int(time())
|
||||
|
||||
kwargs["creation_ip"]=request.remote_addr
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
@ -76,7 +74,6 @@ class CommentVote(Base):
|
|||
vote_type = Column(Integer)
|
||||
comment_id = Column(Integer, ForeignKey("comments.id"))
|
||||
created_utc = Column(Integer, default=0)
|
||||
creation_ip = Column(String)
|
||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||
|
||||
user = relationship("User", lazy="subquery")
|
||||
|
@ -86,7 +83,6 @@ class CommentVote(Base):
|
|||
if "created_utc" not in kwargs:
|
||||
kwargs["created_utc"] = int(time())
|
||||
|
||||
kwargs["creation_ip"]=request.remote_addr
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
|
|
@ -2,13 +2,6 @@ from flask import *
|
|||
import time
|
||||
from .security import *
|
||||
|
||||
|
||||
def session_over18():
|
||||
|
||||
now = int(time.time())
|
||||
try: return session.get('over_18', 0) >= now
|
||||
except: return False
|
||||
|
||||
def make_logged_out_formkey(t):
|
||||
|
||||
s = f"{t}+{session['session_id']}"
|
||||
|
|
|
@ -728,7 +728,6 @@ def ban_post(post_id, v):
|
|||
|
||||
post.is_banned = True
|
||||
post.is_approved = 0
|
||||
post.approved_utc = 0
|
||||
post.stickied = False
|
||||
post.is_pinned = False
|
||||
|
||||
|
@ -773,7 +772,6 @@ def unban_post(post_id, v):
|
|||
|
||||
post.is_banned = False
|
||||
post.is_approved = v.id
|
||||
post.approved_utc = int(time.time())
|
||||
|
||||
g.db.add(post)
|
||||
|
||||
|
@ -839,7 +837,6 @@ def api_ban_comment(c_id, v):
|
|||
|
||||
comment.is_banned = True
|
||||
comment.is_approved = 0
|
||||
comment.approved_utc = 0
|
||||
|
||||
g.db.add(comment)
|
||||
ma=ModAction(
|
||||
|
@ -870,7 +867,6 @@ def api_unban_comment(c_id, v):
|
|||
|
||||
comment.is_banned = False
|
||||
comment.is_approved = v.id
|
||||
comment.approved_utc = int(time.time())
|
||||
|
||||
|
||||
return "", 204
|
||||
|
@ -1163,33 +1159,6 @@ def multiple_plots(**kwargs):
|
|||
|
||||
return upload_from_file(name, name)
|
||||
|
||||
|
||||
@app.route("/admin/distinguish_post/<pid>", methods=["POST"])
|
||||
@app.route("/api/v1/distinguish_post/<pid>", methods=["POST"])
|
||||
@admin_level_required(6)
|
||||
@api("update")
|
||||
def distinguish_post(pid, v):
|
||||
|
||||
post = get_post(pid, v=v)
|
||||
|
||||
if post.author_id != v.id:
|
||||
abort(403)
|
||||
|
||||
if post.gm_distinguish:
|
||||
post.gm_distinguish = 0
|
||||
else:
|
||||
post.gm_distinguish = 1
|
||||
g.db.add(post)
|
||||
|
||||
ma=ModAction(
|
||||
kind="herald_post" if post.gm_distinguish else "unherald_post",
|
||||
user_id=v.id,
|
||||
target_submission_id=post.id,
|
||||
)
|
||||
g.db.add(ma)
|
||||
|
||||
return "", 204
|
||||
|
||||
@app.route("/admin/add_admin", methods=["POST"])
|
||||
@auth_required
|
||||
@validate_formkey
|
||||
|
|
|
@ -85,13 +85,9 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
|||
|
||||
post = get_post(pid, v=v)
|
||||
|
||||
if post.over_18 and not (v and v.over_18) and not session_over18():
|
||||
t = int(time.time())
|
||||
if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()):
|
||||
return {'html': lambda: render_template("errors/nsfw.html",
|
||||
v=v,
|
||||
t=t,
|
||||
lo_formkey=make_logged_out_formkey(
|
||||
t),
|
||||
),
|
||||
'api': lambda: {'error': f'This content is not suitable for some users and situations.'}
|
||||
|
||||
|
|
|
@ -154,34 +154,14 @@ def error_503(e, v):
|
|||
}
|
||||
|
||||
|
||||
@app.route("/allow_nsfw_logged_in", methods=["POST"])
|
||||
@auth_required
|
||||
@validate_formkey
|
||||
def allow_nsfw_logged_in(v):
|
||||
@app.route("/allow_nsfw", methods=["POST"])
|
||||
def allow_nsfw():
|
||||
|
||||
if not session.get("over_18"): session["over_18"] = int(time.time()) + 3600
|
||||
session["over_18"] = int(time.time()) + 3600
|
||||
|
||||
return redirect(request.form.get("redir"))
|
||||
|
||||
|
||||
@app.route("/allow_nsfw_logged_out", methods=["POST"])
|
||||
@auth_desired
|
||||
def allow_nsfw_logged_out(v):
|
||||
|
||||
if v:
|
||||
return redirect('/')
|
||||
|
||||
t = int(request.form.get('time'))
|
||||
|
||||
if not validate_logged_out_formkey(t,
|
||||
request.form.get("formkey")
|
||||
):
|
||||
abort(403)
|
||||
|
||||
if not session.get("over_18"): session["over_18"] = int(time.time()) + 3600
|
||||
|
||||
return redirect(request.form.get("redir"))
|
||||
|
||||
@app.route("/error/<error>", methods=["GET"])
|
||||
@auth_desired
|
||||
def error_all_preview(error, v):
|
||||
|
|
|
@ -232,13 +232,9 @@ def post_base36id(pid, anything=None, v=None):
|
|||
g.db.add(post)
|
||||
g.db.commit()
|
||||
|
||||
if post.over_18 and not (v and v.over_18) and not session_over18():
|
||||
t = int(time.time())
|
||||
if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()):
|
||||
return {"html":lambda:render_template("errors/nsfw.html",
|
||||
v=v,
|
||||
t=t,
|
||||
lo_formkey=make_logged_out_formkey(t),
|
||||
|
||||
),
|
||||
"api":lambda:(jsonify({"error":"Must be 18+ to view"}), 451)
|
||||
}
|
||||
|
|
|
@ -159,7 +159,6 @@ def api_vote_comment(comment_id, x, v):
|
|||
vote = CommentVote(user_id=v.id,
|
||||
vote_type=x,
|
||||
comment_id=base36decode(comment_id),
|
||||
creation_ip=request.remote_addr,
|
||||
app_id=v.client.application.id if v.client else None
|
||||
)
|
||||
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
|
||||
<h2>Analysis</h2>
|
||||
|
||||
<p><b>{{u1.username}} Creation IP:</b> {{u1.creation_ip}}</p>
|
||||
<p><b>{{u2.username}} Creation IP:</b> {{u2.creation_ip}}</p>
|
||||
|
||||
|
||||
|
||||
<table class="table table-striped mb-5">
|
||||
|
|
|
@ -15,20 +15,10 @@
|
|||
<p class="mb-5">This post is rated +18 (Pornographic Content). You must be 18 or older to continue. Are you sure you want to proceed?</p>
|
||||
<div class="btn-toolbar justify-content-center mb-4">
|
||||
|
||||
{% if v %}
|
||||
<form action="/allow_nsfw_logged_in" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<input type="hidden" name="redir" value="{{request.path}}">
|
||||
<input type="submit" class="btn btn-danger mr-2" value="Yes, I am 18">
|
||||
</form>
|
||||
{% else %}
|
||||
<form action="/allow_nsfw_logged_out" method="post">
|
||||
<input type="hidden" name="formkey" value="{{lo_formkey}}">
|
||||
<input type="hidden" name="redir" value="{{request.path}}">
|
||||
<input type="hidden" name="time" value="{{t}}">
|
||||
<input type="submit" class="btn btn-danger mr-2" value="Yes, I am 18">
|
||||
</form>
|
||||
{% endif %}
|
||||
<form action="/allow_nsfw" method="post">
|
||||
<input type="hidden" name="redir" value="{{request.path}}">
|
||||
<input type="submit" class="btn btn-danger mr-2" value="Yes, I am +18">
|
||||
</form>
|
||||
<div><a href="/" class="btn btn-secondary">No</a></div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue