本文整理汇总了Python中models.Order.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Order.get_by_id方法的具体用法?Python Order.get_by_id怎么用?Python Order.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Order
的用法示例。
在下文中一共展示了Order.get_by_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getLogItem
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import get_by_id [as 别名]
def getLogItem(action, request, session):
"""
Get Log item from DB by selected log item's ID.
Arguments:
action - 302|303|304|307
request - form (selected_item)
session - current session
Returns:
exchange_error, exchange_message - exchange error info
id - parsed ID of selected_item
data - XML (Order.data)
"""
form = request.form
print_action(action, 'DBase.GetLogItem')
exchange_message = ''
exchange_error = 0
order = None
id = form.get('selected_item', None)
if IsDebug:
print '>>> Selected LogItem ID: [%s]' % id
if id:
order = Order.get_by_id(id)
else:
exchange_message = '%s: <id>' % gettext('Missing argument')
exchange_error = -10
return (exchange_error, exchange_message, id, order)
示例2: get
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import get_by_id [as 别名]
def get(self, id):
order = Order.get_by_id(id)
if order is None:
self.error(404)
purchases = order.get_purchases()
self.generate('purchase_in_order.html',
{'order':order,
'purchases':purchases})
示例3: getStatictics
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import get_by_id [as 别名]
def getStatictics(action, request, session):
"""
Get Price items from DB by selected log item's ID.
Arguments:
action - 305
request - form (selected_item)
session - current session
Returns:
exchange_error, exchange_message - exchange error info
id - parsed ID of selected_item
data - XML (Order.data)
"""
form = request.form
print_action(action, 'DBase.GetLogStatistics')
exchange_message = ''
exchange_error = 0
response = None
order = None
id = form.get('selected_item', None)
if IsDebug:
print '>>> Selected LogItem ID: [%s]' % id
if id:
order = Order.get_by_id(id)
else:
exchange_message = '%s: <id>' % gettext('Missing argument')
exchange_error = -10
total, order_id, data, query = statistics(DEFAULT_LOG_MODE, order=order)
items = []
headers = get_statistics_headers()
line_in_page = 0
for row in data:
x = dict(zip(headers[0], row))
line_in_page += 1
x['root'] = '%s' % request.script_root
x['num'] = line_in_page
x['cdate'] = cdate(x['reg_date'], fmt=LOCAL_EASY_TIMESTAMP)
for n, column in enumerate(headers[1]):
x['%s_title' % column['id']] = column['title']
items.append([x['id'], [ column.has_key('value') and (column['value'] % x) or x[column['id']]
for n, column in enumerate(headers[1])
if column.get('visible') ]
])
return (exchange_error, exchange_message, id, total, items)
示例4: get_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import get_by_id [as 别名]
def get_order(id=None, code=None, **kw):
order = None
if id:
order = Order.get_by_id(id)
elif code:
user = kw.get('user')
module = kw.get('module')
if user and module:
order = Order.query.filter_by(user=user, module=module, code=code).first()
return order
示例5: post
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import get_by_id [as 别名]
def post(self, order_id):
order = Order.get_by_id(long(order_id))
if order is None:
self.error(404)
return
# TODO: `purchaese' should be the received json object
purchases = order.get_purchases()
balance = UserBalance()
for p in purchases:
balance.pay_for(p.customer, p.item.price)
self.redirect('/u/mine/profile')