add progress bar to subscribe.html

This commit is contained in:
fram3d 2023-07-13 20:01:57 +02:00
parent 27c3e97b91
commit f423750248
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
3 changed files with 24 additions and 7 deletions

View File

@ -72,6 +72,15 @@ class sender():
return 0 return 0
def pledged(self):
sum = 0
f = open("donors.txt", "r")
for line in f:
sum += int(line.split(",")[1])
return sum
class donor(): class donor():
''' '''
Class that represents a donor Class that represents a donor

View File

@ -5,13 +5,16 @@ import donationcalc.donationconfig
@app.route('/donations/subscribe/', methods=['POST', 'GET']) @app.route('/donations/subscribe/', methods=['POST', 'GET'])
def subscribe(): def subscribe():
if request.method == 'GET': config = donationcalc.donationconfig.donationconfig()
return render_template('subscribe.html') currency = config.currency
elif request.method == 'POST':
config = donationcalc.donationconfig.donationconfig()
currency = config.currency
sender = donationcalc.models.sender()
sender = donationcalc.models.sender()
currentlypledged = sender.pledged()
currentpercent = round(currentlypledged/int(config.monthlycost), 2)
if request.method == 'GET':
return render_template('subscribe.html', monthlycost = int(config.monthlycost), pledged = currentlypledged, percent = currentpercent)
elif request.method == 'POST':
donoremail = request.form['email'] donoremail = request.form['email']
donormonthly = request.form['monthly'] donormonthly = request.form['monthly']

View File

@ -10,6 +10,8 @@
margin: 0 auto; margin: 0 auto;
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
color: #3d3d3d; color: #3d3d3d;
display: flex;
flex-direction: column;
} }
body { body {
@ -19,6 +21,9 @@
</head> </head>
<body> <body>
<main class="container"> <main class="container">
<h1 style="text-align:center;">Currently pledged to donate</h1>
<progress style="text-align:center;" id="donationprogress" max="{{ monthlycost }}" value="{{ pledged }}"> {{ percent }}% </progress>
<h1 style="text-align:center;">Subscribe for donation notifications</h1> <h1 style="text-align:center;">Subscribe for donation notifications</h1>
<form action="/donations/subscribe/" method="POST" style="text-align:center;"> <form action="/donations/subscribe/" method="POST" style="text-align:center;">
<label for="email">email</label> <label for="email">email</label>