Exemplo n.º 1
0
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)
Exemplo n.º 2
0
Arquivo: user.py Projeto: pegasy/Titan
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)
Exemplo n.º 3
0
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)
    send_rich_embed = request.form.get("send_rich_embed", 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 send_rich_embed:
        send_rich_embed = send_rich_embed.lower() == "true"
        user.send_rich_embed = send_rich_embed
    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)
Exemplo n.º 4
0
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)
    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
    db.session.add(user)
    db.session.commit()
    return ('', 204)