From 21eab091540944f247ca03b25e944430a9462d56 Mon Sep 17 00:00:00 2001 From: Matthias Kestenholz Date: Mon, 8 Jul 2024 19:52:51 +0200 Subject: [PATCH] Show time of last update Refs #8. --- app/templates/projects/project.html | 7 ++++++- app/templates/projects/projects.html | 7 ++++++- projects/forms.py | 1 + projects/models.py | 9 +++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/templates/projects/project.html b/app/templates/projects/project.html index 64118a7..74e30e4 100644 --- a/app/templates/projects/project.html +++ b/app/templates/projects/project.html @@ -13,7 +13,12 @@

{{ project }}

{% translate 'catalogs'|capfirst %}

diff --git a/app/templates/projects/projects.html b/app/templates/projects/projects.html index 224f3c6..32c19fc 100644 --- a/app/templates/projects/projects.html +++ b/app/templates/projects/projects.html @@ -14,7 +14,12 @@

{% translate 'Your projects' %}

{% if projects %} {% else %} diff --git a/projects/forms.py b/projects/forms.py index 7104f32..474dcc3 100644 --- a/projects/forms.py +++ b/projects/forms.py @@ -139,6 +139,7 @@ def update(self, catalog, *, request): catalog.pofile = str(catalog.po) catalog.save() + catalog.project.save() else: messages.info(request, _("No changes detected.")) diff --git a/projects/models.py b/projects/models.py index 5db38b3..6e0fa34 100644 --- a/projects/models.py +++ b/projects/models.py @@ -5,6 +5,7 @@ from django.core import validators from django.db import models from django.urls import reverse +from django.utils.timesince import timesince from django.utils.translation import gettext_lazy as _ @@ -77,6 +78,10 @@ def clean(self): def get_api_url(self): return f"/api/pofile/{self.slug}/" + @property + def pretty_timesince(self): + return timesince(self.updated_at, depth=1) + class CatalogQuerySet(models.QuerySet): def for_user(self, user): @@ -129,3 +134,7 @@ def get_absolute_url(self): @cached_property def po(self): return polib.pofile(self.pofile, wrapwidth=0) + + @property + def pretty_timesince(self): + return timesince(self.updated_at, depth=1)