From 4eb9095ae53bad4d85c75760ea7c0d6c39dafe15 Mon Sep 17 00:00:00 2001 From: "Outrun Colors, LLC" Date: Sat, 28 May 2022 18:26:30 -0500 Subject: [PATCH] Initial connection of front-end to back-end. --- files/routes/__init__.py | 3 +- files/routes/lottery.py | 20 ++++++++++ files/templates/lottery_modal.html | 64 +++++++++++++++++++++++++++++- 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 files/routes/lottery.py diff --git a/files/routes/__init__.py b/files/routes/__init__.py index 6d73bd1fcf..46a9ae5647 100644 --- a/files/routes/__init__.py +++ b/files/routes/__init__.py @@ -15,4 +15,5 @@ from .votes import * from .feeds import * from .awards import * from .giphy import * -from .subs import * \ No newline at end of file +from .subs import * +from .lottery import * \ No newline at end of file diff --git a/files/routes/lottery.py b/files/routes/lottery.py new file mode 100644 index 0000000000..7ef7923b14 --- /dev/null +++ b/files/routes/lottery.py @@ -0,0 +1,20 @@ +from files.__main__ import app, limiter +from files.helpers.wrappers import * +from files.helpers.alerts import * +from files.helpers.get import * +from files.helpers.const import * + +@app.post("/lottery/buy") +@limiter.limit("1/second;30/minute;200/hour;1000/day") +@auth_required +def lottery_buy(v): + if v.coins < 12: + return {"error": "Lottershe tickets cost 12 dramacoins each."}, 400 + + # Charge user for ticket + v.coins -= 12 + + # Save changes + g.db.commit() + + return {"message": "Lottershe ticket purchased!"} diff --git a/files/templates/lottery_modal.html b/files/templates/lottery_modal.html index 52892761ae..b0183d65f1 100644 --- a/files/templates/lottery_modal.html +++ b/files/templates/lottery_modal.html @@ -57,6 +57,7 @@ type="button" class="btn btn-success lottery-modal--action" id="purchaseTicket" + onclick="purchaseLotteryTicket()" > Purchase 1 for - 10 + 12 + + + + + + +