From 104e53c6ae8444cd8552fbdf2ff53da07be0cf3a Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 31 Jan 2024 23:23:57 +0200 Subject: [PATCH] add houses to WPD --- files/helpers/config/const.py | 9 +++------ files/helpers/stats.py | 16 +++------------- files/routes/settings.py | 2 +- files/templates/settings/personal.html | 2 +- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 937d44804..4f7a197a7 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -420,7 +420,7 @@ FEATURES = { 'PRONOUNS': False, 'BADGES': True, 'HATS': True, - 'HOUSES': False, + 'HOUSES': True, 'GAMBLING': True, 'USERS_PROFILE_BANNER': True, 'USERS_PROFILE_BODYTEXT': True, @@ -436,6 +436,7 @@ FEATURES = { 'PING_GROUPS': True, 'BOTS': True, } +HOUSES = ["Furry","Femboy","Vampire","Racist","Edgy"] WERKZEUG_ERROR_DESCRIPTIONS = { 400: "The browser (or proxy) sent a request that this server could not understand.", @@ -630,7 +631,6 @@ if SITE in {'rdrama.net', 'staging.rdrama.net'}: DEFAULT_TIME_FILTER = "day" FEATURES['PRONOUNS'] = True - FEATURES['HOUSES'] = True FEATURES['USERS_PERMANENT_WORD_FILTERS'] = True BUG_THREAD = 18459 @@ -723,6 +723,7 @@ elif SITE == 'watchpeopledie.tv': FEATURES['NSFW_MARKING'] = False FEATURES['BOTS'] = False FEATURES['HAT_SUBMISSIONS'] = False + HOUSES = ["Furry","Femboy","Vampire","Edgy"] PERMS['POST_COMMENT_EDITING'] = 3 PERMS['MODS_EVERY_HOLE'] = 3 @@ -811,18 +812,14 @@ elif SITE == 'watchpeopledie.tv': elif SITE == 'devrama.net': AEVANN_ID = 7 FEATURES['PRONOUNS'] = True - FEATURES['HOUSES'] = True FEATURES['USERS_PERMANENT_WORD_FILTERS'] = True PERMS["SITE_SETTINGS"] = 4 PERMS["ORGIES"] = 4 else: # localhost or testing environment implied FEATURES['PRONOUNS'] = True - FEATURES['HOUSES'] = True FEATURES['USERS_PERMANENT_WORD_FILTERS'] = True HOLE_BANNER_LIMIT = 69420 -HOUSES = ("None","Furry","Femboy","Vampire","Racist","Edgy") if FEATURES['HOUSES'] else ("None") - BOT_IDs = {AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID} COLORS = {'ff459a','805ad5','62ca56','38a169','80ffff','2a96f3','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58','8cdbe6', DEFAULT_COLOR} diff --git a/files/helpers/stats.py b/files/helpers/stats.py index 63ebd6840..218c7bfc5 100644 --- a/files/helpers/stats.py +++ b/files/helpers/stats.py @@ -122,18 +122,8 @@ def stats(): } if FEATURES['HOUSES']: - stats2 = { - "House Furry members": "{:,}".format(g.db.query(User).filter(User.house.like('Furry%')).count()), - "House Femboy members": "{:,}".format(g.db.query(User).filter(User.house.like('Femboy%')).count()), - "House Vampire members": "{:,}".format(g.db.query(User).filter(User.house.like('Vampire%')).count()), - "House Racist members": "{:,}".format(g.db.query(User).filter(User.house.like('Racist%')).count()), - "House Edgy members": "{:,}".format(g.db.query(User).filter(User.house.like('Edgy%')).count()), - "House Furry total truescore": "{:,}".format(g.db.query(func.sum(User.truescore)).filter(User.house.like('Furry%')).scalar() or 0), - "House Femboy total truescore": "{:,}".format(g.db.query(func.sum(User.truescore)).filter(User.house.like('Femboy%')).scalar() or 0), - "House Vampire total truescore": "{:,}".format(g.db.query(func.sum(User.truescore)).filter(User.house.like('Vampire%')).scalar() or 0), - "House Racist total truescore": "{:,}".format(g.db.query(func.sum(User.truescore)).filter(User.house.like('Racist%')).scalar() or 0), - "House Edgy total truescore": "{:,}".format(g.db.query(func.sum(User.truescore)).filter(User.house.like('Edgy%')).scalar() or 0), - } - stats.update(stats2) + for house in HOUSES: + stats[f"House {house} members"] = "{:,}".format(g.db.query(User).filter(User.house.like(f'{house}%')).count()) + stats[f"House {house} total truescore"] = "{:,}".format(g.db.query(func.sum(User.truescore)).filter(User.house.like(f'{house}%')).scalar() or 0) return stats diff --git a/files/routes/settings.py b/files/routes/settings.py index 17930db49..270209e5c 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -356,7 +356,7 @@ def settings_personal_post(v): else: abort(400, f"{theme} is not a valid theme") house = request.values.get("house") - if not updated and house and house in HOUSES and FEATURES['HOUSES']: + if not updated and house and house in ["None"]+HOUSES and FEATURES['HOUSES']: if v.bite: abort(403) if v.house: if v.house.replace(' Founder', '') == house: abort(409, f"You're already in House {house}") diff --git a/files/templates/settings/personal.html b/files/templates/settings/personal.html index 718e06af1..d78b0d875 100644 --- a/files/templates/settings/personal.html +++ b/files/templates/settings/personal.html @@ -101,7 +101,7 @@ {% endif %}