def cosmetics_post(): user_id = request.form.get("user_id", None) if not user_id: abort(400) css = request.form.get("css", None) css_limit = int(request.form.get("css_limit", 0)) guest_icon = request.form.get("guest_icon", None) badges = request.form.get("badges", None) entry = db.session.query(Cosmetics).filter( Cosmetics.user_id == user_id).first() if entry: abort(409) user = Cosmetics(user_id) if css: css = css.lower() == "true" user.css = css if css_limit is not None: user.css_limit = css_limit if guest_icon is not None: guest_icon = guest_icon.lower() == "true" user.guest_icon = guest_icon if badges is not None: badges = badges.split(",") if badges == [""]: badges = [] user.badges = json.dumps(badges) db.session.add(user) db.session.commit() return ('', 204)
def donate_patch(): item = request.form.get('item') amount = int(request.form.get('amount')) if amount <= 0: abort(400) subtract_amt = 0 entry = db.session.query(Cosmetics).filter( Cosmetics.user_id == session["user_id"]).first() if item == "custom_css_slots": subtract_amt = 100 if item == "guest_icon": subtract_amt = 300 if entry is not None and entry.guest_icon: abort(400) amt_change = -1 * subtract_amt * amount subtract = set_titan_token(session["user_id"], amt_change, "BUY " + item + " x" + str(amount)) if not subtract: return ('', 402) session["tokens"] += amt_change if item == "custom_css_slots": if not entry: entry = Cosmetics(session["user_id"]) entry.css_limit = 0 entry.css = True entry.css_limit += amount if item == "guest_icon": if not entry: entry = Cosmetics(session["user_id"]) entry.guest_icon = True db.session.add(entry) return ('', 204)
def cosmetics_post(): user_id = request.form.get("user_id", None) if not user_id: abort(400) css = request.form.get("css", None) entry = db.session.query(Cosmetics).filter( Cosmetics.user_id == user_id).first() if entry: abort(409) user = Cosmetics(user_id) if css: css = css.lower() == "true" user.css = css db.session.add(user) db.session.commit() return ('', 204)
def cosmetics_post(): user_id = request.form.get("user_id", None) if not user_id: abort(400) css = request.form.get("css", None) css_limit = int(request.form.get("css_limit", 0)) webhook_icon = request.form.get("webhook_icon", None) entry = db.session.query(Cosmetics).filter( Cosmetics.user_id == user_id).first() if entry: abort(409) user = Cosmetics(user_id) if css: css = css.lower() == "true" user.css = css if css_limit is not None: user.css_limit = css_limit if webhook_icon is not None: webhook_icon = webhook_icon.lower() == "true" user.webhook_icon = webhook_icon db.session.add(user) db.session.commit() return ('', 204)