plein de couleurs tout partout

This commit is contained in:
Colin Goutte 2021-10-01 14:43:15 +02:00
parent 4bcc49ad5f
commit cd76770863
2 changed files with 15 additions and 3 deletions

View File

@ -107,9 +107,21 @@ def list_notification_as_text(request: Request, idsonde: str):
changements = content["changes"]
status = content["status"]
def coloriser(message):
d = {"error": "red", "warning": "orange", "pending": "blue"}
for k, v in d.items():
if message.endswith(k):
return "color: %s;" % v
return ""
data = {"recipients": recipients, "changements": changements, "status": status}
return templates.TemplateResponse(
"notification_email.html", context={"request": request, "data": data}
"notification_email.html",
context={
"request": request,
"data": data,
"coloriser": coloriser,
},
)

View File

@ -11,14 +11,14 @@
{% if data['changements'] %}
<p> Changements </p>
{% for changement in data['changements'] %}
<p> {{changement}} </p>
<p style="{{ coloriser(changement) }}"> {{changement}} </p>
{% endfor %}
{% endif %}
{% if data['status'] %}
<p> État courant </p>
{% for status in data['status'] %}
<p> {{status}} </p>
<p style="{{ coloriser(status) }}"> {{status}} </p>
{% endfor %}
{% endif %}