diff --git a/borgweb/borg/models/error.py b/borgweb/borg/models/error.py index f242e75..24849e2 100644 --- a/borgweb/borg/models/error.py +++ b/borgweb/borg/models/error.py @@ -1,7 +1,6 @@ from django.db import models from . import Label from ..utility.time import time_ago -from datetime import datetime class Error(models.Model): diff --git a/borgweb/borg/models/repo.py b/borgweb/borg/models/repo.py index 904a6e5..180fcf9 100644 --- a/borgweb/borg/models/repo.py +++ b/borgweb/borg/models/repo.py @@ -1,6 +1,6 @@ from django.db import models from datetime import datetime, timedelta -from ..utility.time import seconds_to_string +from ..utility.time import seconds_to_string, subtract_months from ..utility.data import bytes_to_string, convert_bytes from . import Label @@ -102,6 +102,23 @@ class Repo(models.Model): def hourly_archive_string(self): return ''.join(['H' if archive is not None else '-' for archive in self.hourly_archives(24)]) + def monthly_archives(self, n_months: int = 12): + archives = [] + for month in range(n_months): + current_date = subtract_months(datetime.utcnow().date(), month) + print(current_date) + archive_current_month = self.archive_set.all()\ + .filter(start__year__gte=current_date.year, + start__month__gte=current_date.month, + start__year__lte=current_date.year, + start__month__lte=current_date.month)\ + .order_by('-start') + if len(archive_current_month) > 0: + archives.append(archive_current_month[0]) + else: + archives.append(None) + return archives + def daily_archives(self, n_days: int = 24): archives = [] for day in range(n_days): diff --git a/borgweb/borg/templates/borg/index.html b/borgweb/borg/templates/borg/index.html index ccc2d9b..cfba89a 100644 --- a/borgweb/borg/templates/borg/index.html +++ b/borgweb/borg/templates/borg/index.html @@ -14,47 +14,46 @@ {{ hour_list|json_script:"hour_list" }} -

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

{{ repo.label }} - {{ repo.location }} +

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

-
-
Latest backup:
-
{{ repo.last_backup }}
+
+
Latest backup:
+
{{ repo.last_backup }}
-
-
Hourly backups:
-
{{ repo.hourly_archive_string }}
+
+
Hourly backups:
+
{{ repo.hourly_archive_string }}
-
-
Size:
-
{{ repo.size_string }}
+
+
Size:
+
{{ repo.size_string }}
{% if repo.recent_errors|length > 0 %}
Recent errors:
{% endif %} -
+
{% for error in repo.recent_errors %} -
{{ error.time_ago }}
-
{{ error.error }}
+
{{ error.time_ago }}
+
{{ error.error }}
{% endfor %}
{% endfor %} -
+
{% else %} diff --git a/borgweb/borgweb/settings.py b/borgweb/borgweb/settings.py index 14e7840..dc599b1 100644 --- a/borgweb/borgweb/settings.py +++ b/borgweb/borgweb/settings.py @@ -124,7 +124,6 @@ import os STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'root') -print(os.path.join(BASE_DIR, 'bootstrap', 'dist')) STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR, 'bootstrap', 'dist'),