From dece3fd460b205f4dcc613076500d0b85c36313b Mon Sep 17 00:00:00 2001 From: TLSM Date: Mon, 6 Jun 2022 19:02:23 -0400 Subject: [PATCH 1/5] Add user title coin cost parameter. --- files/helpers/const.py | 3 +++ files/helpers/jinja2.py | 5 ++++- files/routes/settings.py | 4 ++++ files/templates/settings_profile.html | 6 ++++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index cc1313f98..f45237d89 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -131,8 +131,11 @@ AGENDAPOSTER_MSG = """Hi @{username},\n\nYour {type} has been automatically remo PIN_LIMIT = 3 POST_RATE_LIMIT = "1/second;2/minute;10/hour;50/day" +USER_TITLE_COST = 0 + if SITE in {'rdrama.net','devrama.xyz'}: HOLE_COST = 200000 + USER_TITLE_COST = 25 NOTIFICATIONS_ID = 1046 AUTOJANNY_ID = 2360 SNAPPY_ID = 261 diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index 49701af9f..57c53cff7 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -55,4 +55,7 @@ def inject_constants(): "CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID, "PIZZASHILL_ID":PIZZASHILL_ID, "config":app.config.get, "DEFAULT_COLOR":DEFAULT_COLOR, "COLORS":COLORS, "ADMIGGERS":ADMIGGERS, "datetime":datetime, "time":time, - "LOTTERY_ENABLED": LOTTERY_ENABLED} \ No newline at end of file + "LOTTERY_ENABLED": LOTTERY_ENABLED, + # Below this line really should be refactored as params to render_template + "USER_TITLE_COST": USER_TITLE_COST, + } \ No newline at end of file diff --git a/files/routes/settings.py b/files/routes/settings.py index 2dd3b81a4..97366189d 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -917,6 +917,10 @@ def settings_title_change(v): v.customtitle = filter_emojis_only(new_name) + if USER_TITLE_COST and v.coins < USER_TITLE_COST: + return render_template("settings_profile.html", v=v, error=f"Changing flair costs {USER_TITLE_COST} DC.") + v.coins -= USER_TITLE_COST + if len(v.customtitle) < 1000: g.db.add(v) g.db.commit() diff --git a/files/templates/settings_profile.html b/files/templates/settings_profile.html index 3aa75c794..c804c496d 100644 --- a/files/templates/settings_profile.html +++ b/files/templates/settings_profile.html @@ -470,11 +470,13 @@
- +
    - Limit of 100 characters + Limit of 100 characters + {%- if USER_TITLE_COST %} — Costs {{USER_TITLE_COST}} DC to change.{% endif -%} +
From 70b96162a75daf8aae22c5c782210c05d68c8471 Mon Sep 17 00:00:00 2001 From: TLSM Date: Mon, 6 Jun 2022 22:18:56 -0400 Subject: [PATCH 4/5] Fix banned domain info leak in modlog. --- files/routes/static.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/files/routes/static.py b/files/routes/static.py index a1f6b2604..4e2eb1a1e 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -329,8 +329,12 @@ def log(v): if kind not in types: kind = None actions = g.db.query(ModAction) - if not (v and v.admin_level > 1): - actions = actions.filter(ModAction.kind.notin_(["shadowban","unshadowban","flair_post","edit_post"])) + if not (v and v.admin_level >= 2): + actions = actions.filter(ModAction.kind.notin_([ + "shadowban","unshadowban","flair_post","edit_post"])) + if not (v and v.admin_level >= 3): + actions = actions.filter(ModAction.kind.notin_([ + 'ban_domain', 'unban_domain',])) if admin_id: actions = actions.filter_by(user_id=admin_id) @@ -345,7 +349,7 @@ def log(v): next_exists=len(actions)>25 actions=actions[:25] - admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level > 1).order_by(User.username).all()] + admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= 2).order_by(User.username).all()] return render_template("log.html", v=v, admins=admins, types=types, admin=admin, type=kind, actions=actions, next_exists=next_exists, page=page)