def predict(req): pid = req.GET.get("pid") mid = req.GET.get("mid") m1 = req.GET.get("m1") m2 = req.GET.get("m2") if not pid or not mid or not m1 or not m2: return render(req, "msg.html", {"msg":"invalid params"}) m1 = string.atoi(m1) m2 = string.atoi(m2) if m1 < 0 or m2 < 0: return render(req, "msg.html", {"msg":"Mark cannot be negative!"}) peer = Peer.objects.get(id=pid) if not peer: return render(req, "msg.html", {"msg":"Invalid peer"}) match = TeamMatch.objects.get(id=mid) if not match: return render(req, "msg.html", {"msg":"Invalid match"}) signed_uid, name = get_signed_uid(req) if signed_uid != "admin" and timezone.now() >= match.begin: return render(req, "msg.html", {"msg":"Game is over or timeout"}) pmatch_list = PeerMatch.objects.filter(peer=peer, match=match) if pmatch_list: pmatch = pmatch_list[0] pmatch.mark_a = m1 pmatch.mark_b = m2 else: pmatch = PeerMatch(peer=peer, match=match, mark_a=m1, mark_b=m2) pmatch.save() return render(req, "msg.html", {"msg":"Update OK"})