Exemplo n.º 1
0
def message(request):
    message = dict()
    message['recipient'] = request.POST['messageRecipient']
    message['timestamp'] = int(request.POST['messageTimestamp'])

    message = Dynamo.get_message(message)
    return render(request, 'message.html', {"msg": message})
Exemplo n.º 2
0
    def mark_read(self, request):
        try:
            # To Pass Serializer
            request.data["sender"] = "a"
            request.data["content"] = "a"
            request.data["read"] = "False"
            request.data["urgency"] = "1"

            serializer = MessageSerializer(data=request.data)
            serializer.is_valid()

            update_msg = Dynamo.get_message(serializer.validated_data)
            update_msg.read = True

            response = Dynamo.update_message(update_msg)

        except Exception as e:
            print(e)
            return Response(
                {
                    "Status": "Fail",
                    "MessageRef": {"recipient": request.data["recipient"], "timestamp": request.data["timestamp"]},
                }
            )
        return Response(
            {
                "Status": "Success",
                "MessageRef": {"recipient": request.data["recipient"], "timestamp": request.data["timestamp"]},
            }
        )