27 lines
920 B
Python
27 lines
920 B
Python
from flask import render_template, request, redirect
|
|
from donationcalc import app
|
|
import donationcalc.models
|
|
import donationcalc.donationconfig
|
|
|
|
@app.route('/donations/subscribe/', methods=['POST', 'GET'])
|
|
def subscribe():
|
|
if request.method == 'GET':
|
|
return render_template('subscribe.html')
|
|
elif request.method == 'POST':
|
|
config = donationcalc.donationconfig.donationconfig()
|
|
currency = config.currency
|
|
sender = donationcalc.models.sender()
|
|
|
|
donoremail = request.form['email']
|
|
donormonthly = request.form['monthly']
|
|
|
|
newdonor = donationcalc.models.donor(email = donoremail, monthly = donormonthly)
|
|
|
|
f = open("donors.txt","a")
|
|
f.write(f"{donoremail},{donormonthly}\n")
|
|
f.close()
|
|
|
|
return f"You subscribed to monthly reminder to donate {donormonthly} {currency}"
|
|
else:
|
|
return 'HTTP request method not recogniezed'
|