def commit():
    video_id = request.json['video_id']
    user = users.current()
    video = videos.find(video_id)
    if not user.anonymous:
        watchtran.commit(user, video)
    user = users.current()
    return jsonify(chances=user.chances)
 def test_commit(self):
     user = users.find(self.test_user_id)
     video = videos.find(self.video_id)
     video._duration = 0
     watchtran.begin(user, video)
     result = watchtran.commit(user, video)
     self.assertIsNotNone(result)
 def test_commit_too_early(self):
     user = users.find(self.test_user_id)
     video = videos.find(self.video_id)
     watchtran.begin(user, video)
     result = watchtran.commit(user, video)
     self.assertIsNone(result)
 def test_commit_without_begin(self):
     user = users.find(self.test_user_id)
     video = videos.find(self.video_id)
     result = watchtran.commit(user, video)
     self.assertIsNone(result)