Skip to content

Commit 26f65cd

Browse files
committed
fix last_modified_date
1 parent a5bfdde commit 26f65cd

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

core/api/v3/objects/announcement.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from __future__ import annotations
22

33
from django.conf import settings
4-
from django.contrib.admin.models import LogEntry
5-
from django.contrib.contenttypes.models import ContentType
64
from django.template.loader import render_to_string
75
from django.urls import reverse
86
from rest_framework import permissions, serializers
97
from rest_framework.exceptions import ValidationError
8+
from django.utils import timezone
109

1110
from core.api.serializers.custom import (
1211
CommentField,
@@ -153,6 +152,10 @@ class AnnouncementProvider(BaseProvider):
153152
"tags": [(int, ""), (str, "name")],
154153
"organization": int,
155154
"author": int,
155+
"last_modified_date__gt": str,
156+
"last_modified_date__gte": str,
157+
"last_modified_date__lt": str,
158+
"last_modified_date__lte": str,
156159
}
157160
raw_serializers = {
158161
"single": OneSerializer,
@@ -178,12 +181,11 @@ def get_last_modified(view):
178181

179182
@staticmethod
180183
def get_last_modified_queryset():
181-
return (
182-
LogEntry.objects.filter(
183-
content_type=ContentType.objects.get(
184-
app_label="core", model="announcement"
185-
)
186-
)
187-
.latest("action_time")
188-
.action_time
184+
last_modified_date = (
185+
Announcement.objects.all().order_by("-last_modified_date", "id").first()
189186
)
187+
188+
if last_modified_date:
189+
return last_modified_date.last_modified_date
190+
else:
191+
return timezone.now()

0 commit comments

Comments
 (0)