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


Python Order.create_order方法代码示例

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


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

示例1: add_order

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import create_order [as 别名]
def add_order():
    
    deliveryid = request.json['delivery_id']
    #userID = session['userID']
    userID = session['id']
    
    orderID = Order.create_order(deliveryid, userID)
    
    return json.dumps(Order.get_order_by_id(orderID).serializable())
开发者ID:hungr-dev,项目名称:dev,代码行数:11,代码来源:main.py

示例2: my_cards

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import create_order [as 别名]
def my_cards(request, cards_hash):

    order = request.GET.get('order', False)
    order = '?' if order != 'art' else '-art_number'

    author = False
    author_id = False


    my_cards_hash = cards_hash

    try:
        short_url = ShortLinkCardsUrl.objects.get(url_short=cards_hash)
        my_cards_attrs = sorted(f7(short_url.url_part.split(',')))
        attrs_str = ','.join(str(x) for x in my_cards_attrs)
        my_cards_count = len(my_cards_attrs)

    except:
        my_cards_attrs = {}
        short_url = ''
        attrs_str = ''
        my_cards_count = 0
        count, price = 0, 0





    my_cards_count_array = request.session.get('my_cards_count_array', {})

    my_cards_attrs = request.session.get('my_cards_attrs', {})
    count, price = get_mycards_price(my_cards_attrs, my_cards_count_array)


    if request.method == 'POST':
        form = OrderForm(request.POST)
        if form.is_valid():

            order = Order(email=form.cleaned_data['email'])
            order.save()
            order.create_order(request)


            cards = Postcard.objects
            cards = cards.filter(art_number__in=[int(x) for x in attrs_str.split(',')]).all()
            context = {
                'order_id':order.id,
                'date':date.today(),
                'email':form.cleaned_data['email'],
                'price':price,
                'cards': cards,
            }
            send_templated_mail(
                'order',
                '[email protected]',
                [form.cleaned_data['email']],
                context,
                bcc=['[email protected]'],
            )

            to_redirect = redirect('my_cards', cards_hash=cards_hash)
            to_redirect['Location'] += '?ok={0}'.format(order.id)
            return to_redirect
    else:
        form = OrderForm()

    return render(
        request,
        'front/my_cards.html',
        {
            'action':'my_cards',
            'art_numbers': short_url.url_part if short_url else '' ,
            'mode': 'my_cards',
            'order':order,
            'author_id': author_id,
            'author': author,
            'my_cards_count': my_cards_count,
            'my_cards_hash': my_cards_hash,
            'my_cards_attrs':simplejson.dumps(attrs_str),
            'my_cards_attrs_str': attrs_str if len(my_cards_attrs) else '0',
            'my_cards_count_array': simplejson.dumps(my_cards_count_array),
            'count': count,
            'price': price,
            'form': form,
            'ok_id': request.GET.get('ok'),
        }
    )
开发者ID:Ravall,项目名称:quqs.ru,代码行数:89,代码来源:views.py


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