我想建立一个评估系统 这是我的课
class Goal(db.Expando):
GID = db.IntegerProperty(required=True)
description = db.TextProperty(required=True)
time = db.FloatProperty(required=True)
weight = db.IntegerProperty(required=True)
Emp = db.UserProperty(auto_current_user=True)
Status = db.BooleanProperty(default=False)
以下内容由员工提供
^{pr2}$现在,经理检查目标并批准与否。。如果批准,则状态将在数据存储中存储为true,否则为false
idsta = simplejson.loads(self.request.body)
try:
g = db.Query(Goal).filter("GID =", int(idsta[0])).get()
if g:
if idsta[1]:
g.Status=True
try:
del g.Comments
except:
None
else:
g.Status=False
g.Comments=idsta[2]
db.put(g)
self.response.out.write(simplejson.dumps("Submitted"))
except:
self.response.out.write(simplejson.dumps("Error"))
现在,这就是我卡住的地方…“过滤器('status=',True)”。。这将返回所有状态为true的实体。。经批准的方式。。我想要那些被批准的,还没有被员工评估的实体。。在
def get(self):
t = []
for g in Goal.all().filter("Status = ",True):
t.append([g.GID, g.description, g.time, g.weight, g.Emp])
self.response.out.write(simplejson.dumps(t))
def post(self):
idasm = simplejson.loads(self.request.body)
try:
g = db.Query(Goal).filter("GID =", int(idasm[0])).get()
if g:
g.AsmEmp=idasm[1]
db.put(g)
self.response.out.write(simplejson.dumps("Submitted"))
except:
self.response.out.write(simplejson.dumps("Error"))
我该怎么做?我知道,如果我添加另一个过滤器,比如“filter('asemp=',not None)”,这只会返回那些具有asemp属性的实体,反之亦然。在
记录并不缺少数据存储中的属性,它只是设置为“无”。您可以使用
Goal.all().filter('status =', True).filter('AsmEmp =', None)
查询这些记录。在关于代码的一些附带建议:
.fetch(n)
获取所需的结果数。在编辑:我没注意到你在用Expando——在这种情况下,@Daniel的答案是正确的。不过,在这里使用Expando似乎没有什么好的理由。将属性添加到模型(并更新现有实体)将是这里最简单的解决方案。在
你显然不能这么做。正如documentation所述:
相反,请为
is_assessed
创建一个默认为False的属性,并对其进行查询。在您不能简单地为“当员工评估=数据库用户... 只在评估时填写?在
相关问题 更多 >
编程相关推荐