From 07a12380deedb4a306c31416e55f36a992f17076 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 3 Nov 2022 17:29:14 +0200 Subject: [PATCH] accomodate alt domain --- files/classes/comment.py | 2 +- files/classes/submission.py | 2 +- files/helpers/const.py | 4 ++-- files/helpers/stats.py | 2 +- files/routes/admin.py | 2 +- files/routes/awards.py | 2 +- files/routes/chat.py | 2 +- files/routes/static.py | 4 ++-- files/routes/users.py | 2 +- files/templates/comments.html | 4 ++-- files/templates/hats.html | 4 ++-- files/templates/html_head.html | 2 +- files/templates/marseys.html | 4 ++-- files/templates/post_actions.html | 2 +- files/templates/post_actions_mobile.html | 2 +- 15 files changed, 20 insertions(+), 20 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index a96aff206..75e945f1b 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -89,7 +89,7 @@ class Comment(Base): @lazy def can_see(self, v): - if SITE not in ('rdrama.net','rdrama.com'): return True + if not SITE.startswith('rdrama.'): return True if not self.parent_submission: return True if self.post.sub != 'chudrama': return True if v: diff --git a/files/classes/submission.py b/files/classes/submission.py index 7f075ccc5..24615ecf5 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -79,7 +79,7 @@ class Submission(Base): @lazy def can_see(self, v): - if SITE not in ('rdrama.net','rdrama.com'): return True + if not SITE.startswith('rdrama.'): return True if self.sub != 'chudrama': return True if v: if v.can_see_chudrama: return True diff --git a/files/helpers/const.py b/files/helpers/const.py index f3a986152..0d3ebe96c 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -403,7 +403,7 @@ ANTISPAM_BYPASS_IDS = () PAGE_SIZE = 25 LEADERBOARD_LIMIT = PAGE_SIZE -if SITE in ('rdrama.net','rdrama.com'): +if SITE.startswith('rdrama.'): FEATURES['PRONOUNS'] = True FEATURES['HOUSES'] = True PERMS['ADMIN_ADD'] = 4 @@ -1229,7 +1229,7 @@ if len(SITE_NAME) > 5: if SITE != 'localhost': REDDIT_NOTIFS_SITE.add(SITE) -if SITE in ('rdrama.net','rdrama.com'): +if SITE.startswith('rdrama.'): REDDIT_NOTIFS_SITE.add('marsey') REDDIT_NOTIFS_SITE.add('"r/Drama"') REDDIT_NOTIFS_SITE.add('justice4darrell') diff --git a/files/helpers/stats.py b/files/helpers/stats.py index 72c18133c..d81a9a951 100644 --- a/files/helpers/stats.py +++ b/files/helpers/stats.py @@ -24,7 +24,7 @@ def chart(kind, site): now.tm_wday, now.tm_yday, 0)) today_cutoff = calendar.timegm(midnight_this_morning) - if SITE in ('rdrama.net','rdrama.com'): + if SITE.startswith('rdrama.'): time_diff = time.time() - 1619827200 num_of_weeks = int(time_diff / 604800) chart_width = int(num_of_weeks/1.4) diff --git a/files/routes/admin.py b/files/routes/admin.py index 05f06d9ef..5ad203493 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -159,7 +159,7 @@ def merge_all(v, id): @app.post("/@/make_admin") @admin_level_required(PERMS['ADMIN_ADD']) def make_admin(v, username): - if SITE in ('rdrama.net','rdrama.com'): abort(403) + if SITE.startswith('rdrama.'): abort(403) user = get_user(username) diff --git a/files/routes/awards.py b/files/routes/awards.py index 2339f1c3e..7b30fbc3e 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -158,7 +158,7 @@ def award_thing(v, thing_type, id): author = thing.author if author.shadowbanned: abort(404) - if SITE in ('rdrama.net','rdrama.com') and author.id in (PIZZASHILL_ID, CARP_ID): + if SITE.startswith('rdrama.') and author.id in (PIZZASHILL_ID, CARP_ID): abort(403, "This user is immune to awards.") if kind == "benefactor" and author.id == v.id: diff --git a/files/routes/chat.py b/files/routes/chat.py index a84096f0c..61a478728 100644 --- a/files/routes/chat.py +++ b/files/routes/chat.py @@ -56,7 +56,7 @@ def speak(data, v): global messages, total - if SITE in ('rdrama.net','rdrama.com'): text = data['message'][:200].strip() + if SITE.startswith('rdrama.'): text = data['message'][:200].strip() else: text = data['message'][:1000].strip() if not text: return '', 403 diff --git a/files/routes/static.py b/files/routes/static.py index 7ac34f3e6..9570676a8 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -22,7 +22,7 @@ def rdrama(id, title): @app.get("/marseys") @auth_required def marseys(v): - if SITE in ('rdrama.net','rdrama.com'): + if SITE.startswith('rdrama.'): marseys = g.db.query(Marsey, User).join(User, Marsey.author_id == User.id).filter(Marsey.submitter_id==None) sort = request.values.get("sort", "usage") if sort == "usage": @@ -56,7 +56,7 @@ def marsey_list(): if EMOJI_MARSEYS: emojis = [{ "name": emoji.name, - "author": author if SITE in ('rdrama.net','rdrama.com') or author == "anton-d" else None, + "author": author if SITE.startswith('rdrama.') or author == "anton-d" else None, # yikes, I don't really like this DB schema. Next time be better "tags": emoji.tags.split(" ") + [emoji.name[len("marsey"):] \ if emoji.name.startswith("marsey") else emoji.name], diff --git a/files/routes/users.py b/files/routes/users.py index 84354ddf8..2c8137060 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -428,7 +428,7 @@ def message2(v, username): body_html = sanitize(message) - if not (SITE in ('rdrama.net','rdrama.com') and user.id == BLACKJACKBTZ_ID): + if not (SITE.startswith('rdrama.') and user.id == BLACKJACKBTZ_ID): existing = g.db.query(Comment.id).filter(Comment.author_id == v.id, Comment.sentto == user.id, Comment.body_html == body_html, diff --git a/files/templates/comments.html b/files/templates/comments.html index 651e36dbf..921a3d68f 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -399,7 +399,7 @@ Context - + {% if v %} {% if not c.deleted_utc %} @@ -608,7 +608,7 @@ Context - + {% if v %} diff --git a/files/templates/hats.html b/files/templates/hats.html index 39c278b80..ffd3b0d9b 100644 --- a/files/templates/hats.html +++ b/files/templates/hats.html @@ -84,7 +84,7 @@ Hat Name Description - {% if SITE in ('rdrama.net','rdrama.com') %} + {% if SITE.startswith('rdrama.') %} {% if request.values.get("sort") == 'author_asc' %} Author {% else %} @@ -114,7 +114,7 @@ {{hat.name}} {{hat.censored_description(v)}} - {% if SITE in ('rdrama.net','rdrama.com') %} + {% if SITE.startswith('rdrama.') %} {% include "user_in_table.html" %} {% endif %} {{hat.number_sold}} diff --git a/files/templates/html_head.html b/files/templates/html_head.html index 5c200d4bb..a90dca6c7 100644 --- a/files/templates/html_head.html +++ b/files/templates/html_head.html @@ -35,7 +35,7 @@ {% endmacro %} {% macro cf_2fa_verify() %} - {% if SITE in ('rdrama.net','rdrama.com') %} + {% if SITE.startswith('rdrama.') %} {% elif SITE == 'watchpeopledie.tv' %} diff --git a/files/templates/marseys.html b/files/templates/marseys.html index e6337d574..c5f98fee5 100644 --- a/files/templates/marseys.html +++ b/files/templates/marseys.html @@ -7,7 +7,7 @@ Name Marsey Usage - {% if SITE in ('rdrama.net','rdrama.com') %} + {% if SITE.startswith('rdrama.') %} Author Added on Original File @@ -15,7 +15,7 @@ -{% if SITE in ('rdrama.net','rdrama.com') %} +{% if SITE.startswith('rdrama.') %} {% for marsey, user in marseys %} {{loop.index}} diff --git a/files/templates/post_actions.html b/files/templates/post_actions.html index 3b13d6877..45f470ab0 100644 --- a/files/templates/post_actions.html +++ b/files/templates/post_actions.html @@ -12,7 +12,7 @@ {% endif %} - + {% if v %} diff --git a/files/templates/post_actions_mobile.html b/files/templates/post_actions_mobile.html index beb68f641..fbf3d5b2a 100644 --- a/files/templates/post_actions_mobile.html +++ b/files/templates/post_actions_mobile.html @@ -8,7 +8,7 @@ {% if v and ((not p.ghost and v.admin_level >= PERMS['VOTES_VISIBLE']) or v.id == AEVANN_ID) %}{% endif %} - +