diff --git a/Drama rules.html b/Drama rules.html
deleted file mode 100644
index c45e601cca..0000000000
--- a/Drama rules.html
+++ /dev/null
@@ -1,25 +0,0 @@
-The providers ("we", "us", "our") of the service provided by this web site ("rDrama.net") are not responsible for any user-generated content and accounts. Content submitted express the views of their author only.
-
-You agree to not use rDrama.net to submit or link to any content which violates any laws. You are entirely responsible for the content of, and any harm resulting from, that content or your conduct.
-
-You must be at least 18 years of age to use this site.
-
-
Sorry whiteboy, we're gonna need to see some ID before you start throwin that word around like it's nothing.\n\nTake a 10 minute time-out and come back when you've learned your lesson and/or paid reparations (by purchasing a BIPOC Approved™ Rdrama NWord Pass© from the shop) \n\nThis is an automated message; if you need help, you can message us here.
""" -if True: subs = ('2balkan4you','2middleeast4you','2asia4you','2visegrad4you') -else: subs = () \ No newline at end of file +db = db_session() +SUBS = [x[0] for x in db.query(Sub.name).all()] +db.close() \ No newline at end of file diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index 140c71f0af..e409ac5a69 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -16,4 +16,4 @@ def post_embed(id, v): @app.context_processor def inject_constants(): - return {"environ":environ, "SITE_NAME":SITE_NAME, "AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID, "config":app.config.get, "DEFAULT_COLOR":DEFAULT_COLOR, "COLORS":COLORS, "subs":subs} + return {"environ":environ, "SITE_NAME":SITE_NAME, "AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID, "config":app.config.get, "DEFAULT_COLOR":DEFAULT_COLOR, "COLORS":COLORS, "SUBS": SUBS} diff --git a/files/routes/admin.py b/files/routes/admin.py index 65c5b75c55..363dcd8db4 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -343,6 +343,43 @@ def post_sidebar(v): return render_template('admin/sidebar.html', v=v, sidebar=sidebar, msg='Sidebar edited successfully!') +@app.get('/s//sidebar') +@auth_required +def get_sub_sidebar(v, sub): + sub = g.db.query(Sub).filter_by(name=sub).one_or_none() + if not sub: abort(404) + + mod = g.db.query(Mod).filter_by(user_id=v.id, sub=sub.name).one_or_none() + if not mod: abort(403) + + return render_template('admin/sidebar.html', v=v, sidebar=sub.sidebar, sub=sub) + + +@app.post('/s//sidebar') +@limiter.limit("1/second;30/minute;200/hour;1000/day") +@auth_required +def post_sub_sidebar(v, sub): + sub = g.db.query(Sub).filter_by(name=sub).one_or_none() + if not sub: abort(404) + + mod = g.db.query(Mod).filter_by(user_id=v.id, sub=sub.name).one_or_none() + if not mod: abort(403) + + sub.sidebar = request.values.get('sidebar', '').strip() + sub.sidebar_html = sanitize(sub.sidebar) + g.db.add(sub) + + ma = ModAction( + kind="change_sidebar", + user_id=v.id + ) + g.db.add(ma) + + g.db.commit() + + return render_template('admin/sidebar.html', v=v, sidebar=sub.sidebar, msg='Sidebar edited successfully!', sub=sub) + + @app.get("/admin/shadowbanned") @auth_required def shadowbanned(v): diff --git a/files/routes/comments.py b/files/routes/comments.py index c92edd62f8..bfbc83bf92 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -131,7 +131,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None): else: if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html" else: template = "submission.html" - return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, sub=post.sub) + return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, sub=post.subr) @app.post("/comment") @limiter.limit("1/second;20/minute;200/hour;1000/day") diff --git a/files/routes/front.py b/files/routes/front.py index f11447f155..a642a0d5c9 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -133,7 +133,8 @@ def notifications(v): @limiter.limit("3/second;30/minute;400/hour;2000/day") @auth_desired def front_all(v, sub=None): - if sub and sub not in subs: sub = None + sub = g.db.query(Sub).filter_by(name=sub).one_or_none() + if g.webview and not session.get("session_id"): session.permanent = True session["session_id"] = secrets.token_hex(49) @@ -256,7 +257,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" posts = g.db.query(Submission) - if sub: posts = posts.filter_by(sub=sub) + if sub: posts = posts.filter_by(sub=sub.name) if t == 'all': cutoff = 0 else: @@ -326,7 +327,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" if (sort == "hot" or (v and v.id == Q_ID)) and page == 1 and ccmode == "false": pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False) - if sub: pins = pins.filter_by(sub=sub) + if sub: pins = pins.filter_by(sub=sub.name) if v and v.admin_level == 0: blocking = [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=v.id).all()] blocked = [x[0] for x in g.db.query(UserBlock.user_id).filter_by(target_id=v.id).all()] diff --git a/files/routes/posts.py b/files/routes/posts.py index fac90656f1..aa32b46c33 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -91,7 +91,10 @@ def publish(pid, v): @app.get("/s//submit") @auth_required def submit_get(v, sub=None): - if sub and sub not in subs: sub = None + sub = g.db.query(Sub.name).filter_by(name=sub).one_or_none() + if sub: sub = sub[0] + else: sub = None + return render_template("submit.html", v=v, sub=sub) @app.get("/post/Your {% if "saved" in request.full_path %}saved posts{% else %}posting history{% endif %} will show here.
- {% if "saved" not in request.full_path %} \ No newline at end of file diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 99f9bd83ae..8770eaaaa1 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -553,7 +553,7 @@ Create a post{% endif %} + {% if "saved" not in request.full_path %}Create a post{% endif %}