Exemplo n.º 1
0
 def retrieve_private_conversation(self, request, *args, **kwargs):
     user2 = self.get_object()
     try:
         conversation = Conversation.objects.get_or_create_for_two_users(request.user, user2)
     except Exception:
         return Response(status=status.HTTP_404_NOT_FOUND, data={})
     serializer = ConversationSerializer(conversation, data={}, context={'request': request})
     serializer.is_valid(raise_exception=True)
     return Response(serializer.data)
Exemplo n.º 2
0
 def retrieve_conversation(self, request, *args, **kwargs):
     target = self.get_object()
     conversation = Conversation.objects. \
         prefetch_related('conversationparticipant_set'). \
         select_related('target_type'). \
         get_or_create_for_target(target)
     serializer = ConversationSerializer(
         conversation, data={}, context=self.get_serializer_context())
     serializer.is_valid(raise_exception=True)
     return Response(serializer.data)
Exemplo n.º 3
0
 def retrieve_conversation(self, request, *args, **kwargs):
     target = self.get_object()
     conversation = Conversation.objects.get_or_create_for_target(target)
     serializer = ConversationSerializer(conversation, data={}, context={'request': request})
     serializer.is_valid(raise_exception=True)
     return Response(serializer.data)