本文整理汇总了Python中app.models.place.Place.owner方法的典型用法代码示例。如果您正苦于以下问题:Python Place.owner方法的具体用法?Python Place.owner怎么用?Python Place.owner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.place.Place
的用法示例。
在下文中一共展示了Place.owner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_places
# 需要导入模块: from app.models.place import Place [as 别名]
# 或者: from app.models.place.Place import owner [as 别名]
def create_places():
"""
Create a place
Creates a place based on post parameters.
---
tags:
- place
parameters:
- name: name
in: query
type: string
description: name of the amenity to create
- name: city
in: query
type: number
description: id of the city the place is in
- name: owner
in: query
type: number
description: id of the owner of the place
- name: description
in: query
type: string
description: details about the place
- name: number_rooms
in: query
type: number
description: number of bedrooms in place
- name: number_bathrooms
in: query
type: number
description: number of bathrooms in place
- name: max_guest
in: query
type: number
description: max number of guests that can stay at a time
- name: price_by_night
in: query
type: number
description: price (in USD) to stay a night
- name: latitude
in: query
type: float
description: location of the place in latitude
- name: longitude
in: query
type: float
description: location of the place in longitude
responses:
200:
description: Success message
schema:
id: success_message
properties:
status:
type: number
description: status code
default: 200
msg:
type: string
description: Status message
default: 'Success'
400:
description: Error message
schema:
id: error_message
properties:
status:
type: number
description: status code
default: 40000
msg:
type: string
description: Status message
default: 'Missing parameters'
"""
content = request.get_json(force=True)
if not all(param in content.keys() for param in ["name", "city", "owner", "description", "number_rooms", "number_bathrooms", "max_guest", "price_by_night", "latitude", "longitude"]):
#ERROR
return error_msg(400, 40000, "Missing parameters")
try:
place = Place()
place.name = content["name"]
place.city = content["city"]
place.owner = content["owner"]
place.description = content["description"]
place.number_rooms = content["number_rooms"]
place.number_bathrooms = content["number_bathrooms"]
place.max_guest = content["max_guest"]
place.price_by_night = content["price_by_night"]
place.latitude = content["latitude"]
place.longitude = content["longitude"]
place.save()
except Exception as e:
return error_msg(400, 400, "Error")
return error_msg(200, 200, "Success")