Improve email formatting
This commit is contained in:
parent
764a5c68ec
commit
e32db2648a
@ -8,7 +8,7 @@ from builtins import str
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import smtplib
|
import smtplib
|
||||||
|
from money import Money
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.utils import formatdate, make_msgid
|
from email.utils import formatdate, make_msgid
|
||||||
@ -97,36 +97,28 @@ def send_notification(config, flats):
|
|||||||
for flat in flats:
|
for flat in flats:
|
||||||
title = str(flat.title)
|
title = str(flat.title)
|
||||||
flat_id = str(flat.id)
|
flat_id = str(flat.id)
|
||||||
area = str(flat.area)
|
area = str(int(flat.area))
|
||||||
cost = str(flat.cost)
|
cost = int(flat.cost)
|
||||||
currency = str(flat.currency)
|
currency = str(flat.currency)
|
||||||
|
|
||||||
txt += "- {}: {}#/flat/{} ({}: {}, {}: {} {})\n".format(
|
txt += f"- {title}: {website_url}#/flat/{flat_id}"
|
||||||
title,
|
html += f"""
|
||||||
website_url,
|
|
||||||
flat_id,
|
|
||||||
trs["area"],
|
|
||||||
area,
|
|
||||||
trs["cost"],
|
|
||||||
cost,
|
|
||||||
currency,
|
|
||||||
)
|
|
||||||
|
|
||||||
html += """
|
|
||||||
<li>
|
<li>
|
||||||
<a href="{}#/flat/{}">{}</a>
|
<a href="{website_url}#/flat/{flat_id}">{title}</a>
|
||||||
({}: {}, {}: {} {})
|
"""
|
||||||
</li>
|
|
||||||
""".format(
|
fields = []
|
||||||
website_url,
|
if area:
|
||||||
flat_id,
|
fields.append(f"{trs['area']}: {area}m²")
|
||||||
title,
|
if cost:
|
||||||
trs["area"],
|
money = Money(cost, currency).format(config["notification_lang"])
|
||||||
area,
|
fields.append(f"{trs['cost']}: {money}")
|
||||||
trs["cost"],
|
|
||||||
cost,
|
if len(fields):
|
||||||
currency,
|
txt += f'({", ".join(fields)})'
|
||||||
)
|
html += f'({", ".join(fields)})'
|
||||||
|
|
||||||
|
html += "</li>"
|
||||||
|
|
||||||
html += "</ul>"
|
html += "</ul>"
|
||||||
|
|
||||||
|
@ -17,3 +17,4 @@ unidecode
|
|||||||
vobject
|
vobject
|
||||||
whoosh
|
whoosh
|
||||||
https://git.weboob.org/weboob/weboob/repository/archive.zip?ref=master
|
https://git.weboob.org/weboob/weboob/repository/archive.zip?ref=master
|
||||||
|
money
|
||||||
|
Loading…
Reference in New Issue
Block a user