From 21f003d040b544ece7078b443ee430ad51d547cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Valenta?= <git@imaniti.org>
Date: Mon, 22 Jan 2024 19:52:53 +0100
Subject: [PATCH] =?UTF-8?q?fix=20timestamp=20=E2=86=92=20date?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 district/models.py    |  2 +-
 shared/models/main.py | 10 +++++-----
 uniweb/models.py      |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/district/models.py b/district/models.py
index 1d638815..3ad5df29 100644
--- a/district/models.py
+++ b/district/models.py
@@ -495,7 +495,7 @@ class DistrictArticlePage(
                 self.get_siblings(inclusive=False)
                 .live()  # TODO? filtrovat na stejné tagy? nebo sdílené články?
                 .specific()
-                .order_by("-districtarticlepage__date")[:3]
+                .order_by("-districtarticlepage__timestamp")[:3]
             )
             if self.shared_from is None
             else []
diff --git a/shared/models/main.py b/shared/models/main.py
index 78f2c2ca..891d84d8 100644
--- a/shared/models/main.py
+++ b/shared/models/main.py
@@ -780,15 +780,15 @@ class MainSearchPageMixin(
 
             results = model.objects.filter(filter)
 
-            if hasattr(model, "date"):
-                results = results.order_by("-date")
+            if hasattr(model, "timestamp"):
+                results = results.order_by("-timestamp")
 
             context["results"] += list(results.all()[:15])
 
         context["results"].sort(
-            # Put results without a date first, as they'll be person litsings etc.
-            key=lambda result: result.date
-            if hasattr(result, "date")
+            # Put results without a timestamp first, as they'll be person litsings etc.
+            key=lambda result: result.timestamp
+            if hasattr(result, "timestamp")
             else datetime.date(year=9999, month=1, day=1),
             reverse=True,
         )
diff --git a/uniweb/models.py b/uniweb/models.py
index 0b6217c1..c5705f21 100644
--- a/uniweb/models.py
+++ b/uniweb/models.py
@@ -631,7 +631,7 @@ class UniwebArticlePage(
                 self.get_siblings(inclusive=False)
                 .live()
                 .specific()
-                .order_by("-uniwebarticlepage__date")[:3]
+                .order_by("-uniwebarticlepage__timestamp")[:3]
             )
             if self.shared_from is None
             else []
-- 
GitLab