from osinacore.api.utils import * from osichat.models import * from rest_framework.decorators import api_view from .serializers import * from django.shortcuts import get_object_or_404 @api_view(['GET']) def get_chat_rooms(request): chat_rooms = ChatRoom.objects.annotate(last_update=Max('chatmessage__date_sent')).order_by('-last_update', '-date_created') chat_rooms_serializer = ChatRoomSerializer(chat_rooms, many=True) return successRes(chat_rooms_serializer.data)