From da12c2f81242a8cc4738b1e20f44af9d1262ef29 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 2 Jan 2022 16:12:19 +0200 Subject: [PATCH] fds --- files/routes/admin.py | 19 +++++++++++++++++++ files/routes/settings.py | 20 +------------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index b053a1bbe7..f0d3b0cb31 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -27,6 +27,25 @@ if SITE_NAME == 'PCM': cc = "splash mountain" else: cc = "country club" month = datetime.now().strftime('%B') +@app.get("/admin/sex2") +@admin_level_required(3) +def sex2(v): + for u in g.db.query(User).filter(User.patron > 0).all(): + tier = u.patron + 20 + + if not u.has_badge(tier): + new_badge = Badge(badge_id=tier, user_id=u.id) + g.db.add(new_badge) + print(f'{u.username} with {u.patron} was given {tier}') + + for num in [21,22,23,24,25]: + if num != tier: + existing = u.has_badge(num) + if existing: + g.db.delete(existing) + print(f'{u.username} with {u.patron} was removed {num}') + g.db.commit() + return "sex" @app.get("/admin/grassed") @admin_level_required(2) diff --git a/files/routes/settings.py b/files/routes/settings.py index fb53379092..65eefeb277 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -26,32 +26,14 @@ IMGUR_KEY = environ.get("IMGUR_KEY").strip() GUMROAD_ID = environ.get("GUMROAD_ID", "tfcvri").strip() tiers={ - "(LlamaBean)": 1, "(Paypig)": 1, "(Renthog)": 2, "(Landchad)": 3, "(Terminally online turboautist)": 4, "(Rich Bich)": 5, + "(LlamaBean)": 1, } - -@app.get("/sex") -@admin_level_required(3) -def sex(v): - for u in g.db.query(User).filter(User.patron > 0, User.patron != 5, User.email != None).all(): - data = {'access_token': GUMROAD_TOKEN, 'email': u.email} - response = requests.get('https://api.gumroad.com/v2/sales', data=data).json()["sales"] - - if len(response) == 0: - print(f"{u.username}: email not found") - continue - - response = response[0] - tier = tiers[response["variants_and_quantity"]] - if u.patron != tier: - print(f"{u.username}: patron {u.patron} tier {tier}") - return "sex" - @app.post("/settings/removebackground") @limiter.limit("1/second") @auth_required