示例#1
0
文件: main.py 项目: likr/sympo-score
 def put(self, presenter_key):
     presenter_key = ndb.Key(Presenter, int(presenter_key))
     evaluator = checkauth(self.request.headers.get('Authorization'))
     if evaluator is None:
         self.response.set_status(401)
         return
     data = json.loads(self.request.body)
     score = Score.query(Score.evaluator == evaluator.key,
                         Score.presenter == presenter_key).get()
     if score is None:
         score = Score()
         score.evaluator = evaluator.key
         score.presenter = presenter_key
     score.score1 = int(data.get('score1'))
     score.score2 = int(data.get('score2'))
     score.score3 = int(data.get('score3'))
     score.comment = data.get('comment')
     score.put()
     self.response.write(json.dumps(score.to_dict()))