本文整理汇总了Python中models.Order.status方法的典型用法代码示例。如果您正苦于以下问题:Python Order.status方法的具体用法?Python Order.status怎么用?Python Order.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Order
的用法示例。
在下文中一共展示了Order.status方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: truck_page
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import status [as 别名]
def truck_page(truck):
items = session.query(Item).filter(Item.operator_id == truck)
if request.method == "POST":
user = User()
user.firstName = request.form.get("firstName")
user.lastName = request.form.get("lastName")
user.email = request.form.get("email")
session.add(user)
session.commit()
order = Order()
order.operator_id = truck
order.user = user
order.status = "created"
session.add(order)
session.commit()
for item_id in request.form.getlist("item"):
orderitem = OrderItems()
orderitem.order_id = order.id
orderitem.item_id = item_id
item = items.filter(Item.id == item_id).first()
session.add(orderitem)
session.commit()
return render_template("checkout.html", key=stripe_keys["publishable_key"], order=order, user=user)
else:
items = items.all()
items = filter(lambda x: x.count > 0, items)
return render_template("truckPage.html", items=items)
示例2: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import status [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 status [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: addOrder
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import status [as 别名]
def addOrder(request):
c = request.POST
tableData = json.loads( c['tableData']);
today = jDateField();
today = today.to_python(datetime.datetime.now())
order = Order(submitDate=today)
status = OrderItem.ORDER_ITEM_STATUS_CHOICES[0][0]
order.user = request.user
isforall = 'isforall' in request.POST and request.POST['isforall']
if request.user.is_superuser:
order.status = 'A'
if isforall:
status = 'P'
order.user = None
order.save()
#print tableData
for order_item in tableData:
#print order_item[2]
if order_item[3] == '':
category = None
else:
category = Category.objects.filter(pk=order_item[3])[0]
orderitem=OrderItem(order=order,
category=category,
quantity=int(order_item[1]),
description = order_item[4],
status= status #if it's admin and the order belongs to the public ..., if it's admin the order is accepted
)
orderitem.save()
if request.user.is_superuser and isforall:
inform_purchase_agent(subject='سفارش نیازمند خرید است',message=render_to_string('mail/buy_orderitem.html',{'orderitem' : orderitem}))
c = {'rlink' : '../../myorders/' , 'success' : "سفارش شما با موفقیت ثبت شد تا لحظاتی دیگر به فهرست سفارشاتتان خواهید رفت"}
if request.user.is_superuser:
if not isforall :
inform_warehouse_manager( message=render_to_string('mail/order_warehouse_manager.html', {'order': order}),
subject='سفارش نیازمند بررسی است')
else:
inform_admin('سفارش جدید', render_to_string('mail/order_added.html', {'order': order}))
return render_to_response("success.html",c);
示例5: order_create
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import status [as 别名]
def order_create(request, inmate_pk):
"""Create a new order for the given inmate"""
try:
# look at the request to find the current inmate
inmate = Inmate.objects.get(pk=inmate_pk)
# create a new order object for this inmate
order = Order()
order.inmate = inmate
order.status = 'OPEN'
order.save()
# save this order in the session
request.session['order'] = order
# redirect to the order_build view via named URLs to start adding books
return redirect(reverse('order-build'))
except Inmate.DoesNotExist:
print "There is no inmate with primary key " + request.session['inmate']
raise
示例6: enter_new_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import status [as 别名]
def enter_new_order(email, order_source, scene_list, option_string, note=""):
"""Places a new espa order in the database"""
order = Order()
order.orderid = generate_order_id(email)
order.email = email
order.note = note
order.status = "ordered"
order.order_date = datetime.datetime.now()
order.product_options = option_string
order.order_source = order_source
order.save()
for s in set(scene_list):
scene = Scene()
scene.name = s
scene.order = order
scene.order_date = datetime.datetime.now()
scene.status = "submitted"
scene.save()
return order
示例7: add_to_cart
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import status [as 别名]
def add_to_cart(request):
if request.method=="POST" and request.POST["quantity"].isnumeric():
o=OrderProduct()
pid=request.POST["productid"]
p=Product.objects.get(pk=pid) #look through database. get object back by id.
o.product=p #need to return object as o.product expects
# order=Order.objects.get(pk=1)
order=Order()
order.status=1
order.user_id=request.user.id
order.save()
o.order=order
o.quantity=request.POST["quantity"] #pass in quantity from post form
o.save()
return redirect("cart")
return redirect("product_list")
示例8: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import status [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)
示例9: load_ee_orders
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import status [as 别名]
def load_ee_orders():
""" Loads all the available orders from lta into our database and updates their status """
lta_service = lta.LtaServices()
# This returns a dict that contains a list of dicts{}
# key:(order_num,email) = list({sceneid:, unit_num:})
orders = lta_service.get_available_orders()
# This sets (hard codes) the product options that comes in from EE when someone
# is requesting processing via their interface
ee_options = {
"include_sourcefile": False,
"include_source_metadata": False,
"include_sr_toa": False,
"include_sr_thermal": False,
"include_sr": True,
"include_sr_browse": False,
"include_sr_ndvi": False,
"include_sr_ndmi": False,
"include_sr_nbr": False,
"include_sr_nbr2": False,
"include_sr_savi": False,
"include_sr_evi": False,
"include_solr_index": False,
"include_cfmask": False,
"reproject": False,
"resize": False,
"image_extents": False,
}
# Capture in our db
for eeorder, email in orders:
# create the orderid based on the info from the eeorder
order_id = generate_ee_order_id(email, eeorder)
order = None
# go look to see if it already exists in the db
try:
order = Order.objects.get(orderid=order_id)
except:
# Didn't find it in the db... make the order now
order = Order()
order.orderid = generate_ee_order_id(email, eeorder)
order.email = email
order.chain = "sr_ondemand"
order.status = "ordered"
order.note = "EarthExplorer order id: %s" % eeorder
order.product_options = json.dumps(ee_options)
order.ee_order_id = eeorder
order.order_source = "ee"
order.order_date = datetime.datetime.now()
order.save()
for s in orders[eeorder, email]:
# go look for the scene by ee_unit_id. This will stop
# duplicate key update collisions
scene = None
try:
scene = Scene.objects.get(order=order, ee_unit_id=s["unit_num"])
if scene.status == "complete":
success, msg, status = lta_service.update_order(eeorder, s["unit_num"], "C")
if not success:
log_msg = "Error updating lta for [eeorder:%s ee_unit_num:%s scene name:%s order:%s" % (
eeorder,
s["unit_num"],
scene.name,
order.orderid,
)
helperlogger(log_msg)
log_msg = "Error detail: lta return message:%s lta return status code:%s" % (msg, status)
helperlogger(log_msg)
elif scene.status == "unavailable":
success, msg, status = lta_service.update_order(eeorder, s["unit_num"], "R")
if not success:
log_msg = "Error updating lta for [eeorder:%s ee_unit_num:%s scene name:%s order:%s" % (
eeorder,
s["unit_num"],
scene.name,
order.orderid,
)
helperlogger(log_msg)
log_msg = "Error detail: lta return message:%s lta return status code:%s" % (msg, status)
helperlogger(log_msg)
except:
scene = Scene()
scene.name = s["sceneid"]
scene.ee_unit_id = s["unit_num"]
scene.order = order
scene.order_date = datetime.datetime.now()
scene.status = "submitted"
scene.save()
# Update LTA
success, msg, status = lta_service.update_order(eeorder, s["unit_num"], "I")
if not success:
log_msg = "Error updating lta for [eeorder:%s ee_unit_num:%s scene name:%s order:%s" % (
eeorder,
s["unit_num"],
#.........这里部分代码省略.........