yeet pystache
This commit is contained in:
parent
3fef58826b
commit
ad84d50ef6
|
@ -1,4 +1,3 @@
|
||||||
Hi {{your_name}}!
|
Hi $your_name!
|
||||||
|
|
||||||
Unfortunately, {{user.email}} has chosen to cancel their monthly donation of
|
Unfortunately, $email has chosen to cancel their monthly donation of $amount.
|
||||||
{{amount}}.
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
An attempt was just made to charge your card for your monthly donation to
|
An attempt was just made to charge your card for your monthly donation to
|
||||||
{{your_name}} for {{amount}}. Unfortunately, your card was declined.
|
$your_name for $amount. Unfortunately, your card was declined.
|
||||||
|
|
||||||
The donation has been disabled. If you would like to, you may create a new
|
The donation has been disabled. If you would like to, you may create a new
|
||||||
recurring donation here:
|
recurring donation here:
|
||||||
|
|
||||||
{{root}}
|
$root
|
||||||
|
|
||||||
Thanks!
|
Thanks!
|
||||||
|
|
||||||
--
|
--
|
||||||
{{your_name}}
|
$your_name
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Hi {{your_name}}!
|
Hi $your_name!
|
||||||
|
|
||||||
Good news: {{user.email}} just donated {{amount}}{{frequency}}!
|
Good news: $email just donated $amount$frequency!
|
||||||
|
|
||||||
{{comment}}
|
$comment
|
||||||
|
|
|
@ -2,12 +2,12 @@ Someone, probably you, wants to reset your donor password.
|
||||||
|
|
||||||
To proceed, click this link:
|
To proceed, click this link:
|
||||||
|
|
||||||
{{root}}/password-reset/{{user.password_reset}}
|
$root/password-reset/$password_reset
|
||||||
|
|
||||||
This link expires in 24 hours. If you don't want to change your password or you
|
This link expires in 24 hours. If you don't want to change your password or you
|
||||||
weren't expecting this email, just ignore it.
|
weren't expecting this email, just ignore it.
|
||||||
|
|
||||||
If you have questions, send an email to {{your_email}}.
|
If you have questions, send an email to $your_email.
|
||||||
|
|
||||||
--
|
--
|
||||||
{{your_name}}
|
$your_name
|
||||||
|
|
|
@ -2,18 +2,13 @@ Thank you for donating!
|
||||||
|
|
||||||
Receipt:
|
Receipt:
|
||||||
|
|
||||||
{{#monthly}}
|
$summary $amount
|
||||||
Monthly donation {{amount}}
|
|
||||||
{{/monthly}}
|
|
||||||
{{^monthly}}
|
|
||||||
One-time donation {{amount}}
|
|
||||||
{{/monthly}}
|
|
||||||
|
|
||||||
You can view and manage your donations online here:
|
You can view and manage your donations online here:
|
||||||
|
|
||||||
{{root}}/panel
|
$root/panel
|
||||||
|
|
||||||
Thanks again! If you have questions, contact {{your_email}}.
|
Thanks again! If you have questions, contact $your_email.
|
||||||
|
|
||||||
--
|
--
|
||||||
{{your_name}}
|
$your_name
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import smtplib
|
import smtplib
|
||||||
import pystache
|
|
||||||
import os
|
import os
|
||||||
import html.parser
|
import html.parser
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.utils import localtime, format_datetime
|
from email.utils import localtime, format_datetime
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
|
from string import Template
|
||||||
|
|
||||||
from fosspay.database import db
|
from fosspay.database import db
|
||||||
from fosspay.objects import User, DonationType
|
from fosspay.objects import User, DonationType
|
||||||
|
@ -20,15 +20,14 @@ def send_thank_you(user, amount, monthly):
|
||||||
smtp.starttls()
|
smtp.starttls()
|
||||||
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
|
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
|
||||||
with open("emails/thank-you") as f:
|
with open("emails/thank-you") as f:
|
||||||
message = MIMEText(html.parser.HTMLParser().unescape(\
|
tmpl = Template(f.read())
|
||||||
pystache.render(f.read(), {
|
message = MIMEText(tmpl.substitute(**{
|
||||||
"user": user,
|
"root": _cfg("protocol") + "://" + _cfg("domain"),
|
||||||
"root": _cfg("protocol") + "://" + _cfg("domain"),
|
"your_name": _cfg("your-name"),
|
||||||
"your_name": _cfg("your-name"),
|
"summary": ("Monthly donation" if monthly else "One-time donation"),
|
||||||
"amount": currency.amount("{:.2f}".format(amount / 100)),
|
"amount": currency.amount("{:.2f}".format(amount / 100)),
|
||||||
"monthly": monthly,
|
"your_email": _cfg("your-email")
|
||||||
"your_email": _cfg("your-email")
|
}))
|
||||||
})))
|
|
||||||
message['Subject'] = "Thank you for your donation!"
|
message['Subject'] = "Thank you for your donation!"
|
||||||
message['From'] = _cfg("smtp-from")
|
message['From'] = _cfg("smtp-from")
|
||||||
message['To'] = user.email
|
message['To'] = user.email
|
||||||
|
@ -44,13 +43,13 @@ def send_password_reset(user):
|
||||||
smtp.starttls()
|
smtp.starttls()
|
||||||
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
|
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
|
||||||
with open("emails/reset-password") as f:
|
with open("emails/reset-password") as f:
|
||||||
message = MIMEText(html.parser.HTMLParser().unescape(\
|
tmpl = Template(f.read())
|
||||||
pystache.render(f.read(), {
|
message = MIMEText(tmpl.substitute(**{
|
||||||
"user": user,
|
"password_reset": user.password_reset,
|
||||||
"root": _cfg("protocol") + "://" + _cfg("domain"),
|
"root": _cfg("protocol") + "://" + _cfg("domain"),
|
||||||
"your_name": _cfg("your-name"),
|
"your_name": _cfg("your-name"),
|
||||||
"your_email": _cfg("your-email")
|
"your_email": _cfg("your-email")
|
||||||
})))
|
}))
|
||||||
message['Subject'] = "Reset your donor password"
|
message['Subject'] = "Reset your donor password"
|
||||||
message['From'] = _cfg("smtp-from")
|
message['From'] = _cfg("smtp-from")
|
||||||
message['To'] = user.email
|
message['To'] = user.email
|
||||||
|
@ -66,13 +65,12 @@ def send_declined(user, amount):
|
||||||
smtp.starttls()
|
smtp.starttls()
|
||||||
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
|
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
|
||||||
with open("emails/declined") as f:
|
with open("emails/declined") as f:
|
||||||
message = MIMEText(html.parser.HTMLParser().unescape(\
|
tmpl = Template(f.read())
|
||||||
pystache.render(f.read(), {
|
message = MIMEText(tmpl.substitute(**{
|
||||||
"user": user,
|
"root": _cfg("protocol") + "://" + _cfg("domain"),
|
||||||
"root": _cfg("protocol") + "://" + _cfg("domain"),
|
"your_name": _cfg("your-name"),
|
||||||
"your_name": _cfg("your-name"),
|
"amount": currency.amount("{:.2f}".format(amount / 100))
|
||||||
"amount": currency.amount("{:.2f}".format(amount / 100))
|
}))
|
||||||
})))
|
|
||||||
message['Subject'] = "Your monthly donation was declined."
|
message['Subject'] = "Your monthly donation was declined."
|
||||||
message['From'] = _cfg("smtp-from")
|
message['From'] = _cfg("smtp-from")
|
||||||
message['To'] = user.email
|
message['To'] = user.email
|
||||||
|
@ -88,17 +86,16 @@ def send_new_donation(user, donation):
|
||||||
smtp.starttls()
|
smtp.starttls()
|
||||||
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
|
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
|
||||||
with open("emails/new_donation") as f:
|
with open("emails/new_donation") as f:
|
||||||
message = MIMEText(html.parser.HTMLParser().unescape(\
|
tmpl = Template(f.read())
|
||||||
pystache.render(f.read(), {
|
message = MIMEText(tmpl.substitute(**{
|
||||||
"user": user,
|
"email": user.email,
|
||||||
"root": _cfg("protocol") + "://" + _cfg("domain"),
|
"your_name": _cfg("your-name"),
|
||||||
"your_name": _cfg("your-name"),
|
"amount": currency.amount("{:.2f}".format(
|
||||||
"amount": currency.amount("{:.2f}".format(
|
donation.amount / 100)),
|
||||||
donation.amount / 100)),
|
"frequency": (" per month"
|
||||||
"frequency": (" per month"
|
if donation.type == DonationType.monthly else ""),
|
||||||
if donation.type == DonationType.monthly else ""),
|
"comment": donation.comment or "",
|
||||||
"comment": donation.comment or "",
|
}))
|
||||||
})))
|
|
||||||
message['Subject'] = "New donation on fosspay!"
|
message['Subject'] = "New donation on fosspay!"
|
||||||
message['From'] = _cfg("smtp-from")
|
message['From'] = _cfg("smtp-from")
|
||||||
message['To'] = f"{_cfg('your-name')} <{_cfg('your-email')}>"
|
message['To'] = f"{_cfg('your-name')} <{_cfg('your-email')}>"
|
||||||
|
@ -114,14 +111,14 @@ def send_cancellation_notice(user, donation):
|
||||||
smtp.starttls()
|
smtp.starttls()
|
||||||
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
|
smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
|
||||||
with open("emails/cancelled") as f:
|
with open("emails/cancelled") as f:
|
||||||
message = MIMEText(html.parser.HTMLParser().unescape(\
|
tmpl = Template(f.read())
|
||||||
pystache.render(f.read(), {
|
message = MIMEText(tmpl.substitute(**{
|
||||||
"user": user,
|
"email": user.email,
|
||||||
"root": _cfg("protocol") + "://" + _cfg("domain"),
|
"root": _cfg("protocol") + "://" + _cfg("domain"),
|
||||||
"your_name": _cfg("your-name"),
|
"your_name": _cfg("your-name"),
|
||||||
"amount": currency.amount("{:.2f}".format(
|
"amount": currency.amount("{:.2f}".format(
|
||||||
donation.amount / 100)),
|
donation.amount / 100)),
|
||||||
})))
|
}))
|
||||||
message['Subject'] = "A monthly donation on fosspay has been cancelled"
|
message['Subject'] = "A monthly donation on fosspay has been cancelled"
|
||||||
message['From'] = _cfg("smtp-from")
|
message['From'] = _cfg("smtp-from")
|
||||||
message['To'] = f"{_cfg('your-name')} <{_cfg('your-email')}>"
|
message['To'] = f"{_cfg('your-name')} <{_cfg('your-email')}>"
|
||||||
|
|
|
@ -7,4 +7,3 @@ psycopg2
|
||||||
bcrypt
|
bcrypt
|
||||||
gunicorn
|
gunicorn
|
||||||
sqlalchemy-utils
|
sqlalchemy-utils
|
||||||
pystache
|
|
||||||
|
|
Loading…
Reference in New Issue