本文整理汇总了Python中app.models.Event.rooms方法的典型用法代码示例。如果您正苦于以下问题:Python Event.rooms方法的具体用法?Python Event.rooms怎么用?Python Event.rooms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.Event
的用法示例。
在下文中一共展示了Event.rooms方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Room
# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import rooms [as 别名]
for room_info in room_infos:
room = Room()
room.room_name = room_info[0]
room.room_sq_ft = room_info[1]
room.room_capacity = room_info[2]
if room_info[3]:
room.room_group = db.session.query(RoomGroup).\
filter(RoomGroup.room_group_name == room_info[3]).first()
db.session.add(room)
db.session.commit()
# Assign a random room to each event.
events = Event.query.all()
rooms = Room.query.all()
for event in events:
# Randomly select a room for this event
random_rooms = random.sample(rooms, random.randrange(1,2))
# If the room has a room group, randomly select
# 0 to 1 more rooms from that group for this event.
if random_rooms[0].room_group:
another_room = random.choice(rooms)
if random_rooms[0] != another_room and random_rooms[0].room_group == another_room.room_group:
random_rooms.append(another_room)
event.rooms = random_rooms
# Commit the test data to the database.
db.session.commit()