alarms: handle missing last update

This commit is contained in:
Iain Learmonth 2022-04-20 15:56:09 +01:00
parent 45a6d27c8b
commit 0d4296c89c
2 changed files with 8 additions and 1 deletions

View file

@ -20,6 +20,13 @@ def calculate_mirror_expiry(s):
return f"{countdown.days} days" return f"{countdown.days} days"
@portal.app_template_filter("format_datetime")
def format_datetime(s):
if s is None:
return "Unknown"
return s.strftime("%a, %d %b %Y %H:%M:%S")
@portal.route("/") @portal.route("/")
def portal_home(): def portal_home():
return render_template("home.html.j2", section="home") return render_template("home.html.j2", section="home")

View file

@ -28,7 +28,7 @@
<td>{{ alarm.alarm_type }}</td> <td>{{ alarm.alarm_type }}</td>
<td>{{ alarm.alarm_state.name }}</td> <td>{{ alarm.alarm_state.name }}</td>
<td>{{ alarm.text }}</td> <td>{{ alarm.text }}</td>
<td>{{ alarm.last_updated.strftime("%a, %d %b %Y %H:%M:%S") }}</td> <td>{{ alarm.last_updated | format_date }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>