本文整理汇总了Python中models.Order.ip_address方法的典型用法代码示例。如果您正苦于以下问题:Python Order.ip_address方法的具体用法?Python Order.ip_address怎么用?Python Order.ip_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Order
的用法示例。
在下文中一共展示了Order.ip_address方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import ip_address [as 别名]
def create_order(request):
""" function that takes a POST request and adds a product instance to the current customer's shopping cart """
print('create_order!!!!')
post_data = request.POST.copy()
cart_items = cart.get_cart_items(request)
order = Order()
username = request.session['username']
custom_user = Customer.objects.get(
user = User.objects.get(
username = request.session['username']))
order.user = custom_user
order.email = post_data.get('email',1)
order.phone = post_data.get('phone',1)
order.ip_address = request.META.get('REMOTE_ADDR')
order.save()
for cart_item in cart_items:
product = OrderItem()
product.order = order
product.product = cart_item.product
product.quantity = cart_item.quantity
product.save()
cart.empty_cart(request)
print_order(order.id)
return order
示例2: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import ip_address [as 别名]
def create_order(request, transaction_id):
order = Order()
checkout_form = CheckoutForm(request.POST, instance = order)
order = checkout_form.save(commit = False)
order.transaction_id = transaction_id
order.ip_address = request.META.get('REMOTE_ADDR')
if request.user.is_authenticated():
order.user = request.user
order.status = Order.SUBMITTED
order.save()
# if the order save succeeded
if order.pk:
cart_items = shoppingcart.get_cart_items(request)
for ci in cart_items:
# create order item for each cart item
oi = OrderItem()
oi.order = order
oi.quantity = ci.quantity
oi.price = ci.price
oi.product = ci.product
oi.save()
# all set, empty card
shoppingcart.empty_cart(request)
# save profile info for future orders
if request.user.is_authenticated():
from accounts import profile
profile.set(request)
# return the new order object
return order
示例3: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import ip_address [as 别名]
def create_order(request,transaction_id):
order = Order()
checkout_form = CheckoutForm(request.POST, instance=order)
order = checkout_form.save(commit=False)
order.transaction_id = transaction_id
order.ip_address = request.META.get('REMOTE_ADDR')
order.user = None
if request.user.is_authenticated():
order.user = request.user
order.status = Order.SUBMITTED
order.save()
if order.pk:
cart_items = cart.get_cart_items(request)
for ci in cart_items:
oi = OrderItem()
oi.order = order
oi.quantity = ci.quantity
oi.price = ci.price
oi.product = ci.product
oi.save()
cart.empty_cart(request)
if request.user.is_authenticated():
from accounts import profile
profile.set(request)
return order
示例4: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import ip_address [as 别名]
def create_order(request, postdata):
order = Order()
# order.user = None
# if request.user.is_authenticated():
# order.user = request.user
# данные с формы
data = {
u"Имя": postdata["first-name"],
u"Фамилия": postdata["last-name"],
u"Email": postdata["email"],
u"Телефон": postdata["phone"],
u"Время звонка": postdata["call-time"],
u"Область": postdata["region"],
u"Город": postdata["city"],
u"Улица": postdata["street"],
u"Дом": postdata["building"],
u"Квартира": postdata["flat"],
u"Способ доставки": postdata["ship-method"],
u"Номер склада (адрес офиса)": postdata["warehouse"],
u"Комментарий к заказу": postdata["comment"],
u"Дополнительная информация": postdata["additional_info"],
}
# добавление данных в модель заказа
order.first_name = data[u"Имя"]
order.last_name = data[u"Фамилия"]
order.email = data[u"Email"]
order.phone = data[u"Телефон"]
order.call_time = data[u"Время звонка"]
order.region = data[u"Область"]
order.city = data[u"Город"]
order.street = data[u"Улица"]
order.building = data[u"Дом"]
order.flat = data[u"Квартира"]
order.ship_method = data[u"Способ доставки"]
order.office = data[u"Номер склада (адрес офиса)"]
order.additional_info = data[u"Дополнительная информация"]
order.comment = data[u"Комментарий к заказу"]
order.ip_address = request.META.get("REMOTE_ADDR")
order = Order(**data)
order.status = order.SUBMITTED
order.save()
# отправка почты менеджеру
send_mail_manager(data, order)
# отправка почты заказчкику
if data[u"Email"] != "":
send_mail_customer(data, order)
# if the order save succeeded
if order.pk:
cart_items = cart.get_cart_items(request)
for ci in cart_items:
# create order item for each cart item
oi = OrderItem()
oi.order = order
oi.quantity = ci.quantity
oi.price = ci.price # now using @property
oi.product = ci.product
oi.save()
# all set, empty cart
cart.empty_cart(request)