本文整理汇总了Python中db.Database.getDayClasses方法的典型用法代码示例。如果您正苦于以下问题:Python Database.getDayClasses方法的具体用法?Python Database.getDayClasses怎么用?Python Database.getDayClasses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Database
的用法示例。
在下文中一共展示了Database.getDayClasses方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GET
# 需要导入模块: from db import Database [as 别名]
# 或者: from db.Database import getDayClasses [as 别名]
def GET(self):
dbase=Database()
user_data = web.input()
if not dbase.verify_user(user_data.userid, user_data.token):
return "Please authenticate when using the API"
classes=dbase.getDayClasses(user_data.userid)
dclass=[]
for cls in classes:
cls.timestamp=cls.timestamp.strftime("%H:%M %m/%d/%Y") # JSON friendly date formats.
cls.timeend=cls.timeend.strftime("%H:%M %m/%d/%Y")
dclass.append({"id":cls.id,"class_name":cls.class_name,"section":cls.section,"timestamp":cls.timestamp,"timeend":cls.timeend,"instructor":cls.instructor,"type":cls.type,"where":cls.where})
web.header("Content-Type","application/json")
return json.dumps(dclass)
示例2: GET
# 需要导入模块: from db import Database [as 别名]
# 或者: from db.Database import getDayClasses [as 别名]
def GET(self):
dbase=Database()
ath=Auth(dbase)
if not ath.checkAuth():
raise web.seeother('/login')
tkn,new=dbase.user_exists(ath.getUserid())
if new == True:
raise web.seeother("/onboard")
user_data = web.input(node="2016012246")
nd1=user_data.node
pt = Paths(dbase)
env = Environment(loader=PackageLoader('html', ''))
template = env.get_template('maptest.html')
classes=dbase.getDayClasses(ath.getUserid())
for cls in classes:
x=classes.index(cls)
if x ==0:
classes[x].lastClassLoc="b-E3"
else:
classes[x].lastClassLoc=classes[x-1].build
classes[x].class_name=classes[x].class_name.split(" - ")[0]
classes[x].build="b-"+cls.where.split(" ")[0]
classes[x].timestamp=classes[x].timestamp.strftime("%I:%M %p")
classes[x].timeend=classes[x].timeend.strftime("%I:%M %p")
if cls.type=="LEC":
classes[x].col="warning"
elif cls.type=="TST":
classes[x].col="danger"
elif cls.type=="TUT":
classes[x].col="info"
elif cls.type=="LAB":
classes[x].col="success"
elif cls.type=="SEM":
classes[x].col="warning"
xs=[]
pth=[]
for el in pt.getPath(nd1,"b-E3"):
node=dbase.getNode(el)
pth.append([node.x,node.y])
xs.append(node)
return template.render(vertices=xs,path=pth,classes=classes,qr_data=ath.getUserid()+":"+ath.getUserToken())