def add_reply(request): if request.method == 'POST': fromUser = request.POST['username1'] toUser = request.POST['username2'] post = request.POST['post'] time = request.POST['time'] rorm = request.POST['rorm'] if (fromUser and toUser and post and time): if(check_user(fromUser) and check_user(toUser)): p1 = Reply(fromuser = fromUser, touser = toUser, text = post, time = time, rorm = rorm) p2 = Post(user = fromUser, text = post, time = time) p2.save() p1.save() return HttpResponse("200") else: return HttpResponse("400") else: return HttpResponse("500") return render_to_response('add_reply.html')
def add_post(request): if request.method =='POST': user = request.POST['username'] text = request.POST['message'] date_time = request.POST['time'] #json = request.POST['post'] #result = simplejson.loads(json) #3user = result['username'] #text = result['message'] #date_time = result['time'] if(user and text and date_time): p1 = Post(user = user, text = text, time = date_time) p1.save() return HttpResponse("200") else: return HttpResponse("400") return render_to_response('add_post.html')