def check_answer(req): if req.method=='POST' and req.COOKIES.has_key('userid'): jsonReq = simplejson.loads(req.body) title = jsonReq['title'] id = jsonReq['id'] isTitle = Exercise.objects.filter(id = title['id'],answer = title['answer']) CDao = collectionDao({'userid':req.COOKIES['userid']}) if isTitle: update_rightTime_byReq({'id':id}) rsp = CDao.select_a_collection_byUs(jsonReq['num']-1) return HttpResponse(json.dumps(rsp), content_type="application/json") else: update_wrongTime_byReq({'id':id}) return HttpResponse(json.dumps({'tips':get_tips_byId(title['id']),'wrongTime':select_collection_byReq({'id':id}).wrongtime}), content_type="application/json") return HttpResponse(json.dumps({'tips':'访问错误,请重新登录'}), content_type="application/json")
def delete_collection(req,p1): if select_collection_byReq({'id':p1}).righttime > 0: col = get_object_or_404(Collection,id=p1) col.delete() return HttpResponse() return HttpResponse(json.dumps({'tips':'唯有正确次数>0才能删除'}),content_type="application/json")