diff --git a/drama/classes/comment.py b/drama/classes/comment.py index 87d62e41b..be5f170bb 100644 --- a/drama/classes/comment.py +++ b/drama/classes/comment.py @@ -42,7 +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) level = Column(Integer, default=0) parent_comment_id = Column(Integer, ForeignKey("comments.id")) diff --git a/drama/classes/submission.py b/drama/classes/submission.py index 55d9f1f34..3e110fbdd 100644 --- a/drama/classes/submission.py +++ b/drama/classes/submission.py @@ -60,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", diff --git a/drama/helpers/session.py b/drama/helpers/session.py index a0d133c1c..3690427dd 100644 --- a/drama/helpers/session.py +++ b/drama/helpers/session.py @@ -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']}" diff --git a/drama/routes/admin.py b/drama/routes/admin.py index 1d10fa4f1..36541081c 100644 --- a/drama/routes/admin.py +++ b/drama/routes/admin.py @@ -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 diff --git a/drama/routes/comments.py b/drama/routes/comments.py index 1fb0dded1..77d29099b 100644 --- a/drama/routes/comments.py +++ b/drama/routes/comments.py @@ -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.'} diff --git a/drama/routes/errors.py b/drama/routes/errors.py index 702d5fedb..e267c0e7c 100644 --- a/drama/routes/errors.py +++ b/drama/routes/errors.py @@ -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/", methods=["GET"]) @auth_desired def error_all_preview(error, v): diff --git a/drama/routes/posts.py b/drama/routes/posts.py index b0c023af1..1363f954a 100644 --- a/drama/routes/posts.py +++ b/drama/routes/posts.py @@ -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) } diff --git a/drama/templates/errors/nsfw.html b/drama/templates/errors/nsfw.html index a1e8483ef..283555553 100644 --- a/drama/templates/errors/nsfw.html +++ b/drama/templates/errors/nsfw.html @@ -15,20 +15,10 @@

This post is rated +18 (Pornographic Content). You must be 18 or older to continue. Are you sure you want to proceed?

- {% if v %} -
- - - -
- {% else %} -
- - - - -
- {% endif %} +
+ + +
No