本文整理匯總了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