Skip to content

Commit

Permalink
fixes for mail
Browse files Browse the repository at this point in the history
  • Loading branch information
jschiel committed Aug 4, 2023
1 parent 79e5e33 commit 91eb2d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
14 changes: 9 additions & 5 deletions backend/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ def send_checkout_mails(user_infos):
}
"""
for username, info in user_infos.items():
mail=username if "@" in username else f"{username}@{util.mail_postfix}"
# do for all
send_checkout_mail(info["name"], info["balance"],
info["income"], info["paid"], f"{username}@{util.mail_postfix}")
info["income"], info["paid"], mail)


def compile_latex(name):
Expand Down Expand Up @@ -118,9 +119,12 @@ def send_checkout_mail(name, current_balance, income, paid, mail_address):
raw_latex_file = raw_latex_file.replace("??income-table??", income_table)
raw_latex_file = raw_latex_file.replace("??paid-table??", paid_table)

with open('Latex/checkout.tex', "w") as writer:
filename="checkout"

with open(f'Latex/{filename}.tex', "w") as writer:
writer.write(raw_latex_file)

compile_latex(filename)

compile_latex("checkout")
send_mail_with_attachment("Getränkelisten Abrechnung", mail_address, "Latex/checkout.pdf",
"Abrechnung.pdf", util.checkout_mail_text.format(name=name, balance=format_float(current_balance)))
send_mail_with_attachment("Getränkelisten Abrechnung", mail_address, f"Latex/{filename}.pdf",
"Abrechnung.pdf", util.checkout_mail_text.format(name=name, balance=format_float(current_balance)))
7 changes: 4 additions & 3 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,9 @@ def put(self):
"""
db.do_checkout(request.json)
mail_infos = db.get_checkout_mail()
mail.send_checkout_mails(mail_infos)
return util.build_response()
if util.mail_server is not None:
mail.send_checkout_mails(mail_infos)
return util.build_response("")

@admin
def get(self):
Expand Down Expand Up @@ -690,7 +691,7 @@ def post(self):

if __name__ == "__main__":
if util.logging_enabled:
app.run("0.0.0.0", threaded=True)
app.run("0.0.0.0", threaded=True, debug=True)
else:
from waitress import serve
serve(app, host="0.0.0.0", port=5000, threads=4)

0 comments on commit 91eb2d2

Please sign in to comment.