From ce66431a0141b47b0ea5f1f0ab5df8807ff8dce9 Mon Sep 17 00:00:00 2001 From: George Lacey Date: Sat, 8 May 2021 23:03:56 +0100 Subject: [PATCH] Display recent errors --- borgweb/borg/models/repo.py | 4 ++-- borgweb/borg/static/css/index.css | 2 +- borgweb/borg/templates/borg/index.html | 13 ++++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/borgweb/borg/models/repo.py b/borgweb/borg/models/repo.py index 29cc473..ff97d9c 100644 --- a/borgweb/borg/models/repo.py +++ b/borgweb/borg/models/repo.py @@ -31,9 +31,9 @@ class Repo(models.Model): def recent_errors(self): days = 7 - days_ago = (datetime.utcnow() - timedelta(days=7)) + days_ago = (datetime.utcnow() - timedelta(days=days)) errors = self.label.errors.all().filter(time__gt=days_ago) - return len(errors) + return errors def archive_dates(self): days = self.get_archive_days() diff --git a/borgweb/borg/static/css/index.css b/borgweb/borg/static/css/index.css index f814a8d..21b4ae6 100644 --- a/borgweb/borg/static/css/index.css +++ b/borgweb/borg/static/css/index.css @@ -5,6 +5,6 @@ div { } dl { - margin: 0px; + margin: 4px; font-size: 16px; } \ No newline at end of file diff --git a/borgweb/borg/templates/borg/index.html b/borgweb/borg/templates/borg/index.html index 796882c..01cd027 100644 --- a/borgweb/borg/templates/borg/index.html +++ b/borgweb/borg/templates/borg/index.html @@ -17,7 +17,7 @@

{% if repo_list %} {% for repo in repo_list %} -
+

{{ repo.label }} {{ repo.location }}

Latest backup:
@@ -31,9 +31,16 @@
Size:
{{ repo.size }}
+ {% if repo.recent_errors|length > 0 %}
-
Recent errors:
-
{{ repo.recent_errors }}
+
Recent errors:
+
+ {% endif %} +
+ {% for error in repo.recent_errors %} +
{{ error.time|date:'d-m-Y H:i' }}
+
{{ error.error }}
+ {% endfor %}
{% endfor %}