本文整理汇总了Python中models.Room.put方法的典型用法代码示例。如果您正苦于以下问题:Python Room.put方法的具体用法?Python Room.put怎么用?Python Room.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Room
的用法示例。
在下文中一共展示了Room.put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Room [as 别名]
# 或者: from models.Room import put [as 别名]
def get(self):
user = users.get_current_user()
#Redirect the user if they aren't logged in.
if not user:
self.redirect(users.create_login_url(self.request.uri))
return
#Setup tokbox tokens.
tokbox_session_id = opentok_sdk.create_session().session_id
tokbox_token = opentok_sdk.generate_token(tokbox_session_id)
sub_tokbox_token = opentok_sdk.generate_token(tokbox_session_id, OpenTokSDK.RoleConstants.SUBSCRIBER)
#Create the room.
room_key = user.user_id()
room = Room(key_name = room_key,
current_user = user,
session_id = tokbox_session_id,
pub_token = tokbox_token,
sub_token = sub_tokbox_token
)
room.put()
#Display the template.
token = channel.create_channel(room_key)
template_values = {'token': token,
'tokbox_api_key': tokbox_api_key,
'tokbox_session_id': tokbox_session_id,
'tokbox_token': tokbox_token,
'room_key': room_key,
'initial_message': RoomUpdater(room).get_room_message_for_room(),
}
template = jinja_environment.get_template('nav-pub-with-playback.html')
self.response.out.write(template.render(template_values))
示例2: post
# 需要导入模块: from models import Room [as 别名]
# 或者: from models.Room import put [as 别名]
def post(self):
"""Used by the host to create the room."""
user = users.get_current_user()
if not user:
#Handle the user not being logged in. TODO
return
#Setup tokbox tokens.
tokbox_session_id = opentok_sdk.create_session().session_id
tokbox_token = opentok_sdk.generate_token(tokbox_session_id)
sub_tokbox_token = opentok_sdk.generate_token(tokbox_session_id, OpenTokSDK.RoleConstants.SUBSCRIBER)
#Create the room.
room_key = user.user_id()
room = Room(key_name = room_key,
current_user = user,
session_id = tokbox_session_id,
pub_token = tokbox_token,
sub_token = sub_tokbox_token
)
room.put()
#Create the channel token.
token = channel.create_channel(room_key)
#Respond with room information.
room_data = {'token': token,
'tokbox_api_key': tokbox_api_key,
'tokbox_session_id': tokbox_session_id,
'tokbox_token': tokbox_token,
'room_key': room_key,
'initial_message': RoomUpdater(room).get_room_message_for_room(),
}
self.response.out.write(json.dumps(room_data))
示例3: post
# 需要导入模块: from models import Room [as 别名]
# 或者: from models.Room import put [as 别名]
def post(self):
room = Room()
room.roomNumber = self.request.get('room_number')
room.size = float(self.request.get('room_size'))
room.rentSingle = float(self.request.get('room_rent_single'))
room.rentDouble = float(self.request.get('room_rent_double'))
#room.availability = self.request.get('room_availability')
room.put()
room_url = '/rooms'
self.redirect(room_url)
示例4: post
# 需要导入模块: from models import Room [as 别名]
# 或者: from models.Room import put [as 别名]
def post(self):
user = users.get_current_user()
if user is None:
login_url = users.create_login_url('/home')
template_data = {}
template_data['login_url'] = login_url
template = JINJA_ENVIRONMENT.get_template('login.html')
self.response.write(template.render(template_data))
return
residence = Residence.get_residence_by_user(user)
category = self.request.get('category')
name = self.request.get('name')
price = self.request.get('price')
room_name = self.request.get("room")
if name.strip() == '' or category.strip() == '':
if room_name == "miscellaneous":
self.redirect("home")
else:
self.redirect("/room-tour?room=" + urllib.quote(room_name))
return
price = float(price)
inventory = Inventory.get_inventory_by_user(user)
item = Item(category=category, name=name, price=price, parent=inventory.key)
item.put()
residence = Residence.get_residence_by_user(user)
room = Room.query(ancestor=residence.key).filter(Room.name==room_name).get()
if room is None:
room = Room(name=room_name, parent=residence.key)
room.put()
relation = ItemRoomRelation(item=item.key, room=room.key, parent=inventory.key)
relation.put()
if room_name == "miscellaneous":
self.redirect("/home")
return
self.redirect("/room-tour?room=" + urllib.quote(room_name))
示例5: post
# 需要导入模块: from models import Room [as 别名]
# 或者: from models.Room import put [as 别名]
def post(self):
user = tusers.get_current_user()
#Get the requested tournament
tid = self.request.get('t')
t_key = ndb.Key('Tournament', int(tid))
t = t_key.get()
if (user and user.key in t.owner):
#Create a new Room object whose parent is the tournament
room = Room(parent=t_key)
room.name = self.request.get('room_name')
room.active = True
room.put()
#Return the new room
template_values = {
'room' : room,
}
template = JINJA_ENVIRONMENT.get_template('view/json/room.json')
self.response.write(template.render(template_values))
else:
self.redirect(tusers.create_login_url(self.request.uri))
示例6: get
# 需要导入模块: from models import Room [as 别名]
# 或者: from models.Room import put [as 别名]
def get(self):
user = users.get_current_user()
if user is None:
login_url = users.create_login_url('/welcome')
self.response.write('<html><body>{}</body></html>'.format('<a href="' + login_url + '">Sign in</a>'))
return
name = self.request.get("room")
if name is '':
self.response.write("no room specified")
ResidenceTourHandler
residence = Residence.get_residence_by_user(user)
room = Room.query(ancestor=residence.key).filter(Room.name==name).get()
if room is None:
room = Room(name=name, parent=residence.key)
room.put()
other_rooms = Room.query(Room.name==name).fetch()
relations = []
for other_room in other_rooms:
relations += ItemRoomRelation.query(ItemRoomRelation.room==other_room.key).fetch()
item_count = {}
for relation in relations:
category = relation.item.get().category
if category in item_count:
item_count[category] += 1
continue
item_count[category] = 1
logging.error(item_count)
inventory = Inventory.get_inventory_by_user(user)
item_count_final = {}
for item in item_count:
my_count = Item.query(ancestor=inventory.key).filter(Item.category==item).count()
if my_count == 0:
item_count_final[str(item)] = ("", item_count[item] / max(len(other_rooms), 1))
else:
up_count = str(my_count + 1)
my_tail = ""
if up_count[-1:] in ["0", "4", "5", "6", "7", "8", "9"]:
my_tail = "th"
elif up_count[-1:] in ["2"]:
my_tail = "nd"
elif up_count[-1:] in ["1"]:
my_tail = "st"
elif up_count[-1:] in ["3"]:
my_tail = "rd"
logging.error( "(" + up_count + my_tail + ")")
item_count_final[str(item)] = ("(" + up_count + my_tail + ")", item_count[item] / max(len(other_rooms), 1) - 2 * my_count)
item_count_final = sorted(item_count_final.items(), key=lambda x: x[1][1], reverse=True)
logging.error(item_count_final)
template = JINJA_ENVIRONMENT.get_template('tourItemPage.html')
template_data = {}
template_data['items'] = item_count_final
template_data['room'] = room.name
self.response.write(template.render(template_data))