fix in submitGrade

This commit is contained in:
Aran Zaiger 2015-08-03 00:21:02 +03:00
parent 35ecdd1f60
commit 043fb67b5a

View file

@ -304,12 +304,14 @@ def submitGrade(token, taskId, ownerId, grade):
tg = TaskGrade.all().filter("taskId = ", int(taskId)).filter("userId = ", int(ownerId)) tg = TaskGrade.all().filter("taskId = ", int(taskId)).filter("userId = ", int(ownerId))
if tg.count() == 0: if tg.count() == 0:
grade = TaskGrade(taskId=int(taskId), userId=int(ownerId), grade=int(grade)) grade = TaskGrade(taskId=int(taskId), userId=int(ownerId), grade=int(grade))
db.put(grade)
else: else:
for g in tg.run(): for g in tg.run():
g.grade=int(grade) g.grade=int(grade)
g.taskId=int(taskId) g.taskId=int(taskId)
g.userId=int(ownerId) g.userId=int(ownerId)
db.put(grade) db.put(g)
db.save db.save
return Response(response=grade.to_JSON(), return Response(response=grade.to_JSON(),
status=200, status=200,