示例#1
0
 def retrieve(self, request, pk=None):
     try:
         bulletin = Dynamo.get_bulletin_by_reference(pk.replace("%#A", ":"))
         comment_list = Dynamo.get_comments(bulletin)
         serializer = CommentSerializer(comment_list, many=True)
     except Exception as e:
         print(e)
         return Response({"Status": "Fail", "Received": request.data})
     return Response({"Status": "Success", "Response": serializer.data})
示例#2
0
def viewBulletin(request):
    if request.user.is_authenticated():
        bulletin = Dynamo.get_bulletin_by_reference(
            request.POST['bulletinSender'] + ':' + request.POST['bulletinTimestamp']
        )

        comments = Dynamo.get_comments(bulletin)
        # for comment in comments:
        #     comment["timestamp"] = time.strftime("%a, %d %b %Y %H:%M", time.localtime(comment["timestamp"]))
        return render(request, 'bulletin.html', {'bulletin': bulletin, 'comment_list': comments})
    return redirect("../")
示例#3
0
def sendComment(request):
    try:
        bulletin_reference = request.POST['bulletinSender'] + ':' + request.POST['bulletinTimestamp']
        bulletin = Dynamo.get_bulletin_by_reference(bulletin_reference)

        comment = {
            'sender': 'test',
            'content': str(request.POST['message']),
            'bulletin_reference': bulletin_reference,
            'timestamp': int(time.time())
        }

        Dynamo.initialize().send_comment(comment)
        comments = Dynamo.get_comments(bulletin)


        # for comment in comments:
        #     comment["timestamp"] = time.strftime("%a, %d %b %Y %H:%M", time.localtime(comment["timestamp"]))
        return render(request, 'bulletin.html', {'bulletin': bulletin, 'comment_list':comments})
    except Exception as e:
        print("\tERROR\tFailed to send bulletin comment: " + str(e))
        return redirect(error_comment)