Exemplo n.º 1
0
def message_view(request):
	# pdb.set_trace()
	if request.method == 'POST':
		newMessage = Message(message = request.POST['message'],
			posted_by = User.objects.get(username=request.user.username),
			questionID = Question.objects.get(pk=1))
		newMessage.save()
	messages = Message.objects.all()
	return render_to_response('messages.html',{'messages':messages})
Exemplo n.º 2
0
def ajaxsubmit(request):
    pdb.set_trace()
    new_msg = Message(message = request.POST['message'],
                      posted_by = User.objects.get(username=request.user.username),
                      gameID = Game.objects.get(pk=1))
    new_msg.save()
    cmd = [{'cmd': 'inlinepush',
            'params': {
                'password': settings.APE_PASSWORD,
                'raw': 'postmsg',
                'channel': 'messages',
                'data': {
                    'msg': new_msg.message,
                    'posted_by': 'RANDOM_USER',
                    'timestamp': 'THIS TIME'
                }
            }
    }]
    url = settings.APE_SERVER + urllib2.quote(json.dumps(cmd))
    response = urllib2.urlopen(url)
    pdb.set_trace()
    # Updating the message is handled by APE, so just return an empty 200
    return HttpResponse()
Exemplo n.º 3
0
def receiveMessage(request):
	message = Message(message = request.POST['message'],
    	posted_by = request.user,
    	timestamp = datetime.datetime.now())
	message.save()
	return HttpResponse()