本文整理汇总了Python中models.Order.city方法的典型用法代码示例。如果您正苦于以下问题:Python Order.city方法的具体用法?Python Order.city怎么用?Python Order.city使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Order
的用法示例。
在下文中一共展示了Order.city方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: complete_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import city [as 别名]
def complete_order(request):
request.session.set_expiry(0)
cart = request.session["cart"]
order = Order()
order.first_name = request.POST["first_name"]
order.last_name = request.POST["last_name"]
order.address = request.POST["address"]
order.city = request.POST["city"]
order.payment_method = request.POST["payment"]
order.payment_data = request.POST["payment_data"]
order.items = gen_items_list(cart)
request.session["cart"] = []
return render(request, "mystore/complete_order.html", None)
示例2: completeOrder
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import city [as 别名]
def completeOrder(request):
request.session.set_expiry(0)
cart = request.session['cart']
order = Order()
order.first_name = request.POST['first_name']
order.last_name = request.POST['last_name']
order.address = request.POST['address']
order.city = request.POST['city']
order.payment_method = request.POST['payment']
order.payment_data = request.POST['payment_data']
order.items = genItemsList(cart)
request.session['cart'] = []
return render(request, "complete_order.html", None)
示例3: completeOrder
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import city [as 别名]
def completeOrder(request):
cart = request.session['cart']
request.session.set_expiry(0)
ctx = {'cart':cart, 'cart_size':len(cart), 'cart_items':cartItems(cart), 'total_price': priceCart(cart)}
order = Order()
order.items = genItemsList(cart)
order.first_name = request.POST['first_name']
order.last_name = request.POST['last_name']
order.address = request.POST['address']
order.city = request.POST['city']
order.payment_data = request.POST['payment_data']
order.fulfilled = False
order.payment_method = request.POST['payment']
order.save()
request.session['cart'] = []
return render(request, "complete_order.html", ctx)
示例4: completeOrder
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import city [as 别名]
def completeOrder(request):
cart = request.session.get('cart', [])
total_price = request.session.get('total_price', 0.0)
cart_items = cartItems(cart)
items_str = ','.join(map(lambda i: i.name, cart_items))
order = Order()
order.total_price = total_price
order.first_name = request.POST['first_name']
order.last_name = request.POST['last_name']
order.address1 = request.POST['address1']
order.address2 = request.POST['address2']
order.city = request.POST['city']
order.postcode = request.POST['postcode']
order.payment_type = request.POST['payment_type']
order.payment_data = request.POST['payment_data']
order.items = items_str
order.fulfilled = False
order.save()
request.session['cart'] = []
return render(request, 'complete_order.html', {'cart_size' : len(request.session['cart'])})
示例5: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import city [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)
示例6: choose_recipient
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import city [as 别名]
def choose_recipient(request, origami_id, order_id=None):
'''This returns a form where the user picks a recipient
and provides shipping information.'''
origami = Origami.objects.get(id=origami_id)
amazonOrderReferenceId = None
if request.GET.has_key("session"): amazonOrderReferenceId = str(request.GET["session"])
# if the user backtracked and already has an order_id...
if order_id != None:
order = Order.objects.get(id=order_id)
amazonOrderReferenceId = order.amazonOrderReferenceId
# if the user went back and chose a different origami, update the origami_id
if order.origami_id != origami_id:
order.origami_id = origami_id
order.save()
# if the user fills out the form and clicks "save and continue"
if request.method == "POST":
form = RecipientShippingForm(request.POST) # A form bound to the POST data
if form.is_valid():
recipient_name = form.cleaned_data['recipient_name']
sender_name = form.cleaned_data['sender_name']
message = form.cleaned_data['message']
ship_to_name = ""
ship_to_address = ""
city = ""
state = ""
zip_code = ""
# If the user is submitting the form for the first time, add the data to the db
if order_id == None:
order = Order(amazonOrderReferenceId=amazonOrderReferenceId, origami_id=origami_id, order_status='pre-payment', email_code=gen_email_code(),
recipient_name=recipient_name, sender_name=sender_name, message=message, ship_to_name=ship_to_name,
ship_to_address=ship_to_address, city=city, state=state, zip_code=zip_code)
order.save()
# otherwise update the data in the db
else:
order.recipient_name = recipient_name
order.sender_name = sender_name
order.message = message
order.save()
params = {}
params["OrderReferenceAttributes.OrderTotal.Amount"] = str(origami.price)
params["OrderReferenceAttributes.OrderTotal.CurrencyCode"] = "USD"
params["OrderReferenceAttributes.SellerNote"] = message
params["OrderReferenceAttributes.SellerOrderAttributes.SellerOrderId"] = str(order.id)
data = dict(Action='SetOrderReferenceDetails',
SellerId=MWS_SELLER_ID,
AmazonOrderReferenceId=str(amazonOrderReferenceId))
data.update(params)
mwsResponse = mws.make_request(data)
pp = pprint.PrettyPrinter(depth=6)
pp.pprint(mwsResponse.parsed)
order.city = mwsResponse.parsed.OrderReferenceDetails.Destination.PhysicalDestination.City
order.state = mwsResponse.parsed.OrderReferenceDetails.Destination.PhysicalDestination.StateOrRegion
order.zip_code = mwsResponse.parsed.OrderReferenceDetails.Destination.PhysicalDestination.PostalCode
order.save()
# After submitting the form, send user to the payments page
return HttpResponseRedirect('/payment.html/%s/%s' % (origami_id, order.id))
# For a GET request where the user already has an order id, pre-populate the form with his previously filled-in values
elif order_id != None:
order = Order.objects.get(id=order_id)
data = {'recipient_name': order.recipient_name,
'sender_name': order.sender_name,
'message': order.message,
'ship_to_name': order.ship_to_name,
'ship_to_address': order.ship_to_address,
'city': order.city,
'state': order.state,
'zip_code': order.zip_code}
form = RecipientShippingForm(data) #A sort of bounded form - if user wants to edit!
# User is visiting the page for the first time - show him the empty form
else:
form = RecipientShippingForm() # An unbound form
return render_to_response('choose_recipient.html', {'form':form, 'origami':origami, 'order_id':order_id, 'origami_id':origami_id, 'amazonOrderReferenceId': amazonOrderReferenceId},
context_instance=RequestContext(request))
示例7: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import city [as 别名]
def create_order(request):
args = {
'form': OrderForm(),
'delivery_mass': DeliveryType.objects.all(),
'user': request.user,
'user_active': request.user.is_authenticated(),
'cart_sum': get_sum(request),
}
args.update(csrf(request))
is_valid = True
if request.user.is_authenticated():
ord = Order()
ord.first_name = request.user.first_name
ord.last_name = request.user.last_name
ord.email = request.user.email
ord.phone = request.user.phone
ord.city = request.user.city
ord.address = request.user.address
args['form'] = OrderForm(instance=ord)
if request.POST:
if request.POST.get('first_name', "") == "":
args['user_inform_error'] = True
args['first_name_error'] = "error_field"
is_valid = False
if request.POST.get('last_name', "") == "":
args['user_inform_error'] = True
args['last_name_error'] = "error_field"
is_valid = False
if request.POST.get('email', "") == "":
args['user_inform_error'] = True
args['email_error'] = "error_field"
is_valid = False
if request.POST.get('phone', "") == "":
args['user_inform_error'] = True
args['phone_error'] = "error_field"
is_valid = False
if request.POST.get('city', "") == "":
args['address_inform_error'] = True
args['city_error'] = "error_field"
is_valid = False
if request.POST.get('address', "") == "":
args['address_inform_error'] = True
args['address_error'] = "error_field"
is_valid = False
if request.POST.get('delivery', "") == "":
args['delivery_error'] = "выберите тип доставки"
args['delivery_error'] = "error_field"
is_valid = False
if 'register' in request.POST:
try:
email = request.POST.get('email', "")
User.objects.get(email=email)
args['register_error'] = "Пользователь с таким email уже разегистрирован"
is_valid = False
except User.DoesNotExist:
pass
form = OrderForm(request.POST)
if is_valid and form.is_valid():
order = form.save(commit=False)
delivery = DeliveryType.objects.get(id=request.POST['delivery'])
order.delivery = delivery.title
order.delivery_price = delivery.price
order.status = 0
print(get_sum(request))
order.sum = get_sum(request)
if request.user.is_authenticated():
order.user = request.user
order.save()
cart = get_cart(request)
if cart:
for pr in CartProduct.objects.filter(cart=cart):
if pr.product.sale_status:
pr.price_order = pr.product.price_sale
else:
pr.price_order = pr.product.price
pr.save()
order.products.add(pr)
else:
args['cart_error'] = "в вашей корзине ничего нет"
order.save()
if 'register' in request.POST:
new_user = User()
new_user.first_name = request.POST.get('first_name', "")
new_user.last_name = request.POST.get('last_name', "")
new_user.email = request.POST.get('email', "")
new_user.phone = request.POST.get('phone', "")
new_user.city = request.POST.get('city', "")
new_user.address = request.POST.get('address', "")
new_user.username = translit(new_user.first_name) + "_" + random_str(6)
password = random_str(7)
new_user.set_password(password)
new_user.save()
# отправка уведомления
#.........这里部分代码省略.........