本文整理汇总了Python中models.Room.get_all方法的典型用法代码示例。如果您正苦于以下问题:Python Room.get_all方法的具体用法?Python Room.get_all怎么用?Python Room.get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Room
的用法示例。
在下文中一共展示了Room.get_all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: query_rooms
# 需要导入模块: from models import Room [as 别名]
# 或者: from models.Room import get_all [as 别名]
def query_rooms():
'''returns each room and its availability status'''
response = []
# loop through the rooms
rooms = Room.get_all()
if rooms:
for r in rooms:
# get current day/time stuff
current_day = datetime.datetime.now().strftime('%A').lower()
current_time = datetime.datetime.fromtimestamp(time.time()).strftime('%H:%M')
# get room use times
room_times = Timetable.get_by_room_id(r.room_id)
# determine usage
use_flag = True
for t in room_times:
if t.day == current_day:
if (current_time >= t.start_time) and (current_time <= t.end_time):
use_flag = False
response.append({"room_id": r.room_id, "room_number": r.room_number, "available": use_flag})
else:
response.append({})
return response