当前位置: 首页>>代码示例>>Python>>正文


Python Order._data方法代码示例

本文整理汇总了Python中models.Order._data方法的典型用法代码示例。如果您正苦于以下问题:Python Order._data方法的具体用法?Python Order._data怎么用?Python Order._data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Order的用法示例。


在下文中一共展示了Order._data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import _data [as 别名]

#.........这里部分代码省略.........
    # ----------------------------------------------
    elif action == '203':
        if not id:
            otype = ORDER_STANDARD
            order = Order.query.filter_by(user=user, module=module, otype=otype).first()
        else:
            order = get_order(id, None)
            custom_code = order and order.code
            otype = -1
    elif action == '204':
        otype = ORDER_CUSTOM
        order = get_order(id, code, user=user, module=module)
    elif action == '205':
        otype = ORDER_CUSTOM
        #order = get_order(None, code, user=user, module=module)
    elif action == '207':
        otype = ORDER_DONE
    else:
        otype = -1

    if IsDebug:
        print '>>> Order: %s %s %s' % (order, str(code), str(id))

    if otype in valid_order_types:
        price_columns = get_columns(dom, attrs, model_price_columns)

        if not attrs.get('title'):
            attrs['title'] = gettext(valid_order_names[otype])

        if not order:
            order = Order(user, module, otype, get_columns(dom, attrs, model_order_columns))

            #if otype == ORDER_DONE:
            #    order.code = Order.generate_custom_code(user, module, otype=ORDER_DONE)
            #elif otype == ORDER_CUSTOM:
            #    order.code = get_item(dom, attrs, 'custom_code') or \
            #        Order.generate_custom_code(user, module, otype=otype)

            IsAddOrder = True
        else:
            if action in ('203','207'):
                pass
            elif action == '204':
                if order.option_update:
                    order.data = order._data(get_item(dom, attrs, 'data'))
                    IsUpdateOrder = True
            elif action == '205':
                order.set_attrs(get_columns(dom, attrs, model_order_columns))
                IsUpdateOrder = True

        current_price = Order.generate_current_price(int(float(price_columns['total']) * 100), \
            price_columns['currency'])

        if IsAddOrder:
            last_price = ''
            order.current_price = current_price
        else:
            last_price = order.current_price
            if order.otype in (ORDER_STANDARD, ORDER_CUSTOM,):
                order.current_price = current_price
                order.rating = order.current_price < last_price and RATING_DOWN or \
                               order.current_price > last_price and RATING_UP or \
                               RATING_EQUAL
            else:
                order.rating = current_price > last_price and RATING_DOWN or \
                               current_price < last_price and RATING_UP or \
                               RATING_EQUAL

        if IsDebug:
            print '>>> Current price: %s %s %s' % (last_price, order.current_price, order.rating)

        if order and IsAddOrder:
            _add(order)

        if order and (IsAddOrder or (order.option_cost and last_price != current_price)):
            _add(Price(order, price_columns))

    # ----------
    # Save to DB
    # ----------
    _commit(IsUpdateOrder and True or False)

    # ---------------------
    # Get data for response
    # ---------------------
    data = {}
    next_custom_code = Order.generate_custom_code(user, module)

    if action in ('203','204','205',):
        if order:
            data['title'] = order.title
            data['custom_code'] = order.code or custom_code
            data['next_custom_code'] = order.option_update and order.code or next_custom_code
            data['option_update'] = order.option_update
            data['option_cost'] = order.option_cost
        else:
            data['next_custom_code'] = next_custom_code
            data['custom_code'] = custom_code

    return data
开发者ID:ichar,项目名称:player.python,代码行数:104,代码来源:dbase.py


注:本文中的models.Order._data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。