for last_followup remove filter stub, fix localization, improve serializer

This commit is contained in:
DavidVadnais
2025-03-21 23:55:28 +00:00
parent 27a94dde34
commit 1e580aa59d
3 changed files with 3 additions and 19 deletions

View File

@ -75,15 +75,7 @@ class DatatablesTicketSerializer(serializers.ModelSerializer):
return obj.kbitem.title if obj.kbitem else ""
def get_last_followup(self, obj):
followup = obj.followup_set.order_by().annotate(
last_followup=Window(
expression=Max("date"),
partition_by=[F("ticket_id"),],
order_by="-date"
)
).values("last_followup").distinct().values_list("last_followup", flat=True)
# If there are no followups for the ticket then the result will be empty
return localtime(followup[0]).strftime('%Y-%m-%d %H:%M:%S') if followup else ""
return obj.last_followup
class FollowUpAttachmentSerializer(serializers.ModelSerializer):