本文整理汇总了Python中models.Order.email方法的典型用法代码示例。如果您正苦于以下问题:Python Order.email方法的具体用法?Python Order.email怎么用?Python Order.email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Order
的用法示例。
在下文中一共展示了Order.email方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import email [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: enter_new_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import email [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
示例3: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import email [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)
示例4: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import email [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()
# отправка уведомления
#.........这里部分代码省略.........
示例5: load_ee_orders
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import email [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"],
#.........这里部分代码省略.........
示例6: create_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import email [as 别名]
def create_order(request):
args = {
'user': request.user,
'form': OrderForm(),
'delivery_mass': DeliveryType.objects.all(),
'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.index = request.user.index
ord.address = request.user.address
# index
args['form'] = OrderForm(instance=ord)
if request.POST:
if request.POST.get('delivery', "") == "":
args['delivery_error'] = "- выберите тип доставки"
is_valid = False
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
if request.user.is_authenticated():
order.user = request.user
order.sum = delivery.price + get_sum(request)
order.save()
cart = get_cart(request)
if cart:
for pr in CartProduct.objects.filter(cart=cart):
pr.cart = None
pr.save()
order.products.add(pr)
else:
args['cart_error'] = "в вашей корзине ничего нет"
order.save()
if request.user.is_authenticated():
request.user.first_name = request.POST.get('first_name', "")
request.user.last_name = request.POST.get('last_name', "")
request.user.phone = request.POST.get('phone', "")
request.user.address = request.POST.get('address', "")
request.user.index = request.POST.get('index', "")
request.user.save()
email = request.POST.get('email', "")
t = get_template('create_order_sender.html')
html_content = t.render(Context({
'hello': 'Спасибо за заказ на <a href="http://darya-shop.ru">darya-shop.ru</a>!',
'user_active': request.user.is_authenticated(),
'order': order,
'order_status': STATUSES_LIST[order.status],
'products': order.products.all(),
}))
msg = EmailMultiAlternatives("Заказ на Darya-Shop", html_content, "[email protected]", [email, "[email protected]"])
msg.attach_alternative(html_content, "text/html")
msg.send()
return redirect("/orders/thanks/")
args['form'] = form
return render_to_response("create_order.html", args)